iio: potentiometer: merge calls to of_match_device and of_device_get_match_data
authorJulia Lawall <Julia.Lawall@lip6.fr>
Mon, 21 May 2018 09:49:10 +0000 (11:49 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 19 Aug 2018 19:16:39 +0000 (20:16 +0100)
commitce7c637a8368d0293649a4acc0b89930295cb62a
treec77397ced609bd7f428bf0cd1c2216a1c2174c50
parent892e62fab4983656d3ca5df4e83fdf2b496c06e4
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>
drivers/iio/potentiometer/max5481.c
drivers/iio/potentiometer/mcp4018.c
drivers/iio/potentiometer/mcp4531.c