Commit fd6ca3f5 authored by Minghao Chi's avatar Minghao Chi Committed by Guenter Roeck

hwmon: (scpi-hwmon): Use of_device_get_match_data()

Use of_device_get_match_data() to simplify the code.
Reported-by: default avatarZeal Robot <zealci@zte.com.cn>
Signed-off-by: default avatarMinghao Chi <chi.minghao@zte.com.cn>
Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
Link: https://lore.kernel.org/r/20220315023412.2118415-1-chi.minghao@zte.com.cnSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 5d4a2ea9
...@@ -141,7 +141,6 @@ static int scpi_hwmon_probe(struct platform_device *pdev) ...@@ -141,7 +141,6 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
struct scpi_ops *scpi_ops; struct scpi_ops *scpi_ops;
struct device *hwdev, *dev = &pdev->dev; struct device *hwdev, *dev = &pdev->dev;
struct scpi_sensors *scpi_sensors; struct scpi_sensors *scpi_sensors;
const struct of_device_id *of_id;
int idx, ret; int idx, ret;
scpi_ops = get_scpi_ops(); scpi_ops = get_scpi_ops();
...@@ -171,12 +170,11 @@ static int scpi_hwmon_probe(struct platform_device *pdev) ...@@ -171,12 +170,11 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
scpi_sensors->scpi_ops = scpi_ops; scpi_sensors->scpi_ops = scpi_ops;
of_id = of_match_device(scpi_of_match, &pdev->dev); scale = of_device_get_match_data(&pdev->dev);
if (!of_id) { if (!scale) {
dev_err(&pdev->dev, "Unable to initialize scpi-hwmon data\n"); dev_err(&pdev->dev, "Unable to initialize scpi-hwmon data\n");
return -ENODEV; return -ENODEV;
} }
scale = of_id->data;
for (i = 0, idx = 0; i < nr_sensors; i++) { for (i = 0, idx = 0; i < nr_sensors; i++) {
struct sensor_data *sensor = &scpi_sensors->data[idx]; struct sensor_data *sensor = &scpi_sensors->data[idx];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment