From: Jonathan Cameron <jic23@kernel.org>
To: Peter Rosin <peda@axentia.se>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>,
Hartmut Knaack <knaack.h@gmx.de>,
Himanshu Jha <himanshujha199640@gmail.com>
Subject: Re: [PATCH 3/3] iio: potentiometer: merge calls to of_match_device and of_device_get_match_data
Date: Sun, 19 Aug 2018 20:17:52 +0100 [thread overview]
Message-ID: <20180819201752.2280be76@archlinux> (raw)
In-Reply-To: <0a8aff9e-51fe-96a5-bcab-cc472be92dcc@axentia.se>
On Sun, 19 Aug 2018 09:02:42 +0200
Peter Rosin <peda@axentia.se> wrote:
> On 2018-05-21 11:49, Julia Lawall wrote:
> > Drop call to of_match_device, which is subsumed by the subsequent
> > call to of_device_get_match_data. The code becomes simpler, and a
> > temporary variable can be dropped.
> >
> > The semantic match that makes this change is as follows:
> > (http://coccinelle.lip6.fr/)
> >
> > // <smpl>
> > @r@
> > local idexpression match;
> > identifier i;
> > expression x, dev, e, e1;
> > @@
> > - match@i = of_match_device(x, dev);
> > - if (match) e = of_device_get_match_data(dev);
> > - else e = e1;
> > + e = of_device_get_match_data(dev);
> > + if (!e) e = e1;
> >
> > @@
> > identifier r.i;
> > @@
> > - const struct of_device_id *i;
> > ... when != i
> > // </smpl>
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Reviewed-by: Peter Rosin <peda@axentia.se>
Applied to the togreg branch of iio.git.
Glad you replied to this one Peter, it had definitely dropped through the cracks.
Jonathan
>
> Cheers,
> Peter
>
> >
> > ---
> > drivers/iio/potentiometer/max5481.c | 7 ++-----
> > drivers/iio/potentiometer/mcp4018.c | 7 ++-----
> > drivers/iio/potentiometer/mcp4531.c | 7 ++-----
> > 3 files changed, 6 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/iio/potentiometer/mcp4018.c b/drivers/iio/potentiometer/mcp4018.c
> > index 320a7c9..c051ee0 100644
> > --- a/drivers/iio/potentiometer/mcp4018.c
> > +++ b/drivers/iio/potentiometer/mcp4018.c
> > @@ -147,7 +147,6 @@ static int mcp4018_probe(struct i2c_client *client)
> > struct device *dev = &client->dev;
> > struct mcp4018_data *data;
> > struct iio_dev *indio_dev;
> > - const struct of_device_id *match;
> >
> > if (!i2c_check_functionality(client->adapter,
> > I2C_FUNC_SMBUS_BYTE)) {
> > @@ -162,10 +161,8 @@ static int mcp4018_probe(struct i2c_client *client)
> > i2c_set_clientdata(client, indio_dev);
> > data->client = client;
> >
> > - match = of_match_device(of_match_ptr(mcp4018_of_match), dev);
> > - if (match)
> > - data->cfg = of_device_get_match_data(dev);
> > - else
> > + data->cfg = of_device_get_match_data(dev);
> > + if (!data->cfg)
> > data->cfg = &mcp4018_cfg[i2c_match_id(mcp4018_id, client)->driver_data];
> >
> > indio_dev->dev.parent = dev;
> > diff --git a/drivers/iio/potentiometer/mcp4531.c b/drivers/iio/potentiometer/mcp4531.c
> > index df894af..d87ca85 100644
> > --- a/drivers/iio/potentiometer/mcp4531.c
> > +++ b/drivers/iio/potentiometer/mcp4531.c
> > @@ -360,7 +360,6 @@ static int mcp4531_probe(struct i2c_client *client)
> > struct device *dev = &client->dev;
> > struct mcp4531_data *data;
> > struct iio_dev *indio_dev;
> > - const struct of_device_id *match;
> >
> > if (!i2c_check_functionality(client->adapter,
> > I2C_FUNC_SMBUS_WORD_DATA)) {
> > @@ -375,10 +374,8 @@ static int mcp4531_probe(struct i2c_client *client)
> > i2c_set_clientdata(client, indio_dev);
> > data->client = client;
> >
> > - match = of_match_device(of_match_ptr(mcp4531_of_match), dev);
> > - if (match)
> > - data->cfg = of_device_get_match_data(dev);
> > - else
> > + data->cfg = of_device_get_match_data(dev);
> > + if (!data->cfg)
> > data->cfg = &mcp4531_cfg[i2c_match_id(mcp4531_id, client)->driver_data];
> >
> > indio_dev->dev.parent = dev;
> > diff --git a/drivers/iio/potentiometer/max5481.c b/drivers/iio/potentiometer/max5481.c
> > index ffe2761..6d2f13f 100644
> > --- a/drivers/iio/potentiometer/max5481.c
> > +++ b/drivers/iio/potentiometer/max5481.c
> > @@ -137,7 +137,6 @@ static int max5481_probe(struct spi_device *spi)
> > struct iio_dev *indio_dev;
> > struct max5481_data *data;
> > const struct spi_device_id *id = spi_get_device_id(spi);
> > - const struct of_device_id *match;
> > int ret;
> >
> > indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*data));
> > @@ -149,10 +148,8 @@ static int max5481_probe(struct spi_device *spi)
> >
> > data->spi = spi;
> >
> > - match = of_match_device(of_match_ptr(max5481_match), &spi->dev);
> > - if (match)
> > - data->cfg = of_device_get_match_data(&spi->dev);
> > - else
> > + data->cfg = of_device_get_match_data(&spi->dev);
> > + if (!data->cfg)
> > data->cfg = &max5481_cfg[id->driver_data];
> >
> > indio_dev->name = id->name;
> >
>
prev parent reply other threads:[~2018-08-19 22:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 9:49 [PATCH 0/3] merge calls to of_match_device and of_device_get_match_data Julia Lawall
2018-05-21 9:49 ` [PATCH 3/3] iio: potentiometer: " Julia Lawall
2018-08-19 7:02 ` Peter Rosin
2018-08-19 19:17 ` Jonathan Cameron [this message]
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=20180819201752.2280be76@archlinux \
--to=jic23@kernel.org \
--cc=Julia.Lawall@lip6.fr \
--cc=himanshujha199640@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=pmeerw@pmeerw.net \
/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).