Commit 53b17607 authored by Vaibhav Gupta's avatar Vaibhav Gupta

fixup! software: kernel: Use HWMON API to expose Temperature

parent 269e67b2
......@@ -3,6 +3,8 @@
/*
* Author: Vaibhav Gupta <vaibhav.gupta@cern.ch>
*
* Hardware Monitoring for fa-dev
*/
#include <linux/hwmon.h>
......@@ -27,29 +29,13 @@ static int fa_hwmon_temp_read(struct device *dev, enum hwmon_sensor_types type,
return 0;
}
static char *fa_hwmon_temp_sensor_id;
static int fa_hwmon_temp_sensor_id_read(struct device *dev,
enum hwmon_sensor_types type,
u32 attr, int channel, const char **str)
{
int size;
char device_type[] = "Temperature - FMC ADC 100M14B4C - ";
struct fa_dev *fa = dev_get_drvdata(dev);
size = strlen(dev_name(&fa->slot->dev));
size += strlen(device_type);
size++;
fa_hwmon_temp_sensor_id = kzalloc(size, GFP_KERNEL);
if(!fa_hwmon_temp_sensor_id)
return -ENOMEM;
snprintf(fa_hwmon_temp_sensor_id, size, "%s%s",
device_type, dev_name(&fa->slot->dev));
*str = fa_hwmon_temp_sensor_id;
*str = fa->hwmon_temp_sensor_id;
return 0;
}
......@@ -72,13 +58,34 @@ static const struct hwmon_chip_info fa_hwmon_temp_chip_info = {
int fa_hwmon_init(struct fa_dev *fa)
{
int size;
char device_type[] = "Temperature - FMC ADC 100M14B4C - ";
struct device *dev = &fa->pdev->dev;
fa->hwmon_dev = devm_hwmon_device_register_with_info(dev,
"fa_temperature",
fa,
&fa_hwmon_temp_chip_info,
NULL);
return PTR_ERR_OR_ZERO(fa->hwmon_dev);
if(!IS_ERR(fa->hwmon_dev)) {
size = strlen(dev_name(&fa->slot->dev));
size += strlen(device_type);
size++;
fa->hwmon_temp_sensor_id = devm_kzalloc(fa->hwmon_dev,
size, GFP_KERNEL);
if(!fa->hwmon_temp_sensor_id) {
devm_hwmon_device_unregister(dev);
return -ENOMEM;
}
snprintf(fa->hwmon_temp_sensor_id, size, "%s%s",
device_type, dev_name(&fa->slot->dev));
return 0;
}
return PTR_ERR(fa->hwmon_dev);
}
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0) */
......@@ -345,9 +345,12 @@ struct fa_dev {
/* one-wire */
uint8_t ds18_id[8];
unsigned long next_t;
struct device *hwmon_dev;
int temp; /* temperature: scaled by 4 bits */
/* HWMON */
char *hwmon_temp_sensor_id;
struct device *hwmon_dev;
/* Calibration Data */
struct fa_calib calib;
int32_t range[FA100M14B4C_NCHAN];
......
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