lkml.org 
[lkml]   [2020]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v5 4/6] drivers: leds: Add the iEi WT61P803 PUZZLE LED driver
Hello Andy,

On Sun, Oct 18, 2020 at 8:50 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Sun, Oct 18, 2020 at 12:18 AM Luka Kovacic <luka.kovacic@sartura.hr> 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

\
 
 \ /
  Last update: 2020-10-19 23:37    [W:0.080 / U:0.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site