From: Jonathan Cameron <jic23@kernel.org>
To: Herve Codina <herve.codina@bootlin.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v4 2/3] iio: potentiometer: Add support for the Renesas X9250 potentiometers
Date: Sun, 14 May 2023 18:19:12 +0100 [thread overview]
Message-ID: <20230514181912.314ef781@jic23-huawei> (raw)
In-Reply-To: <20230514163233.0c048256@bootlin.com>
On Sun, 14 May 2023 16:32:33 +0200
Herve Codina <herve.codina@bootlin.com> wrote:
> Hi Jonathan,
>
> On Sat, 13 May 2023 19:35:25 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
>
> > On Tue, 9 May 2023 18:08:51 +0200
> > Herve Codina <herve.codina@bootlin.com> wrote:
> >
> > > The Renesas X9250 integrates four digitally controlled potentiometers.
> > > On each potentiometer, the X9250T has a 100 kOhms total resistance and
> > > the X9250U has a 50 kOhms total resistance.
> > >
> > > Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> >
> > As I only noticed one trivial thing I made the change whilst applying.
> > diff --git a/drivers/iio/potentiometer/x9250.c b/drivers/iio/potentiometer/x9250.c
> > index 3d4ca18d1f14..7e145d7d14f1 100644
> > --- a/drivers/iio/potentiometer/x9250.c
> > +++ b/drivers/iio/potentiometer/x9250.c
> > @@ -176,10 +176,7 @@ static int x9250_probe(struct spi_device *spi)
> >
> > x9250 = iio_priv(indio_dev);
> > x9250->spi = spi;
> > - x9250->cfg = device_get_match_data(&spi->dev);
> > - if (!x9250->cfg)
> > - x9250->cfg = &x9250_cfg[spi_get_device_id(spi)->driver_data];
> > -
> > + x9250->cfg = spi_get_device_match_data(spi);
> > x9250->wp_gpio = devm_gpiod_get_optional(&spi->dev, "wp", GPIOD_OUT_LOW);
> > if (IS_ERR(x9250->wp_gpio))
> > return dev_err_probe(&spi->dev, PTR_ERR(x9250->wp_gpio),
> >
>
> Are you sure about your modification ?
>
> I am not sure (maybe I am wrong) that
> x9250->cfg = spi_get_device_match_data(spi);
> is equivalent to
> x9250->cfg = &x9250_cfg[spi_get_device_id(spi)->driver_data];
>
> The spi_get_device_id(spi)->driver_data value I used is a simple integer
> (X9250T or X9250U) and not the x9250_cfg item.
> Maybe the x9250_id_table should be modified to replace X9250T by
> &x9250_cfg[X9250T] to have your modification working.
Excellent point. I'm was clearly half asleep. The mod should have included
switching them over to be pointers.
>
> The data defined in the driver are the following:
> --- 8< ---
> static const struct x9250_cfg x9250_cfg[] = {
> [X9250T] = { .name = "x9250t", .kohms = 100, },
> [X9250U] = { .name = "x9250u", .kohms = 50, },
> };
>
> ...
>
> static const struct of_device_id x9250_of_match[] = {
> { .compatible = "renesas,x9250t", &x9250_cfg[X9250T]},
> { .compatible = "renesas,x9250u", &x9250_cfg[X9250U]},
> { }
> };
> MODULE_DEVICE_TABLE(of, x9250_of_match);
>
> static const struct spi_device_id x9250_id_table[] = {
> { "x9250t", X9250T },
> { "x9250u", X9250U },
So these should be (kernel_ulong_t)&x9250_cfg[X9250T] etc for the data.
I've tweaked it so that is now the case. Oops and thanks for sanity checking.
Sometimes we see what we expect to see rather than what is there.
Tweak on top of original tweak is:
diff --git a/drivers/iio/potentiometer/x9250.c b/drivers/iio/potentiometer/x9250.c
index 7e145d7d14f1..0cc7f72529be 100644
--- a/drivers/iio/potentiometer/x9250.c
+++ b/drivers/iio/potentiometer/x9250.c
@@ -198,8 +198,8 @@ static const struct of_device_id x9250_of_match[] = {
MODULE_DEVICE_TABLE(of, x9250_of_match);
static const struct spi_device_id x9250_id_table[] = {
- { "x9250t", X9250T },
- { "x9250u", X9250U },
+ { "x9250t", (kernel_ulong_t)&x9250_cfg[X9250T] },
+ { "x9250u", (kernel_ulong_t)&x9250_cfg[X9250U] },
{ }
};
Jonathan
> { }
> };
> MODULE_DEVICE_TABLE(spi, x9250_id_table);
>
> static struct spi_driver x9250_spi_driver = {
> .driver = {
> .name = "x9250",
> .of_match_table = x9250_of_match,
> },
> .id_table = x9250_id_table,
> .probe = x9250_probe,
> };
> --- 8< ---
>
>
> Best regards,
> Hervé
>
next prev parent reply other threads:[~2023-05-14 17:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 16:08 [PATCH v4 0/3] Add the Renesas X9250 potentiometers IIO support Herve Codina
2023-05-09 16:08 ` [PATCH v4 1/3] dt-bindings: iio: potentiometer: Add the Renesas X9250 potentiometers Herve Codina
2023-05-09 17:34 ` Krzysztof Kozlowski
2023-05-09 16:08 ` [PATCH v4 2/3] iio: potentiometer: Add support for " Herve Codina
2023-05-13 18:35 ` Jonathan Cameron
2023-05-14 14:32 ` Herve Codina
2023-05-14 17:19 ` Jonathan Cameron [this message]
2023-05-15 6:44 ` Herve Codina
2023-05-20 16:30 ` Jonathan Cameron
2023-05-29 15:57 ` andy.shevchenko
2023-06-04 12:57 ` Jonathan Cameron
2023-05-28 22:35 ` andy.shevchenko
2023-05-09 16:08 ` [PATCH v4 3/3] MAINTAINERS: add the Renesas X9250 driver entry Herve Codina
2023-05-13 18:35 ` [PATCH v4 0/3] Add the Renesas X9250 potentiometers IIO support Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230514181912.314ef781@jic23-huawei \
--to=jic23@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=devicetree@vger.kernel.org \
--cc=herve.codina@bootlin.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).