summaryrefslogtreecommitdiff
path: root/drivers/iio/potentiometer/mcp4531.c
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2018-05-21 12:49:10 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-08-19 22:16:39 +0300
commitce7c637a8368d0293649a4acc0b89930295cb62a (patch)
treec77397ced609bd7f428bf0cd1c2216a1c2174c50 /drivers/iio/potentiometer/mcp4531.c
parent892e62fab4983656d3ca5df4e83fdf2b496c06e4 (diff)
downloadlinux-ce7c637a8368d0293649a4acc0b89930295cb62a.tar.xz
iio: potentiometer: merge calls to of_match_device and of_device_get_match_data
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> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/potentiometer/mcp4531.c')
-rw-r--r--drivers/iio/potentiometer/mcp4531.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/iio/potentiometer/mcp4531.c b/drivers/iio/potentiometer/mcp4531.c
index df894af6cccb..d87ca85645db 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;