diff mbox series

[v1,02/28] leds: core: The -ENOTSUPP should never be seen by user space

Message ID 20210510095045.3299382-3-andy.shevchenko@gmail.com
State New
Headers show
Series leds: cleanups and fwnode refcounting bug fixes | expand

Commit Message

Andy Shevchenko May 10, 2021, 9:50 a.m. UTC
Replace -ENOTSUPP by -EOPNOTSUPP when returning from exported function.

Fixes: 13ae79bbe4c2 ("leds: core: Drivers shouldn't enforce SYNC/ASYNC brightness setting")
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/leds/led-core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Pavel Machek May 28, 2021, 10:03 a.m. UTC | #1
On Mon 2021-05-10 12:50:19, Andy Shevchenko wrote:
> Replace -ENOTSUPP by -EOPNOTSUPP when returning from exported function.

> 

> Fixes: 13ae79bbe4c2 ("leds: core: Drivers shouldn't enforce SYNC/ASYNC brightness setting")

> Cc: Jacek Anaszewski <j.anaszewski@samsung.com>

> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>


Are you sure this is real problem? This does not sound like an error
path that should happen.

BR,
								Pavel

>  int led_set_brightness_sync(struct led_classdev *led_cdev, unsigned int value)

>  {

> +	int ret;

> +

>  	if (led_cdev->blink_delay_on || led_cdev->blink_delay_off)

>  		return -EBUSY;

>  

> @@ -297,7 +299,10 @@ int led_set_brightness_sync(struct led_classdev *led_cdev, unsigned int value)

>  	if (led_cdev->flags & LED_SUSPENDED)

>  		return 0;

>  

> -	return __led_set_brightness_blocking(led_cdev, led_cdev->brightness);

> +	ret = __led_set_brightness_blocking(led_cdev, led_cdev->brightness);

> +	if (ret == -ENOTSUPP)

> +		return -EOPNOTSUPP;

> +	return ret;

>  }

>  EXPORT_SYMBOL_GPL(led_set_brightness_sync);

>  


-- 
http://www.livejournal.com/~pavelmachek
Andy Shevchenko May 28, 2021, 10:43 a.m. UTC | #2
On Fri, May 28, 2021 at 12:03:39PM +0200, Pavel Machek wrote:
> On Mon 2021-05-10 12:50:19, Andy Shevchenko wrote:

> > Replace -ENOTSUPP by -EOPNOTSUPP when returning from exported function.

> > 

> > Fixes: 13ae79bbe4c2 ("leds: core: Drivers shouldn't enforce SYNC/ASYNC brightness setting")

> > Cc: Jacek Anaszewski <j.anaszewski@samsung.com>

> > Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> 

> Are you sure this is real problem?


(Potential) real problem, yes.

» This does not sound like an error
> path that should happen.


Before crafting this patch I have checked callers and _luckily_ they haven't
tested the returned code. But if any of the user decides to check -> real
problem.

-- 
With Best Regards,
Andy Shevchenko
Andy Shevchenko May 29, 2021, 9:42 a.m. UTC | #3
On Fri, May 28, 2021 at 1:43 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>

> On Fri, May 28, 2021 at 12:03:39PM +0200, Pavel Machek wrote:

> > On Mon 2021-05-10 12:50:19, Andy Shevchenko wrote:

> > > Replace -ENOTSUPP by -EOPNOTSUPP when returning from exported function.

> > >

> > > Fixes: 13ae79bbe4c2 ("leds: core: Drivers shouldn't enforce SYNC/ASYNC brightness setting")

> > > Cc: Jacek Anaszewski <j.anaszewski@samsung.com>

> > > Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> >

> > Are you sure this is real problem?

>

> (Potential) real problem, yes.

>

> » This does not sound like an error

> > path that should happen.

>

> Before crafting this patch I have checked callers and _luckily_ they haven't

> tested the returned code. But if any of the user decides to check -> real

> problem.


I have rephrased the commit message to point out the above.

-- 
With Best Regards,
Andy Shevchenko
diff mbox series

Patch

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index d56ff4939492..f962620a504f 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -289,6 +289,8 @@  EXPORT_SYMBOL_GPL(led_set_brightness_nosleep);
 
 int led_set_brightness_sync(struct led_classdev *led_cdev, unsigned int value)
 {
+	int ret;
+
 	if (led_cdev->blink_delay_on || led_cdev->blink_delay_off)
 		return -EBUSY;
 
@@ -297,7 +299,10 @@  int led_set_brightness_sync(struct led_classdev *led_cdev, unsigned int value)
 	if (led_cdev->flags & LED_SUSPENDED)
 		return 0;
 
-	return __led_set_brightness_blocking(led_cdev, led_cdev->brightness);
+	ret = __led_set_brightness_blocking(led_cdev, led_cdev->brightness);
+	if (ret == -ENOTSUPP)
+		return -EOPNOTSUPP;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(led_set_brightness_sync);