Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (scmi) port driver to the new scmi_sensor_proto_ops interface

Port the scmi hwmon driver to the new SCMI sensor interface based on
protocol handles and common devm_get_ops().

Link: https://lore.kernel.org/r/20210316124903.35011-25-cristian.marussi@arm.com
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Jean Delvare <jdelvare@suse.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

authored by

Cristian Marussi and committed by
Sudeep Holla
987bae41 9694a7f6

+15 -9
+15 -9
drivers/hwmon/scmi-hwmon.c
··· 2 2 /* 3 3 * System Control and Management Interface(SCMI) based hwmon sensor driver 4 4 * 5 - * Copyright (C) 2018 ARM Ltd. 5 + * Copyright (C) 2018-2021 ARM Ltd. 6 6 * Sudeep Holla <sudeep.holla@arm.com> 7 7 */ 8 8 ··· 13 13 #include <linux/sysfs.h> 14 14 #include <linux/thermal.h> 15 15 16 + static const struct scmi_sensor_proto_ops *sensor_ops; 17 + 16 18 struct scmi_sensors { 17 - const struct scmi_handle *handle; 19 + const struct scmi_protocol_handle *ph; 18 20 const struct scmi_sensor_info **info[hwmon_max]; 19 21 }; 20 22 ··· 71 69 u64 value; 72 70 const struct scmi_sensor_info *sensor; 73 71 struct scmi_sensors *scmi_sensors = dev_get_drvdata(dev); 74 - const struct scmi_handle *h = scmi_sensors->handle; 75 72 76 73 sensor = *(scmi_sensors->info[type] + channel); 77 - ret = h->sensor_ops->reading_get(h, sensor->id, &value); 74 + ret = sensor_ops->reading_get(scmi_sensors->ph, sensor->id, &value); 78 75 if (ret) 79 76 return ret; 80 77 ··· 170 169 struct hwmon_channel_info *scmi_hwmon_chan; 171 170 const struct hwmon_channel_info **ptr_scmi_ci; 172 171 const struct scmi_handle *handle = sdev->handle; 172 + struct scmi_protocol_handle *ph; 173 173 174 - if (!handle || !handle->sensor_ops) 174 + if (!handle) 175 175 return -ENODEV; 176 176 177 - nr_sensors = handle->sensor_ops->count_get(handle); 177 + sensor_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_SENSOR, &ph); 178 + if (IS_ERR(sensor_ops)) 179 + return PTR_ERR(sensor_ops); 180 + 181 + nr_sensors = sensor_ops->count_get(ph); 178 182 if (!nr_sensors) 179 183 return -EIO; 180 184 ··· 187 181 if (!scmi_sensors) 188 182 return -ENOMEM; 189 183 190 - scmi_sensors->handle = handle; 184 + scmi_sensors->ph = ph; 191 185 192 186 for (i = 0; i < nr_sensors; i++) { 193 - sensor = handle->sensor_ops->info_get(handle, i); 187 + sensor = sensor_ops->info_get(ph, i); 194 188 if (!sensor) 195 189 return -EINVAL; 196 190 ··· 242 236 } 243 237 244 238 for (i = nr_sensors - 1; i >= 0 ; i--) { 245 - sensor = handle->sensor_ops->info_get(handle, i); 239 + sensor = sensor_ops->info_get(ph, i); 246 240 if (!sensor) 247 241 continue; 248 242