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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VfXmzgQp1sDqYnsSNVxSmW-D4BhFdQK4tGmUg9oXZcnXg@mail.gmail.com>
Date:   Wed, 21 Feb 2018 23:57:53 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Pierre Bourdon <delroth@...gle.com>
Cc:     Jonathan Cameron <jic23@...nel.org>,
        Hartmut Knaack <knaack.h@....de>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        linux-iio@...r.kernel.org, Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        devicetree <devicetree@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Daniel Baluta <daniel.baluta@...il.com>
Subject: Re: [PATCH v2 1/2] iio: light: add driver for bh1730fvc chips

On Wed, Feb 21, 2018 at 9:45 PM, Pierre Bourdon <delroth@...gle.com> wrote:
> Ambient light sensor that supports visible light and IR measurements and
> configurable gain/integration time.
>
> Changed in v2:
> * Split off DT documentation change into a separate commit.
> * Use i2c's probe_new.

Btw, how big the difference with existing drivers?

> +       default:
> +               return -1;

Better to

return -EINVAL;

> +       highest = max(visible, ir);
> +
> +       /*
> +        * If the read value is being clamped, assume the worst and go to the
> +        * lowest possible gain. The alternative is doing multiple
> +        * recalibrations, which would be slower and have the same effect.
> +        */
> +       if (highest == USHRT_MAX)
> +               highest *= 128;
> +       else
> +               highest = (highest * 128) / bh1730_gain_multiplier(bh1730);

In both cases you multiply.
Why not just

     highest = max(visible, ir) * 128;

if (highest < USHRT_MAX)
...
?

> +       millilux = (u64)USEC_PER_MSEC * (visible_coef * visible - ir_coef * ir);

I'm not sure I understand how time units is related to lux one.

> +       millilux /= bh1730_gain_multiplier(bh1730);
> +       millilux *= 103;
> +       millilux /= itime_us;
> +       return millilux;
> +}

> +       indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*bh1730));
> +       if (!indio_dev)
> +               return -ENOMEM;
> +

> +       indio_dev->dev.parent = &client->dev;

Strange, it's not done in IIO core... Jonathan, is it true that in
case of devm_iio_device_alloc() all drivers use supplied struct device
as a parent one?
If so, doesn't make sense to modify IIO core to do this?

> +static int bh1730_remove(struct i2c_client *client)
> +{
> +       struct iio_dev *indio_dev = i2c_get_clientdata(client);
> +       struct bh1730_data *bh1730 = iio_priv(indio_dev);
> +

> +       iio_device_unregister(indio_dev);

Hmm... Do you still need this even with devm IIO in ->probe()?


> +#ifdef CONFIG_OF
> +#endif

This...

> +               .of_match_table = of_match_ptr(of_bh1730_match),

...and of_match_ptr() now pointless.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ