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:   Wed, 27 Jul 2022 19:14:40 +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 v3 2/2] iio: humidity: hdc100x: add manufacturer and
 device ID check

On Wed, Jul 27, 2022 at 6:43 PM Potin Lai <potin.lai.pt@...il.com> wrote:
>
> Add manufacturer and device ID checking during probe, and skip the
> checking if chip model not supported.
>
> Supported:
> - HDC1000
> - HDC1010
> - HDC1050
> - HDC1080
>
> Not supported:
> - HDC1008

Almost there!

...

> +static bool is_valid_hdc100x(struct i2c_client *client)
> +{
> +       const struct hdc100x_chip_data *data;
> +       int mfr_id, dev_id;

> +       data = device_get_match_data(&client->dev);
> +       if (!data->support_mfr_check)
> +               return true;

Logically this part does belong to ->probe() and doesn't here (too
wide for this specific helper).

> +       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;
> +}

...

> +       if (!is_valid_hdc100x(client))
> +               return -EINVAL;

Means here you add

       const struct hdc100x_chip_data *data;
       struct device *dev = &client->dev;
       ...
       data = device_get_match_data(dev);
       if (data->support_mfr_check && !is_valid_hdc100x(client))
               return -EINVAL;

(Introducing a temporary variable for struct device pointer might also
help in future to refactor to make code neater.)

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ