public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] iio: potentiometer: max5481: merge calls to of_match_device and of_device_get_match_data
@ 2018-09-15 10:50 YueHaibing
  2018-09-16  9:46 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2018-09-15 10:50 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw; +Cc: linux-kernel, linux-iio, YueHaibing

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/max5481.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

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;
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] iio: potentiometer: max5481: merge calls to of_match_device and of_device_get_match_data
  2018-09-15 10:50 [PATCH -next] iio: potentiometer: max5481: merge calls to of_match_device and of_device_get_match_data YueHaibing
@ 2018-09-16  9:46 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2018-09-16  9:46 UTC (permalink / raw)
  To: YueHaibing; +Cc: knaack.h, lars, pmeerw, linux-kernel, linux-iio

On Sat, 15 Sep 2018 18:50:33 +0800
YueHaibing <yuehaibing@huawei.com> 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>
Sorry, another one that was waiting in my queue and only just went
towards linux-next - so will be there tomorrow.

Jonathan
> ---
>  drivers/iio/potentiometer/max5481.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> 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;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-16  9:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-15 10:50 [PATCH -next] iio: potentiometer: max5481: merge calls to of_match_device and of_device_get_match_data YueHaibing
2018-09-16  9:46 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox