public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: leds: replace divide condition 'shift / 16' with 'shift >= 16'
@ 2024-09-22 17:40 Dipendra Khadka
  2024-09-26 10:14 ` Pavel Machek
  2024-10-09 13:37 ` Lee Jones
  0 siblings, 2 replies; 6+ messages in thread
From: Dipendra Khadka @ 2024-09-22 17:40 UTC (permalink / raw)
  To: avel, ee; +Cc: Dipendra Khadka, linux-leds, linux-kernel

Smatch reported following:
'''
drivers/leds/leds-bcm6328.c:116 bcm6328_led_mode() warn: replace divide condition 'shift / 16' with 'shift >= 16'
drivers/leds/leds-bcm6328.c:360 bcm6328_led() warn: replace divide condition 'shift / 16' with 'shift >= 16'
'''
Replacing 'shift / 16' with 'shift >= 16'.

Signed-off-by: Dipendra Khadka <kdipendra88@gmail.com>
---
 drivers/leds/leds-bcm6328.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c
index 246f1296ab09..13f535ccba0b 100644
--- a/drivers/leds/leds-bcm6328.c
+++ b/drivers/leds/leds-bcm6328.c
@@ -113,7 +113,7 @@ static void bcm6328_led_mode(struct bcm6328_led *led, unsigned long value)
 	unsigned long val, shift;
 
 	shift = bcm6328_pin2shift(led->pin);
-	if (shift / 16)
+	if (shift >= 16)
 		mode = led->mem + BCM6328_REG_MODE_HI;
 	else
 		mode = led->mem + BCM6328_REG_MODE_LO;
@@ -357,7 +357,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
 		break;
 	case LEDS_DEFSTATE_KEEP:
 		shift = bcm6328_pin2shift(led->pin);
-		if (shift / 16)
+		if (shift >= 16)
 			mode = mem + BCM6328_REG_MODE_HI;
 		else
 			mode = mem + BCM6328_REG_MODE_LO;
-- 
2.43.0


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

* Re: [PATCH] Staging: leds: replace divide condition 'shift / 16' with 'shift >= 16'
  2024-09-22 17:40 [PATCH] Staging: leds: replace divide condition 'shift / 16' with 'shift >= 16' Dipendra Khadka
@ 2024-09-26 10:14 ` Pavel Machek
  2024-10-09 13:37 ` Lee Jones
  1 sibling, 0 replies; 6+ messages in thread
From: Pavel Machek @ 2024-09-26 10:14 UTC (permalink / raw)
  To: Dipendra Khadka; +Cc: avel, ee, linux-leds, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 571 bytes --]

On Sun 2024-09-22 17:40:19, Dipendra Khadka wrote:
> Smatch reported following:
> '''
> drivers/leds/leds-bcm6328.c:116 bcm6328_led_mode() warn: replace divide condition 'shift / 16' with 'shift >= 16'
> drivers/leds/leds-bcm6328.c:360 bcm6328_led() warn: replace divide condition 'shift / 16' with 'shift >= 16'
> '''
> Replacing 'shift / 16' with 'shift >= 16'.
> 
> Signed-off-by: Dipendra Khadka <kdipendra88@gmail.com>

Reviewed-by: Pavel Machek <pavel@ucw.cz>

BR,
								Pavel
-- 
People of Russia, stop Putin before his war on Ukraine escalates.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH] Staging: leds: replace divide condition 'shift / 16' with 'shift >= 16'
  2024-09-22 17:40 [PATCH] Staging: leds: replace divide condition 'shift / 16' with 'shift >= 16' Dipendra Khadka
  2024-09-26 10:14 ` Pavel Machek
@ 2024-10-09 13:37 ` Lee Jones
  2024-10-11 11:24   ` Pavel Machek
  1 sibling, 1 reply; 6+ messages in thread
From: Lee Jones @ 2024-10-09 13:37 UTC (permalink / raw)
  To: Dipendra Khadka; +Cc: avel, lee, linux-leds, linux-kernel

Staging!  Why Staging?

On Sun, 22 Sep 2024, Dipendra Khadka wrote:

> Smatch reported following:
> '''
> drivers/leds/leds-bcm6328.c:116 bcm6328_led_mode() warn: replace divide condition 'shift / 16' with 'shift >= 16'
> drivers/leds/leds-bcm6328.c:360 bcm6328_led() warn: replace divide condition 'shift / 16' with 'shift >= 16'
> '''
> Replacing 'shift / 16' with 'shift >= 16'.

More info please.

- What is the current problem you're attempting to solve?
- How does this patch help with that?
- What are the consequences for not applying this fix?

> Signed-off-by: Dipendra Khadka <kdipendra88@gmail.com>
> ---
>  drivers/leds/leds-bcm6328.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c
> index 246f1296ab09..13f535ccba0b 100644
> --- a/drivers/leds/leds-bcm6328.c
> +++ b/drivers/leds/leds-bcm6328.c
> @@ -113,7 +113,7 @@ static void bcm6328_led_mode(struct bcm6328_led *led, unsigned long value)
>  	unsigned long val, shift;
>  
>  	shift = bcm6328_pin2shift(led->pin);
> -	if (shift / 16)
> +	if (shift >= 16)
>  		mode = led->mem + BCM6328_REG_MODE_HI;
>  	else
>  		mode = led->mem + BCM6328_REG_MODE_LO;
> @@ -357,7 +357,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
>  		break;
>  	case LEDS_DEFSTATE_KEEP:
>  		shift = bcm6328_pin2shift(led->pin);
> -		if (shift / 16)
> +		if (shift >= 16)
>  			mode = mem + BCM6328_REG_MODE_HI;
>  		else
>  			mode = mem + BCM6328_REG_MODE_LO;
> -- 
> 2.43.0
> 
> 

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH] Staging: leds: replace divide condition 'shift / 16' with 'shift >= 16'
  2024-10-09 13:37 ` Lee Jones
@ 2024-10-11 11:24   ` Pavel Machek
  2024-10-15  9:01     ` Lee Jones
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2024-10-11 11:24 UTC (permalink / raw)
  To: Lee Jones; +Cc: Dipendra Khadka, avel, linux-leds, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1574 bytes --]

Hi!

> Staging!  Why Staging?
> 
> On Sun, 22 Sep 2024, Dipendra Khadka wrote:
> 
> > Smatch reported following:
> > '''
> > drivers/leds/leds-bcm6328.c:116 bcm6328_led_mode() warn: replace divide condition 'shift / 16' with 'shift >= 16'
> > drivers/leds/leds-bcm6328.c:360 bcm6328_led() warn: replace divide condition 'shift / 16' with 'shift >= 16'
> > '''
> > Replacing 'shift / 16' with 'shift >= 16'.
> 
> More info please.
> 
> - What is the current problem you're attempting to solve?
> - How does this patch help with that?
> - What are the consequences for not applying this fix?

Take a look at patch. Doing shift / 16 when testing on >= 16 is just
ugly. It is simple cleanup.

Reviewed-by: Pavel Machek <Pavel@ucw.cz>

Best regards,
						Pavel

> > @@ -113,7 +113,7 @@ static void bcm6328_led_mode(struct bcm6328_led *led, unsigned long value)
> >  	unsigned long val, shift;
> >  
> >  	shift = bcm6328_pin2shift(led->pin);
> > -	if (shift / 16)
> > +	if (shift >= 16)
> >  		mode = led->mem + BCM6328_REG_MODE_HI;
> >  	else
> >  		mode = led->mem + BCM6328_REG_MODE_LO;
> > @@ -357,7 +357,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
> >  		break;
> >  	case LEDS_DEFSTATE_KEEP:
> >  		shift = bcm6328_pin2shift(led->pin);
> > -		if (shift / 16)
> > +		if (shift >= 16)
> >  			mode = mem + BCM6328_REG_MODE_HI;
> >  		else
> >  			mode = mem + BCM6328_REG_MODE_LO;
> > -- 
> > 2.43.0
> > 
> > 
> 

-- 
People of Russia, stop Putin before his war on Ukraine escalates.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH] Staging: leds: replace divide condition 'shift / 16' with 'shift >= 16'
  2024-10-11 11:24   ` Pavel Machek
@ 2024-10-15  9:01     ` Lee Jones
  2024-10-17 19:23       ` Dipendra Khadka
  0 siblings, 1 reply; 6+ messages in thread
From: Lee Jones @ 2024-10-15  9:01 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Dipendra Khadka, avel, linux-leds, linux-kernel

On Fri, 11 Oct 2024, Pavel Machek wrote:

> Hi!
> 
> > Staging!  Why Staging?
> > 
> > On Sun, 22 Sep 2024, Dipendra Khadka wrote:
> > 
> > > Smatch reported following:
> > > '''
> > > drivers/leds/leds-bcm6328.c:116 bcm6328_led_mode() warn: replace divide condition 'shift / 16' with 'shift >= 16'
> > > drivers/leds/leds-bcm6328.c:360 bcm6328_led() warn: replace divide condition 'shift / 16' with 'shift >= 16'
> > > '''
> > > Replacing 'shift / 16' with 'shift >= 16'.
> > 
> > More info please.
> > 
> > - What is the current problem you're attempting to solve?
> > - How does this patch help with that?
> > - What are the consequences for not applying this fix?
> 
> Take a look at patch. Doing shift / 16 when testing on >= 16 is just
> ugly. It is simple cleanup.

You missed the point of the comments.

Copying / pasting the warning into the subject-line and commit message
without any additional wordage is sub-optimal.  Please improve the
commit message.

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH] Staging: leds: replace divide condition 'shift / 16' with 'shift >= 16'
  2024-10-15  9:01     ` Lee Jones
@ 2024-10-17 19:23       ` Dipendra Khadka
  0 siblings, 0 replies; 6+ messages in thread
From: Dipendra Khadka @ 2024-10-17 19:23 UTC (permalink / raw)
  To: Lee Jones; +Cc: Pavel Machek, avel, linux-leds, linux-kernel

Hi,

On Tue, 15 Oct 2024 at 14:46, Lee Jones <lee@kernel.org> wrote:
>
> On Fri, 11 Oct 2024, Pavel Machek wrote:
>
> > Hi!
> >
> > > Staging!  Why Staging?
> > >
> > > On Sun, 22 Sep 2024, Dipendra Khadka wrote:
> > >
> > > > Smatch reported following:
> > > > '''
> > > > drivers/leds/leds-bcm6328.c:116 bcm6328_led_mode() warn: replace divide condition 'shift / 16' with 'shift >= 16'
> > > > drivers/leds/leds-bcm6328.c:360 bcm6328_led() warn: replace divide condition 'shift / 16' with 'shift >= 16'
> > > > '''
> > > > Replacing 'shift / 16' with 'shift >= 16'.
> > >
> > > More info please.
> > >
> > > - What is the current problem you're attempting to solve?
> > > - How does this patch help with that?
> > > - What are the consequences for not applying this fix?
> >
> > Take a look at patch. Doing shift / 16 when testing on >= 16 is just
> > ugly. It is simple cleanup.
>
> You missed the point of the comments.
>
> Copying / pasting the warning into the subject-line and commit message
> without any additional wordage is sub-optimal.  Please improve the
> commit message.
>

Sure, I will send a v2 for this.

> --
> Lee Jones [李琼斯]

Best regards,
Dipendra Khadka

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

end of thread, other threads:[~2024-10-17 19:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-22 17:40 [PATCH] Staging: leds: replace divide condition 'shift / 16' with 'shift >= 16' Dipendra Khadka
2024-09-26 10:14 ` Pavel Machek
2024-10-09 13:37 ` Lee Jones
2024-10-11 11:24   ` Pavel Machek
2024-10-15  9:01     ` Lee Jones
2024-10-17 19:23       ` Dipendra Khadka

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