lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 19 Oct 2020 23:35:03 +0200
From:   Luka Kovacic <luka.kovacic@...tura.hr>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        linux-hwmon@...r.kernel.org,
        Linux LED Subsystem <linux-leds@...r.kernel.org>,
        Lee Jones <lee.jones@...aro.org>, Pavel Machek <pavel@....cz>,
        Dan Murphy <dmurphy@...com>, Rob Herring <robh+dt@...nel.org>,
        Jean Delvare <jdelvare@...e.com>,
        Guenter Roeck <linux@...ck-us.net>,
        Marek BehĂșn <marek.behun@....cz>,
        Luka Perkov <luka.perkov@...tura.hr>,
        Robert Marko <robert.marko@...tura.hr>
Subject: Re: [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@...il.com> wrote:
>
> On Sun, Oct 18, 2020 at 12:18 AM Luka Kovacic <luka.kovacic@...tura.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ