Re: [PATCH 07/14] leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support

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

 



On Thu, Jun 2, 2022 at 2:07 PM szuni chen <szunichen@xxxxxxxxx> wrote:
> Andy Shevchenko <andy.shevchenko@xxxxxxxxx> 於 2022年6月1日 週三 下午5:57寫道:
> > On Tue, May 31, 2022 at 1:32 PM ChiaEn Wu <peterwu.pub@xxxxxxxxx> wrote:

...

> > > +       const char * const states[] = { "off", "keep", "on" };
> > > +       const char *str;
> > > +       int ret;
> > > +
> > > +       if (!fwnode_property_read_string(init_data->fwnode,
> > > +                                        "default-state", &str)) {
> > > +               ret = match_string(states, ARRAY_SIZE(states), str);
> > > +               if (ret < 0)
> > > +                       ret = STATE_OFF;
> > > +
> > > +               led->default_state = ret;
> > > +       }
> >
> > fwnode_property_match_string()?
> Sorry, but I think the use of this function is different from my target.
> I want to read the string of the "default-state" property and figure
> out if the string is in the states array.
> But the fwnode_property_match_string aimed to figure out if the state
> in the property array.
> One is a property array and another one is a state array.

Ah, indeed. Nevertheless you may reduce the code base by doing like
the following (I wonder what your code do if there is no default-state
property):

  led->default_state = STATE_OFF; // it's by default off since
kzalloc(), so I don't see why we need this line at all.

  fwnode_property_read_string(init_data->fwnode, "default-state", &str);
  ret = match_string(states, ARRAY_SIZE(states), str);
  if (ret >= 0)
    led->default_state = ret;


-- 
With Best Regards,
Andy Shevchenko




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux