From e3e11431fcbfb47695cce3cffc2c8740468d09af Mon Sep 17 00:00:00 2001 From: Jeremy90307 Date: Wed, 11 Dec 2024 18:23:59 +0800 Subject: [PATCH] Allow devicemodel built with Linux v6.11+ Since commit 0edb555 ("platform: Make platform_driver::remove() return void"), the original `platform_driver::remove()` function returned an integer value, usually an error code. This made driver developers think that errors were properly handled. However, the driver core does not stop the device removal process based on the error code, so the error code did not serve its intended purpose. Therefore, the return type was changed to `void` to avoid potential issues. Make the devicemodel example run successfully on Linux v6.11+. Testing detail: - Tested on Raspberry Pi 5B with Raspberry Pi OS (Debian 12, Linux version 6.12.1-v8-16k+) - Verified the devicemodel examples compile and load successfully --- examples/devicemodel.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/devicemodel.c b/examples/devicemodel.c index c2c66204..6646c057 100644 --- a/examples/devicemodel.c +++ b/examples/devicemodel.c @@ -4,6 +4,7 @@ #include #include #include +#include struct devicemodel_data { char *greeting; @@ -22,14 +23,18 @@ static int devicemodel_probe(struct platform_device *dev) return 0; } - +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0) static int devicemodel_remove(struct platform_device *dev) +#else +static void devicemodel_remove(struct platform_device *dev) +#endif { pr_info("devicemodel example removed\n"); /* Your device removal code */ - +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0) return 0; +#endif } static int devicemodel_suspend(struct device *dev)