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: <CAHp75VfrRJmB-Q6TM+Tiy79_q63=cOvyrePMQwi6ZbvDNUPezQ@mail.gmail.com>
Date: Wed, 20 Aug 2025 13:07:28 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Ben Collins <bcollins@...ter.com>
Cc: Jonathan Cameron <jic23@...nel.org>, David Lechner <dlechner@...libre.com>, 
	Nuno Sá <nuno.sa@...log.com>, 
	Andy Shevchenko <andy@...nel.org>, Rob Herring <robh@...nel.org>, 
	Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, 
	Andrew Hepp <andrew.hepp@...pp.dev>, linux-iio@...r.kernel.org, 
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7 4/5] iio: mcp9600: Recognize chip id for mcp9601

On Wed, Aug 20, 2025 at 2:45 AM Ben Collins <bcollins@...ter.com> wrote:
>
> The current driver works with mcp9601, but emits a warning because it
> does not recognize the chip id.
>
> MCP9601 is a superset of MCP9600. The drivers works without changes
> on this chipset.
>
> However, the 9601 chip supports open/closed-circuit detection if wired
> properly, so we'll need to be able to differentiate between them.
>
> Moved "struct mcp9600_data" up in the file since a later patch will
> need it and chip_info before the declerations.

declarations

...

> +struct mcp9600_data {
> +       struct i2c_client *client;
> +};
> +
>  #define MCP9600_CHANNELS(hj_num_ev, hj_ev_spec_off, cj_num_ev, cj_ev_spec_off) \
>         {                                                                      \
>                 {                                                              \
> @@ -123,10 +133,6 @@ static const struct iio_chan_spec mcp9600_channels[][2] = {
>         MCP9600_CHANNELS(2, 0, 2, 0), /* Alerts: 1 2 3 4 */
>  };
>
> -struct mcp9600_data {
> -       struct i2c_client *client;
> -};
> -

It's not obvious why this piece of change is needed. AFAICS it's a stray change.

...

>  static int mcp9600_probe(struct i2c_client *client)
>  {
> +       const struct mcp_chip_info *chip_info = i2c_get_match_data(client);

>         struct iio_dev *indio_dev;
>         struct mcp9600_data *data;
> -       int ret, ch_sel;
> +       int ch_sel, dev_id, ret;

It's hard to maintain and prone to subtle errors if we split
assignment and check, so please move assignment here.

       chip_info = i2c_get_match_data(client);

> +       if (!chip_info)
> +               return dev_err_probe(&client->dev, -EINVAL,

In such cases we usually use ENODEV.

> +                                    "No chip-info found for device\n");

...

> +               return dev_err_probe(&client->dev, dev_id,
> +                                    "Failed to read device ID\n");

With

  struct device *dev = &client->dev;

at the top of the function this and other statements become neater and
easier to follow. In particular, I believe this one may become a one
liner after the change.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ