[2/5] clocksource: timer-stm32-lp: Mark driver as non-removable

Message ID 20230313075430.2730803-3-u.kleine-koenig@pengutronix.de
State New
Headers
Series clocksource: Convert to platform remove callback returning void |

Commit Message

Uwe Kleine-König March 13, 2023, 7:54 a.m. UTC
  The comment in the remove callback suggests that the driver is not
supposed to be unbound. However returning an error code in the remove
callback doesn't accomplish that. Instead set the suppress_bind_attrs
property (which makes it impossible to unbind the driver via sysfs).
The only remaining way to unbind an stm32-lp device would be module
unloading, but that doesn't apply here, as the driver cannot be built as
a module.

Also drop the useless remove callback.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/clocksource/timer-stm32-lp.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
  

Comments

Uwe Kleine-König March 13, 2023, 9:43 a.m. UTC | #1
Hello,

On Mon, Mar 13, 2023 at 08:54:27AM +0100, Uwe Kleine-König wrote:
> The comment in the remove callback suggests that the driver is not
> supposed to be unbound. However returning an error code in the remove
> callback doesn't accomplish that. Instead set the suppress_bind_attrs
> property (which makes it impossible to unbind the driver via sysfs).
> The only remaining way to unbind an stm32-lp device would be module
> unloading, but that doesn't apply here, as the driver cannot be built as
> a module.
> 
> Also drop the useless remove callback.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/clocksource/timer-stm32-lp.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/clocksource/timer-stm32-lp.c b/drivers/clocksource/timer-stm32-lp.c
> index db2841d0beb8..616ea4fe4234 100644
> --- a/drivers/clocksource/timer-stm32-lp.c
> +++ b/drivers/clocksource/timer-stm32-lp.c
> @@ -195,11 +195,6 @@ static int stm32_clkevent_lp_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static int stm32_clkevent_lp_remove(struct platform_device *pdev)
> -{
> -	return -EBUSY; /* cannot unregister clockevent */
> -}
> -
>  static const struct of_device_id stm32_clkevent_lp_of_match[] = {
>  	{ .compatible = "st,stm32-lptimer-timer", },
>  	{},
> @@ -207,11 +202,11 @@ static const struct of_device_id stm32_clkevent_lp_of_match[] = {
>  MODULE_DEVICE_TABLE(of, stm32_clkevent_lp_of_match);
>  
>  static struct platform_driver stm32_clkevent_lp_driver = {
> -	.probe	= stm32_clkevent_lp_probe,
>  	.remove = stm32_clkevent_lp_remove,

This is of course broken, I intended to drop the remove line ... and
only noticed that breakage after sending out the patch set :-\

So please either skip this patch, or fixup while applying. If you do the
former I'll come back to this driver and send a fixed patch.

Best regards and sorry
Uwe
  
kernel test robot March 13, 2023, 1:10 p.m. UTC | #2
Hi Uwe,

I love your patch! Yet something to improve:

[auto build test ERROR on fe15c26ee26efa11741a7b632e9f23b01aca4cc6]

url:    https://github.com/intel-lab-lkp/linux/commits/Uwe-Kleine-K-nig/clocksource-sh_mtu2-Mark-driver-as-non-removable/20230313-155913
base:   fe15c26ee26efa11741a7b632e9f23b01aca4cc6
patch link:    https://lore.kernel.org/r/20230313075430.2730803-3-u.kleine-koenig%40pengutronix.de
patch subject: [PATCH 2/5] clocksource: timer-stm32-lp: Mark driver as non-removable
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230313/202303132013.6jB1U6Dg-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d4016ca907c0dd473c1f28ce43f4ef2495cf1dd5
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Uwe-Kleine-K-nig/clocksource-sh_mtu2-Mark-driver-as-non-removable/20230313-155913
        git checkout d4016ca907c0dd473c1f28ce43f4ef2495cf1dd5
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303132013.6jB1U6Dg-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/clocksource/timer-stm32-lp.c:205:19: error: 'stm32_clkevent_lp_remove' undeclared here (not in a function); did you mean 'stm32_clkevent_lp_probe'?
     205 |         .remove = stm32_clkevent_lp_remove,
         |                   ^~~~~~~~~~~~~~~~~~~~~~~~
         |                   stm32_clkevent_lp_probe
   drivers/clocksource/timer-stm32-lp.c:142:12: warning: 'stm32_clkevent_lp_probe' defined but not used [-Wunused-function]
     142 | static int stm32_clkevent_lp_probe(struct platform_device *pdev)
         |            ^~~~~~~~~~~~~~~~~~~~~~~


vim +205 drivers/clocksource/timer-stm32-lp.c

48b41c5e2de6c5 Benjamin Gaignard 2020-06-03  203  
48b41c5e2de6c5 Benjamin Gaignard 2020-06-03  204  static struct platform_driver stm32_clkevent_lp_driver = {
48b41c5e2de6c5 Benjamin Gaignard 2020-06-03 @205  	.remove = stm32_clkevent_lp_remove,
48b41c5e2de6c5 Benjamin Gaignard 2020-06-03  206  	.driver	= {
48b41c5e2de6c5 Benjamin Gaignard 2020-06-03  207  		.name = "stm32-lptimer-timer",
48b41c5e2de6c5 Benjamin Gaignard 2020-06-03  208  		.of_match_table = of_match_ptr(stm32_clkevent_lp_of_match),
d4016ca907c0dd Uwe Kleine-König  2023-03-13  209  		.suppress_bind_attrs = true,
48b41c5e2de6c5 Benjamin Gaignard 2020-06-03  210  	},
48b41c5e2de6c5 Benjamin Gaignard 2020-06-03  211  };
48b41c5e2de6c5 Benjamin Gaignard 2020-06-03  212  module_platform_driver(stm32_clkevent_lp_driver);
48b41c5e2de6c5 Benjamin Gaignard 2020-06-03  213
  

Patch

diff --git a/drivers/clocksource/timer-stm32-lp.c b/drivers/clocksource/timer-stm32-lp.c
index db2841d0beb8..616ea4fe4234 100644
--- a/drivers/clocksource/timer-stm32-lp.c
+++ b/drivers/clocksource/timer-stm32-lp.c
@@ -195,11 +195,6 @@  static int stm32_clkevent_lp_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int stm32_clkevent_lp_remove(struct platform_device *pdev)
-{
-	return -EBUSY; /* cannot unregister clockevent */
-}
-
 static const struct of_device_id stm32_clkevent_lp_of_match[] = {
 	{ .compatible = "st,stm32-lptimer-timer", },
 	{},
@@ -207,11 +202,11 @@  static const struct of_device_id stm32_clkevent_lp_of_match[] = {
 MODULE_DEVICE_TABLE(of, stm32_clkevent_lp_of_match);
 
 static struct platform_driver stm32_clkevent_lp_driver = {
-	.probe	= stm32_clkevent_lp_probe,
 	.remove = stm32_clkevent_lp_remove,
 	.driver	= {
 		.name = "stm32-lptimer-timer",
 		.of_match_table = of_match_ptr(stm32_clkevent_lp_of_match),
+		.suppress_bind_attrs = true,
 	},
 };
 module_platform_driver(stm32_clkevent_lp_driver);