hwmon: (scpi-hwmon): Use of_device_get_match_data()
authorMinghao Chi <chi.minghao@zte.com.cn>
Tue, 15 Mar 2022 02:34:12 +0000 (02:34 +0000)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 15 Mar 2022 23:30:56 +0000 (16:30 -0700)
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>
Link: https://lore.kernel.org/r/20220315023412.2118415-1-chi.minghao@zte.com.cn
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/scpi-hwmon.c

index 919877970ae3b1c342b7a37ce7da2ffac1c45204..5187c6dd5a4f0400f990011f10e342ea16e4f73c 100644 (file)
@@ -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];