From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
Cc: Jonathan Cameron <jic23@kernel.org>,
"Voss, Dr. Nikolaus" <Nikolaus.Dr.Voss@loewensteinmedical.de>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
Xiongfeng Wang <xiongfeng.wang@linaro.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] IIO: st_accel_i2c.c: Use fallback if DT/ACPI enum failed
Date: Mon, 2 Jul 2018 14:05:51 +0100 [thread overview]
Message-ID: <20180702140551.00006297@huawei.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1807020843100.31768@fox.voss.local>
On Mon, 2 Jul 2018 08:53:00 +0200
Nikolaus Voss <nikolaus.voss@loewensteinmedical.de> wrote:
> On Sat, 30 Jun 2018, Jonathan Cameron wrote:
>
> > On Fri, 29 Jun 2018 10:10:10 +0200
> > Nikolaus Voss <nikolaus.voss@loewensteinmedical.de> wrote:
> >
> >> Currently, the driver bails out if not explicitly referred to in
> >> DT or ACPI tables. This prevents fallback mechanisms from coming
> >> into effect, e.g. I2C device ID table match via DT or ACPI
> >> PRP0001 HID. However DT/ACPI enum should take precedence over
> >> the fallback, so evaluate that first.
> >>
> >> Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
> >
> > Is the change to probe_new actually related to the rest of the change?
> >
> > I can't immediately see why... If not I would prefer that as a separate
> > change.
>
> Well, it is, because the id table pointer of the old probe() is not
> used any more.
Hmm. Fair enough, kind of incidental cleanup rather than anything more.
J
>
> >
> >> ---
> >> drivers/iio/accel/st_accel_i2c.c | 21 ++++++++++++---------
> >> 1 file changed, 12 insertions(+), 9 deletions(-)
> >>
> >> diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
> >> index 6bdec8c451e0..e360da407027 100644
> >> --- a/drivers/iio/accel/st_accel_i2c.c
> >> +++ b/drivers/iio/accel/st_accel_i2c.c
> >> @@ -138,8 +138,7 @@ static const struct i2c_device_id st_accel_id_table[] = {
> >> };
> >> MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
> >>
> >> -static int st_accel_i2c_probe(struct i2c_client *client,
> >> - const struct i2c_device_id *id)
> >> +static int st_accel_i2c_probe(struct i2c_client *client)
> >> {
> >> struct iio_dev *indio_dev;
> >> struct st_sensor_data *adata;
> >> @@ -156,14 +155,18 @@ static int st_accel_i2c_probe(struct i2c_client *client,
> >> client->name, sizeof(client->name));
> >> } else if (ACPI_HANDLE(&client->dev)) {
> >> ret = st_sensors_match_acpi_device(&client->dev);
> >> - if ((ret < 0) || (ret >= ST_ACCEL_MAX))
> >> - return -ENODEV;
> >> -
> >> - strlcpy(client->name, st_accel_id_table[ret].name,
> >> + if ((ret >= 0) && (ret < ST_ACCEL_MAX))
> >> + strlcpy(client->name, st_accel_id_table[ret].name,
> >> sizeof(client->name));
> >> - } else if (!id)
> >> - return -ENODEV;
> >> + }
> >>
> >> + /*
> >> + * If OF and ACPI enumeration failed, there could still be platform
> >> + * information via fallback enumeration or explicit instantiation, so
> >> + * check if id table has been matched via client->name.
> >> + */
> >> + if (!client->name)
> >> + return -ENODEV;
> >>
> >> st_sensors_i2c_configure(indio_dev, client, adata);
> >>
> >> @@ -187,7 +190,7 @@ static struct i2c_driver st_accel_driver = {
> >> .of_match_table = of_match_ptr(st_accel_of_match),
> >> .acpi_match_table = ACPI_PTR(st_accel_acpi_match),
> >> },
> >> - .probe = st_accel_i2c_probe,
> >> + .probe_new = st_accel_i2c_probe,
> >> .remove = st_accel_i2c_remove,
> >> .id_table = st_accel_id_table,
> >> };
> >
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-07-02 13:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-29 10:30 [PATCH 0/3] IIO: st_sensors_i2c: improve device enumeration Nikolaus Voss
2018-06-29 8:10 ` [PATCH 1/3] IIO: st_accel_i2c.c: Use fallback if DT/ACPI enum failed Nikolaus Voss
2018-06-30 15:28 ` Jonathan Cameron
2018-07-02 6:53 ` Nikolaus Voss
2018-07-02 13:05 ` Jonathan Cameron [this message]
2018-06-29 8:19 ` [PATCH 2/3] IIO: st_sensors_i2c.c: Don't print error on failed ACPI match Nikolaus Voss
2018-06-29 8:45 ` [PATCH 3/3] IIO: st_accel.h: sync DT and I2C device ID table strings Nikolaus Voss
2018-06-30 15:33 ` Jonathan Cameron
2018-07-02 7:32 ` Nikolaus Voss
2018-06-29 20:19 ` [PATCH 0/3] IIO: st_sensors_i2c: improve device enumeration Andy Shevchenko
2018-07-02 6:41 ` Nikolaus Voss
2018-07-02 16:14 ` Andy Shevchenko
2018-07-03 8:18 ` Nikolaus Voss
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=20180702140551.00006297@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=Nikolaus.Dr.Voss@loewensteinmedical.de \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.bianconi83@gmail.com \
--cc=nikolaus.voss@loewensteinmedical.de \
--cc=pmeerw@pmeerw.net \
--cc=xiongfeng.wang@linaro.org \
/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