public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] time: alarmtimer: Optimization function return value
@ 2023-06-09 18:09 Li zeming
  2023-06-10 12:20 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Li zeming @ 2023-06-09 18:09 UTC (permalink / raw)
  To: jstultz, tglx, sboyd; +Cc: linux-kernel, Li zeming

Replace -1 return values with -EPERM.

Signed-off-by: Li zeming <zeming@nfschina.com>
---
 kernel/time/alarmtimer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 82b28ab0f328..e918d556dd51 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -92,9 +92,9 @@ static int alarmtimer_rtc_add_device(struct device *dev)
 		return -EBUSY;
 
 	if (!test_bit(RTC_FEATURE_ALARM, rtc->features))
-		return -1;
+		return -EPERM;
 	if (!device_may_wakeup(rtc->dev.parent))
-		return -1;
+		return -EPERM;
 
 	pdev = platform_device_register_data(dev, "alarmtimer",
 					     PLATFORM_DEVID_AUTO, NULL, 0);
@@ -104,7 +104,7 @@ static int alarmtimer_rtc_add_device(struct device *dev)
 	spin_lock_irqsave(&rtcdev_lock, flags);
 	if (!IS_ERR(pdev) && !rtcdev) {
 		if (!try_module_get(rtc->owner)) {
-			ret = -1;
+			ret = -EPERM;
 			goto unlock;
 		}
 
@@ -113,7 +113,7 @@ static int alarmtimer_rtc_add_device(struct device *dev)
 		get_device(dev);
 		pdev = NULL;
 	} else {
-		ret = -1;
+		ret = -EPERM;
 	}
 unlock:
 	spin_unlock_irqrestore(&rtcdev_lock, flags);
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] time: alarmtimer: Optimization function return value
  2023-06-09 18:09 [PATCH] time: alarmtimer: Optimization function return value Li zeming
@ 2023-06-10 12:20 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2023-06-10 12:20 UTC (permalink / raw)
  To: Li zeming, jstultz, sboyd; +Cc: linux-kernel, Li zeming

On Sat, Jun 10 2023 at 02:09, Li zeming wrote:
>  	if (!test_bit(RTC_FEATURE_ALARM, rtc->features))
> -		return -1;
> +		return -EPERM;

I know you are only replacing the -1, but EPERM does not make any sense
here. It's not a permission problem, it's the lack of a feature. So the
proper code is -ENODEV.

>  	if (!device_may_wakeup(rtc->dev.parent))
> -		return -1;
> +		return -EPERM;

Ditto
 
>  	pdev = platform_device_register_data(dev, "alarmtimer",
>  					     PLATFORM_DEVID_AUTO, NULL, 0);
> @@ -104,7 +104,7 @@ static int alarmtimer_rtc_add_device(struct device *dev)
>  	spin_lock_irqsave(&rtcdev_lock, flags);
>  	if (!IS_ERR(pdev) && !rtcdev) {
>  		if (!try_module_get(rtc->owner)) {
> -			ret = -1;
> +			ret = -EPERM;

Same here.

But this error case is broken because it does not undo the

     device_init_wakeup(&pdev->dev, true);

So this needs

+  		device_init_wakeup(&pdev->dev, false);

before the goto

>  			goto unlock;
>  		}
>  
> @@ -113,7 +113,7 @@ static int alarmtimer_rtc_add_device(struct device *dev)
>  		get_device(dev);
>  		pdev = NULL;
>  	} else {
> -		ret = -1;
> +		ret = -EPERM;

                ENODEV

>  	}

So please do not blindly replace something without actually analysing
it. There is a reason why these things are not just "fixed" with a
script.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-10 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-09 18:09 [PATCH] time: alarmtimer: Optimization function return value Li zeming
2023-06-10 12:20 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox