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: <CAHp75Vfm+NDzZEB1Qp-3+mbj=NOko=5jjcHr_A4J6-jMpTykhg@mail.gmail.com>
Date:   Fri, 1 Jul 2022 12:13:24 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Nishanth Menon <nm@...com>
Cc:     Javier Martinez Canillas <javier@....samsung.com>,
        Nuno Sá <nuno.sa@...log.com>,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        Alexandru Ardelean <ardeleanalex@...il.com>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Jonathan Cameron <jic23@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        linux-iio <linux-iio@...r.kernel.org>,
        Stable <stable@...r.kernel.org>
Subject: Re: [PATCH] iio: adc: ti-adc128s052: Fix number of channels when
 device tree is used

On Fri, Jul 1, 2022 at 1:02 AM Nishanth Menon <nm@...com> wrote:
>
> When device_match_data is called - with device tree, of_match list is

device_get_match_data() ?

> looked up to find the data, which by default is 0. So, no matter which
> kind of device compatible we use, we match with config 0 which implies
> we enable 8 channels even on devices that do not have 8 channels.
>
> Solve it by providing the match data similar to what we do with the ACPI
> lookup information.
>
> Fixes: 9e611c9e5a20 ("iio: adc128s052: Add OF match table")
> Cc: <stable@...r.kernel.org> # 5.0+
> Signed-off-by: Nishanth Menon <nm@...com>

...

> +       { .compatible = "ti,adc128s052", .data = 0},

No assignment, 0 _is_ the default here.

> +       { .compatible = "ti,adc122s021", .data = 1},
> +       { .compatible = "ti,adc122s051", .data = 1},
> +       { .compatible = "ti,adc122s101", .data = 1},
> +       { .compatible = "ti,adc124s021", .data = 2},
> +       { .compatible = "ti,adc124s051", .data = 2},
> +       { .compatible = "ti,adc124s101", .data = 2},

What you need _ideally_ is rather use pointers to data structure where
each of that chip is defined, then it will be as simple as


const struct my_custom_drvdata *data;

data = device_get_match_data(dev);

Where my_custom_drvdata::num_of_channels will be already assigned to
whatever you want on a per chip basis.

If the number of channels is the only data you have, then yes, cast it
to void * in the OF ID table and

num = (uintptr_t)device_get_match_data(dev);

will suffice.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ