time: alarmtimer: Optimization function return value
PATCH 1/1 time: alarmtimer: Optimization function return value
Replace -1 return values with -EPERM.
--- kernel/time/alarmtimer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/time/alarmtimer.c +4 -4
@@ -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);
Signature · 1 line
2.18.2
kernel/time/alarmtimer.c static int alarmtimer_rtc_add_device(struct device *dev) · line 95
Quoted 3 lines · Li zeming
kernel/time/alarmtimer.c +1
-1if (!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.
kernel/time/alarmtimer.c static int alarmtimer_rtc_add_device(struct device *dev) · line 97
Quoted 3 lines
kernel/time/alarmtimer.c +1
-1if (!device_may_wakeup (rtc->dev.parent)) -return -1 ; +return -EPERM ;
Ditto
kernel/time/alarmtimer.c static int alarmtimer_rtc_add_device(struct device *dev) · line 107
Quoted 8 lines
kernel/time/alarmtimer.c +1
-1pdev =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
kernel/time/alarmtimer.c static int alarmtimer_rtc_add_device(struct device *dev) · line 116
Quoted 9 lines
kernel/time/alarmtimer.c +1
-1goto 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
Review static int alarmtimer_rtc_add_device(struct device *dev) · line 117
Quoted 1 line
(quoted diff) +0
-0}
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