Re: [PATCH v5 4/6] drivers: leds: Add the iEi WT61P803 PUZZLE LED driver

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

 



Hello Andy,

On Sun, Oct 18, 2020 at 8:50 PM Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:
>
> On Sun, Oct 18, 2020 at 12:18 AM Luka Kovacic <luka.kovacic@xxxxxxxxxx> wrote:
> >
> > Add support for the iEi WT61P803 PUZZLE LED driver.
> > Currently only the front panel power LED is supported.
> >
> > This driver depends on the iEi WT61P803 PUZZLE MFD driver.
>
> ...

I'll expand the description a bit.

>
> > +/**
> > + * struct iei_wt61p803_puzzle_led - MCU LED Driver
> > + *
> > + * @mcu:               MCU struct pointer
> > + * @response_buffer    Global MCU response buffer allocation
> > + * @lock:              General mutex lock to protect simultaneous R/W access to led_power_state
> > + * @led_power_state:   State of the front panel power LED
> > + * @cdev:              LED classdev
> > + */
> > +struct iei_wt61p803_puzzle_led {
> > +       struct iei_wt61p803_puzzle *mcu;
> > +       unsigned char *response_buffer;
> > +       struct mutex lock;
> > +       int led_power_state;
>
> > +       struct led_classdev cdev;
>
> If you are using container_of() and move this member to be first, you
> will effectively make the container_of() a no-op.
>
> > +};
> > +
> > +static inline struct iei_wt61p803_puzzle_led *cdev_to_iei_wt61p803_puzzle_led
> > +       (struct led_classdev *led_cdev)
> > +{
> > +       return dev_get_drvdata(led_cdev->dev->parent);
>
> Why not simply call container_of()

I agree, container_of() is much cleaner, when used here.

>
> > +}
>
> ...
>
> > +       ret = fwnode_property_read_u32(child, "reg", &reg);
> > +       if (ret || reg > 1) {
> > +               dev_err(dev, "Could not register 'reg' (%lu)\n", (unsigned long)reg);
>
> When you cast explicitly during printf() you are doing something wrong
> in 99.9% cases.
> What's wrong with %u in this case?

I'll remove the cast, %u should be okay.

>
> > +               ret = -EINVAL;
> > +               goto err_child_node;
> > +       }
>
> --
> With Best Regards,
> Andy Shevchenko

Kind regards,
Luka



[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