* [sparse stuff] bug in lp3944_led_set_brightness()
@ 2011-10-05 9:32 Dan Carpenter
2011-10-05 20:21 ` Antonio Ospite
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2011-10-05 9:32 UTC (permalink / raw)
To: ospite; +Cc: Richard Purdie, open list
Hi Antonio,
I was going through some Sparse warnings and this one seems pretty
valid.
drivers/leds/leds-lp3944.c +292 23:
warning: mixing different enum types
284 static void lp3944_led_set_brightness(struct led_classdev *led_cdev,
285 enum led_brightness brightness)
286 {
287 struct lp3944_led_data *led = ldev_to_led(led_cdev);
288
289 dev_dbg(&led->client->dev, "%s: %s, %d\n",
290 __func__, led_cdev->name, brightness);
291
292 led->status = brightness;
^^^^^^^^^^^^^^^^^^^^^^^^
293 schedule_work(&led->work);
294 }
led->status should be values between 0-3. brightness is 0, 127 and
255.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sparse stuff] bug in lp3944_led_set_brightness()
2011-10-05 9:32 [sparse stuff] bug in lp3944_led_set_brightness() Dan Carpenter
@ 2011-10-05 20:21 ` Antonio Ospite
2011-10-06 21:34 ` [PATCH] leds: leds-lp3944, fix "sparse" warning "mixing different enum types" Antonio Ospite
0 siblings, 1 reply; 5+ messages in thread
From: Antonio Ospite @ 2011-10-05 20:21 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Richard Purdie, open list
[-- Attachment #1: Type: text/plain, Size: 2153 bytes --]
On Wed, 5 Oct 2011 12:32:48 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Hi Antonio,
>
> I was going through some Sparse warnings and this one seems pretty
> valid.
>
> drivers/leds/leds-lp3944.c +292 23:
> warning: mixing different enum types
>
> 284 static void lp3944_led_set_brightness(struct led_classdev *led_cdev,
> 285 enum led_brightness brightness)
> 286 {
> 287 struct lp3944_led_data *led = ldev_to_led(led_cdev);
> 288
> 289 dev_dbg(&led->client->dev, "%s: %s, %d\n",
> 290 __func__, led_cdev->name, brightness);
> 291
> 292 led->status = brightness;
> ^^^^^^^^^^^^^^^^^^^^^^^^
> 293 schedule_work(&led->work);
> 294 }
>
>
> led->status should be values between 0-3. brightness is 0, 127 and
> 255.
>
Hi Dan, thanks for reporting that.
AFAICS this is not a problem _in_practice_ as lp3944_led_set_brightness
() is called by the leds framework with brightness values already
limited by max_brightness, so it is always 0 or 1 in our case. The
sparse warning is not pretty tho, so I guess we can safely get rid of it
anyways with:
led->status = !!brightness;
keeping track of LP3944_LED_STATUS_OFF and LP3944_LED_STATUS_ON only in
lp3944_led_set_brightness() is OK, as the handling of DIM (blinking)
mode[s] is in lp3944_led_set_blink().
I am following up with a patch in that direction tomorrow, after a test
on the actual hardware.
This is the rationale behind the current code if it is of any interest:
in the development phase of the driver I was abusing brightness = {2,3}
to trigger the hardware blinking function, but then I set the
max_brightness to 1 and so this abusing mechanism became inactive and I
must have forgotten about it.
Thanks again.
Regards,
Antonio
--
Antonio Ospite
http://ao2.it
PGP public key ID: 0x4553B001
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] leds: leds-lp3944, fix "sparse" warning "mixing different enum types"
2011-10-05 20:21 ` Antonio Ospite
@ 2011-10-06 21:34 ` Antonio Ospite
2011-11-16 15:00 ` Antonio Ospite
0 siblings, 1 reply; 5+ messages in thread
From: Antonio Ospite @ 2011-10-06 21:34 UTC (permalink / raw)
To: Richard Purdie; +Cc: Antonio Ospite, Dan Carpenter, open list
Fix a warning from "sparse":
drivers/leds/leds-lp3944.c:292:23: warning: mixing different enum types
drivers/leds/leds-lp3944.c:292:23: int enum led_brightness versus
drivers/leds/leds-lp3944.c:292:23: int enum lp3944_status
Keeping track of LP3944_LED_STATUS_OFF and LP3944_LED_STATUS_ON only in
lp3944_led_set_brightness() is OK, as the handling of DIM (blinking)
mode[s] is in lp3944_led_set_blink().
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
---
drivers/leds/leds-lp3944.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c
index 9010c05..3cc01fb 100644
--- a/drivers/leds/leds-lp3944.c
+++ b/drivers/leds/leds-lp3944.c
@@ -289,7 +289,7 @@ static void lp3944_led_set_brightness(struct led_classdev *led_cdev,
dev_dbg(&led->client->dev, "%s: %s, %d\n",
__func__, led_cdev->name, brightness);
- led->status = brightness;
+ led->status = !!brightness;
schedule_work(&led->work);
}
--
1.7.6.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: leds-lp3944, fix "sparse" warning "mixing different enum types"
2011-10-06 21:34 ` [PATCH] leds: leds-lp3944, fix "sparse" warning "mixing different enum types" Antonio Ospite
@ 2011-11-16 15:00 ` Antonio Ospite
2011-11-16 18:43 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Antonio Ospite @ 2011-11-16 15:00 UTC (permalink / raw)
To: Richard Purdie; +Cc: Antonio Ospite, Dan Carpenter, open list
[-- Attachment #1: Type: text/plain, Size: 1589 bytes --]
On Thu, 6 Oct 2011 23:34:44 +0200
Antonio Ospite <ospite@studenti.unina.it> wrote:
> Fix a warning from "sparse":
>
> drivers/leds/leds-lp3944.c:292:23: warning: mixing different enum types
> drivers/leds/leds-lp3944.c:292:23: int enum led_brightness versus
> drivers/leds/leds-lp3944.c:292:23: int enum lp3944_status
>
> Keeping track of LP3944_LED_STATUS_OFF and LP3944_LED_STATUS_ON only in
> lp3944_led_set_brightness() is OK, as the handling of DIM (blinking)
> mode[s] is in lp3944_led_set_blink().
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Ping.
Dan, did you receive this one? I can't see it in 3.2-rc2.
Regards,
Antonio.
> ---
> drivers/leds/leds-lp3944.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c
> index 9010c05..3cc01fb 100644
> --- a/drivers/leds/leds-lp3944.c
> +++ b/drivers/leds/leds-lp3944.c
> @@ -289,7 +289,7 @@ static void lp3944_led_set_brightness(struct led_classdev *led_cdev,
> dev_dbg(&led->client->dev, "%s: %s, %d\n",
> __func__, led_cdev->name, brightness);
>
> - led->status = brightness;
> + led->status = !!brightness;
> schedule_work(&led->work);
> }
>
> --
> 1.7.6.3
>
>
--
Antonio Ospite
http://ao2.it
PGP public key ID: 0x4553B001
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: leds-lp3944, fix "sparse" warning "mixing different enum types"
2011-11-16 15:00 ` Antonio Ospite
@ 2011-11-16 18:43 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2011-11-16 18:43 UTC (permalink / raw)
To: Antonio Ospite; +Cc: Richard Purdie, open list
[-- Attachment #1: Type: text/plain, Size: 963 bytes --]
On Wed, Nov 16, 2011 at 04:00:07PM +0100, Antonio Ospite wrote:
> On Thu, 6 Oct 2011 23:34:44 +0200
> Antonio Ospite <ospite@studenti.unina.it> wrote:
>
> > Fix a warning from "sparse":
> >
> > drivers/leds/leds-lp3944.c:292:23: warning: mixing different enum types
> > drivers/leds/leds-lp3944.c:292:23: int enum led_brightness versus
> > drivers/leds/leds-lp3944.c:292:23: int enum lp3944_status
> >
> > Keeping track of LP3944_LED_STATUS_OFF and LP3944_LED_STATUS_ON only in
> > lp3944_led_set_brightness() is OK, as the handling of DIM (blinking)
> > mode[s] is in lp3944_led_set_blink().
> >
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
>
> Ping.
> Dan, did you receive this one? I can't see it in 3.2-rc2.
Richard is the maintainer, not me. But he's on the CC list as well
so hopefully he can answer your question.
regards,
dan carpenter
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-11-16 18:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-05 9:32 [sparse stuff] bug in lp3944_led_set_brightness() Dan Carpenter
2011-10-05 20:21 ` Antonio Ospite
2011-10-06 21:34 ` [PATCH] leds: leds-lp3944, fix "sparse" warning "mixing different enum types" Antonio Ospite
2011-11-16 15:00 ` Antonio Ospite
2011-11-16 18:43 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox