linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (scpi-hwmon): Use of_device_get_match_data()
@ 2022-03-15  2:34 cgel.zte
  2022-03-15 16:18 ` Jean Delvare
  2022-03-15 23:31 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: cgel.zte @ 2022-03-15  2:34 UTC (permalink / raw)
  To: jdelvare; +Cc: linux, linux-hwmon, linux-kernel, Minghao Chi, Zeal Robot

From: Minghao Chi <chi.minghao@zte.com.cn>

Use of_device_get_match_data() to simplify the code.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
---
 drivers/hwmon/scpi-hwmon.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c
index 919877970ae3..5187c6dd5a4f 100644
--- a/drivers/hwmon/scpi-hwmon.c
+++ b/drivers/hwmon/scpi-hwmon.c
@@ -141,7 +141,6 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
 	struct scpi_ops *scpi_ops;
 	struct device *hwdev, *dev = &pdev->dev;
 	struct scpi_sensors *scpi_sensors;
-	const struct of_device_id *of_id;
 	int idx, ret;
 
 	scpi_ops = get_scpi_ops();
@@ -171,12 +170,11 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
 
 	scpi_sensors->scpi_ops = scpi_ops;
 
-	of_id = of_match_device(scpi_of_match, &pdev->dev);
-	if (!of_id) {
+	scale = of_device_get_match_data(&pdev->dev);
+	if (!scale) {
 		dev_err(&pdev->dev, "Unable to initialize scpi-hwmon data\n");
 		return -ENODEV;
 	}
-	scale = of_id->data;
 
 	for (i = 0, idx = 0; i < nr_sensors; i++) {
 		struct sensor_data *sensor = &scpi_sensors->data[idx];
-- 
2.25.1


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

* Re: [PATCH] hwmon: (scpi-hwmon): Use of_device_get_match_data()
  2022-03-15  2:34 [PATCH] hwmon: (scpi-hwmon): Use of_device_get_match_data() cgel.zte
@ 2022-03-15 16:18 ` Jean Delvare
  2022-03-15 23:31 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Jean Delvare @ 2022-03-15 16:18 UTC (permalink / raw)
  To: cgel.zte; +Cc: linux, linux-hwmon, linux-kernel, Minghao Chi, Zeal Robot

On Tue, 15 Mar 2022 02:34:12 +0000, cgel.zte@gmail.com wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
> 
> Use of_device_get_match_data() to simplify the code.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
> ---
>  drivers/hwmon/scpi-hwmon.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c
> index 919877970ae3..5187c6dd5a4f 100644
> --- a/drivers/hwmon/scpi-hwmon.c
> +++ b/drivers/hwmon/scpi-hwmon.c
> @@ -141,7 +141,6 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
>  	struct scpi_ops *scpi_ops;
>  	struct device *hwdev, *dev = &pdev->dev;
>  	struct scpi_sensors *scpi_sensors;
> -	const struct of_device_id *of_id;
>  	int idx, ret;
>  
>  	scpi_ops = get_scpi_ops();
> @@ -171,12 +170,11 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
>  
>  	scpi_sensors->scpi_ops = scpi_ops;
>  
> -	of_id = of_match_device(scpi_of_match, &pdev->dev);
> -	if (!of_id) {
> +	scale = of_device_get_match_data(&pdev->dev);
> +	if (!scale) {
>  		dev_err(&pdev->dev, "Unable to initialize scpi-hwmon data\n");
>  		return -ENODEV;
>  	}
> -	scale = of_id->data;
>  
>  	for (i = 0, idx = 0; i < nr_sensors; i++) {
>  		struct sensor_data *sensor = &scpi_sensors->data[idx];

Reviewed-by: Jean Delvare <jdelvare@suse.de>

-- 
Jean Delvare
SUSE L3 Support

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

* Re: [PATCH] hwmon: (scpi-hwmon): Use of_device_get_match_data()
  2022-03-15  2:34 [PATCH] hwmon: (scpi-hwmon): Use of_device_get_match_data() cgel.zte
  2022-03-15 16:18 ` Jean Delvare
@ 2022-03-15 23:31 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2022-03-15 23:31 UTC (permalink / raw)
  To: cgel.zte; +Cc: jdelvare, linux-hwmon, linux-kernel, Minghao Chi, Zeal Robot

On Tue, Mar 15, 2022 at 02:34:12AM +0000, cgel.zte@gmail.com wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
> 
> Use of_device_get_match_data() to simplify the code.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
> Reviewed-by: Jean Delvare <jdelvare@suse.de>

Applied to hwmon-next.

Thanks,
Guenter

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

end of thread, other threads:[~2022-03-15 23:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15  2:34 [PATCH] hwmon: (scpi-hwmon): Use of_device_get_match_data() cgel.zte
2022-03-15 16:18 ` Jean Delvare
2022-03-15 23:31 ` Guenter Roeck

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).