[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZwkLCE9x5DWtaaJU@duo.ucw.cz>
Date: Fri, 11 Oct 2024 13:24:56 +0200
From: Pavel Machek <pavel@....cz>
To: Lee Jones <lee@...nel.org>
Cc: Dipendra Khadka <kdipendra88@...il.com>, avel@....cz,
linux-leds@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Staging: leds: replace divide condition 'shift / 16'
with 'shift >= 16'
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@....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.
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists