summaryrefslogtreecommitdiff
path: root/drivers/hwmon/scmi-hwmon.c
AgeCommit message (Collapse)Author
2021-03-30hwmon: (scmi) port driver to the new scmi_sensor_proto_ops interfaceCristian Marussi
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>
2020-11-22hwmon: (scmi) Update hwmon internal scale data typeCristian Marussi
Use an int to calculate scale values inside scmi_hwmon_scale() to match the updated scale data type in struct scmi_sensor_info. Link: https://lore.kernel.org/r/20201119174906.43862-4-cristian.marussi@arm.com Cc: linux-hwmon@vger.kernel.org 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>
2020-09-23hwmon: (scmi-hwmon) Avoid comma separated statementsJoe Perches
Use semicolons and braces. Signed-off-by: Joe Perches <joe@perches.com> Link: https://lore.kernel.org/r/5e1ca60df261e3bfd0e6510e388581a1d1f52c77.1598331149.git.joe@perches.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-07-15hwmon: (scmi) Fix potential buffer overflow in scmi_hwmon_probe()Cristian Marussi
SMATCH detected a potential buffer overflow in the manipulation of hwmon_attributes array inside the scmi_hwmon_probe function: drivers/hwmon/scmi-hwmon.c:226 scmi_hwmon_probe() error: buffer overflow 'hwmon_attributes' 6 <= 9 Fix it by statically declaring the size of the array as the maximum possible as defined by hwmon_max define. Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Link: https://lore.kernel.org/r/20200715121338.GA18761@e119603-lin.cambridge.arm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-12-24hwmon: (scmi-hwmon) Match scmi device by both name and protocol idSudeep Holla
The scmi bus now has support to match the driver with devices not only based on their protocol id but also based on their device name if one is available. This was added to cater the need to support multiple devices and drivers for the same protocol. Let us add the name "hwmon" to scmi_device_id table in the driver so that in matches only with device with the same name and protocol id SCMI_PROTOCOL_SENSOR. This is just for sake of completion and must not be used to add IIO support in parallel. Instead, if IIO support is added ever in future, we need to drop this hwmon driver entirely and use the iio->hwmon bridge to access the sensors as hwmon devices if needed. Cc: linux-hwmon@vger.kernel.org Acked-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2019-08-12firmware: arm_scmi: Drop async flag in sensor_ops->reading_getSudeep Holla
SENSOR_DESCRIPTION_GET provides attributes to indicate if the sensor supports asynchronous read. Ideally we should be able to read that flag and use asynchronous reads for any sensors with that attribute set. In order to add that support, let's drop the async flag passed to sensor_ops->reading_get and dynamically switch between sync and async flags based on the attributes as provided by the firmware. Cc: linux-hwmon@vger.kernel.org Acked-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2019-06-12hwmon: scmi: Scale values to target desired HWMON unitsFlorian Fainelli
If the SCMI firmware implementation is reporting values in a scale that is different from the HWMON units, we need to scale up or down the value according to how far apart they are. Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> [sudeep.holla: added check of scale = 0 for early exit in scmi_hwmon_scale] Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2019-02-18hwmon: (scmi-hwmon) Replace S_<PERMS> with octal valuesGuenter Roeck
Replace S_<PERMS> with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-10-10hwmon: (scmi) Remove redundant pointer checkNathan Chancellor
Clang warns when the address of a pointer is used in a boolean context as it will always return true. drivers/hwmon/scmi-hwmon.c:59:24: warning: address of array 'sensor->name' will always evaluate to 'true' [-Wpointer-bool-conversion] if (sensor && sensor->name) ~~ ~~~~~~~~^~~~ 1 warning generated. Remove the check as it isn't doing anything currently; if validation of the contents of the data structure was intended by the original author (since this line has been present from the first version of this driver), it can be added in a follow-up patch. Reported-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-04-22hwmon: (scmi) handle absence of few types of sensorsSudeep Holla
Currently the loop checks for non-zero count of sensors for each type of sensors which is completely wrong. It also results in aborting the registration of sensors if one or more types of sensors are completely not supported by the platform SCMI firmware. This patch fixes the issue by continue to loop and skiping sensor types that are not present. Fixes: b23688aefb8b ("hwmon: add support for sensors exported via ARM SCMI") Reported-by: Jim Quinlan <james.quinlan@broadcom.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: linux-hwmon@vger.kernel.org Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-03-20hwmon: (scmi) return -EINVAL when sensor information is unavailableSudeep Holla
Passing NULL pointer to PTR_ERR will result in return value of 0 indicating success which is clearly not what it is intended here. This patch returns -EINVAL instead when the sensor information is not available. Fixes: b23688aefb8b ("hwmon: add support for sensors exported via ARM SCMI") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Guenter Roeck <linux@roeck-us.net> Cc: linux-hwmon@vger.kernel.org Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2018-02-28hwmon: add support for sensors exported via ARM SCMISudeep Holla
Create a driver to add support for SoC sensors exported by the System Control Processor (SCP) via the System Control and Management Interface (SCMI). The supported sensor types is one of voltage, temperature, current, and power. The sensor labels and values provided by the SCP are exported via the hwmon sysfs interface. Cc: linux-hwmon@vger.kernel.org Acked-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>