diff mbox series

[-next] iio: potentiometer: mcp4018: merge calls to of_match_device and of_device_get_match_data

Message ID 20180915105241.22584-1-yuehaibing@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] iio: potentiometer: mcp4018: merge calls to of_match_device and of_device_get_match_data | expand

Commit Message

YueHaibing Sept. 15, 2018, 10:52 a.m. UTC
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.

Found by coccinelle.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/iio/potentiometer/mcp4018.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Peter Rosin Sept. 15, 2018, 11:35 a.m. UTC | #1
On 2018-09-15 12:52, YueHaibing 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.
> 
> Found by coccinelle.
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Acked-by: Peter Rosin <peda@axentia.se>

Cheers,
Peter
Jonathan Cameron Sept. 16, 2018, 9:36 a.m. UTC | #2
On Sat, 15 Sep 2018 13:35:06 +0200
Peter Rosin <peda@axentia.se> wrote:

> On 2018-09-15 12:52, YueHaibing 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.
> > 
> > Found by coccinelle.
> > 
> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>  
> 
> Acked-by: Peter Rosin <peda@axentia.se>
Similar change already in place from Julia Lawall back in May but
looks like that just missed the last set for the merge window
after I managed to loose it and only picked up again when Peter
pointed it out in August.

However, something odd is going on as these are not currently in
next.

Ah, looks line staging-next was updated 2 days ago and last linux-next
is just before that.  So I'm afraid you hit some very unfortunate
timing or this would have been there when you were looking.

Thanks,

Jonathan

> 
> Cheers,
> Peter
Peter Rosin Sept. 16, 2018, 3:45 p.m. UTC | #3
On September 16, 2018 11:36:57 AM GMT+02:00, Jonathan Cameron <jic23@kernel.org> wrote:
>On Sat, 15 Sep 2018 13:35:06 +0200
>Peter Rosin <peda@axentia.se> wrote:
>
>> On 2018-09-15 12:52, YueHaibing 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.
>> > 
>> > Found by coccinelle.
>> > 
>> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>  
>> 
>> Acked-by: Peter Rosin <peda@axentia.se>
>Similar change already in place from Julia Lawall back in May but
>looks like that just missed the last set for the merge window
>after I managed to loose it and only picked up again when Peter
>pointed it out in August.
>
>However, something odd is going on as these are not currently in
>next.
>
>Ah, looks line staging-next was updated 2 days ago and last linux-next
>is just before that. 

Heh. I sure thought it looked familiar but assumed the old thing had hit next a long time ago and that this was something else...

Cheers,
Peter
diff mbox series

Patch

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;