Re: [PATCH] leds: lm355x: Fix sparse warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday, August 02, 2013 7:24 AM, Bryan Wu wrote:
> On Wed, Jul 31, 2013 at 11:03 PM, Jingoo Han <jg1.han@xxxxxxxxxxx> wrote:
> > Don't mix different enum types to fix the following sparse warnings.
> >
> > drivers/leds/leds-lm355x.c:180:49: warning: mixing different enum types
> > drivers/leds/leds-lm355x.c:180:49:     int enum lm355x_tx2  versus
> > drivers/leds/leds-lm355x.c:180:49:     int enum lm355x_ntc
> > drivers/leds/leds-lm355x.c:191:49: warning: mixing different enum types
> > drivers/leds/leds-lm355x.c:191:49:     int enum lm355x_tx2  versus
> > drivers/leds/leds-lm355x.c:191:49:     int enum lm355x_ntc
> >
> > Signed-off-by: Jingoo Han <jg1.han@xxxxxxxxxxx>
> > ---
> >  drivers/leds/leds-lm355x.c |    7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c
> > index 591eb5e..9772aad 100644
> > --- a/drivers/leds/leds-lm355x.c
> > +++ b/drivers/leds/leds-lm355x.c
> > @@ -177,7 +177,8 @@ static int lm355x_chip_init(struct lm355x_chip_data *chip)
> >         /* input and output pins configuration */
> >         switch (chip->type) {
> >         case CHIP_LM3554:
> > -               reg_val = pdata->pin_tx2 | pdata->ntc_pin;
> > +               reg_val = pdata->pin_tx2;
> > +               reg_val |= pdata->ntc_pin;
> >                 ret = regmap_update_bits(chip->regmap, 0xE0, 0x28, reg_val);
> >                 if (ret < 0)
> >                         goto out;
> > @@ -188,7 +189,9 @@ static int lm355x_chip_init(struct lm355x_chip_data *chip)
> >                 break;
> >
> >         case CHIP_LM3556:
> > -               reg_val = pdata->pin_tx2 | pdata->ntc_pin | pdata->pass_mode;
> > +               reg_val = pdata->pin_tx2;
> > +               reg_val |= pdata->ntc_pin;
> > +               reg_val |= pdata->pass_mode;
> 
> Although there are some warning from sparse, changing a beautiful one
> line code into multiple lines code looks not good to me. Is there any
> better way to solve this issue.

+CC Joe Perches,

Hi Joe Perches,

Do you know any better way to fix sparse warnings, without changing a one
line into multiple lines?


Maybe if 'enum' is changed to '#define', it will not make the sparse
warnings. But, it requires many code changes.

-enum lm355x_tx2 {
-       LM355x_PIN_TX_DISABLE = 0,
-       LM3554_PIN_TX_ENABLE = 0x20,
-       LM3556_PIN_TX_ENABLE = 0x40,
-};
+#define        LM355x_PIN_TX_DISABLE 0
+#define        LM3554_PIN_TX_ENABLE 0x20
+#define        LM3556_PIN_TX_ENABLE 0x40

-enum lm355x_ntc {
-       LM355x_PIN_NTC_DISABLE = 0,
-       LM3554_PIN_NTC_ENABLE = 0x08,
-       LM3556_PIN_NTC_ENABLE = 0x80,
-};
+#define        LM355x_PIN_NTC_DISABLE 0
+#define        LM3554_PIN_NTC_ENABLE 0x08
+#define        LM3556_PIN_NTC_ENABLE 0x80

Best regards,
Jingoo Han

> 
> Thanks,
> -Bryan
> 
> >                 ret = regmap_update_bits(chip->regmap, 0x0A, 0xC4, reg_val);
> >                 if (ret < 0)
> >                         goto out;
> > --
> > 1.7.10.4
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-leds" in
> > the body of a message to majordomo@xxxxxxxxxxxxxxx
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux