[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHp75VdH4UXsG7GP5A3ocy0-J2XDr=9akwX+dwczt6ejA8kO7A@mail.gmail.com>
Date: Mon, 25 Jul 2022 23:01:56 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Potin Lai <potin.lai.pt@...il.com>
Cc: Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Patrick Williams <patrick@...cx.xyz>,
Potin Lai <potin.lai@...ntatw.com>,
linux-iio <linux-iio@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] iio: humidity: hdc100x: add manufacturer and device
id cehck
On Fri, Jul 22, 2022 at 7:25 PM Potin Lai <potin.lai.pt@...il.com> wrote:
>
> Add manufacturer and device id checking during probe, and Skip the
ID
skip
> checking if chip model not supported.
>
> Supported:
> - HDC1000
> - HDC1010
> - HDC1050
> - HDC1080
>
> Not supported:
> - HDC1008
...
> +enum {
> + HDC100X,
> + HDC1000,
> + HDC1008,
> + HDC1010,
> + HDC1050,
> + HDC1080
+ Comma here.
> +};
...
> +static const struct of_device_id hdc100x_dt_ids[];
No, drop it.
...
> + match = i2c_of_match_device(hdc100x_dt_ids, client);
> +
> + if (match) {
> + of_data = (struct hdc100x_of_data *)match->data;
> + if (!of_data->support_mfr_check)
> + return true;
Besides the redundant blank line this call to i2c_of_match_device() is not good.
of_data is a misleading name. What about ACPI?
What you are looking for is:
data = device_get_match_data(&client->dev);
> + } else if (id->driver_data == HDC1008)
Don't use I2C id field, switch to i2c ->probe_new() if it's not done yet.
> + return true;
> +
> + mfr_id = hdc100x_read_mfr_id(client);
> + dev_id = hdc100x_read_dev_id(client);
> + if (mfr_id == HDC100X_MFR_ID &&
> + (dev_id == 0x1000 || dev_id == 0x1050))
> + return true;
> +
> + return false;
> +}
...
> static const struct i2c_device_id hdc100x_id[] = {
> - { "hdc100x", 0 },
> - { "hdc1000", 0 },
> - { "hdc1008", 0 },
> - { "hdc1010", 0 },
> - { "hdc1050", 0 },
> - { "hdc1080", 0 },
> + { "hdc100X", HDC100X },
> + { "hdc1000", HDC1000 },
> + { "hdc1008", HDC1008 },
> + { "hdc1010", HDC1010 },
> + { "hdc1050", HDC1050 },
> + { "hdc1080", HDC1080 },
Please, use pointers as in of_device_id table.
> { }
> };
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists