Commit f1d8b504 authored by Daniel Lezcano's avatar Daniel Lezcano Committed by Daniel Lezcano

ata/drivers/ahci_imx: Switch to new of thermal API

The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.

sata_ahci_read_temperature() is used by sata_ahci_show_temp() also.

So in order to change the function prototype for the get_temp ops which
does not take a void* but a thermal_zone_device* structure, this
function wraps the call.
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linexp.org>
Acked-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Link: https://lore.kernel.org/r/20220804224349.1926752-26-daniel.lezcano@linexp.orgSigned-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent 2cf3c72a
...@@ -327,7 +327,7 @@ static int read_adc_sum(void *dev, u16 rtune_ctl_reg, void __iomem * mmio) ...@@ -327,7 +327,7 @@ static int read_adc_sum(void *dev, u16 rtune_ctl_reg, void __iomem * mmio)
} }
/* SATA AHCI temperature monitor */ /* SATA AHCI temperature monitor */
static int sata_ahci_read_temperature(void *dev, int *temp) static int __sata_ahci_read_temperature(void *dev, int *temp)
{ {
u16 mpll_test_reg, rtune_ctl_reg, dac_ctl_reg, read_sum; u16 mpll_test_reg, rtune_ctl_reg, dac_ctl_reg, read_sum;
u32 str1, str2, str3, str4; u32 str1, str2, str3, str4;
...@@ -416,6 +416,11 @@ static int sata_ahci_read_temperature(void *dev, int *temp) ...@@ -416,6 +416,11 @@ static int sata_ahci_read_temperature(void *dev, int *temp)
return 0; return 0;
} }
static int sata_ahci_read_temperature(struct thermal_zone_device *tz, int *temp)
{
return __sata_ahci_read_temperature(tz->devdata, temp);
}
static ssize_t sata_ahci_show_temp(struct device *dev, static ssize_t sata_ahci_show_temp(struct device *dev,
struct device_attribute *da, struct device_attribute *da,
char *buf) char *buf)
...@@ -423,14 +428,14 @@ static ssize_t sata_ahci_show_temp(struct device *dev, ...@@ -423,14 +428,14 @@ static ssize_t sata_ahci_show_temp(struct device *dev,
unsigned int temp = 0; unsigned int temp = 0;
int err; int err;
err = sata_ahci_read_temperature(dev, &temp); err = __sata_ahci_read_temperature(dev, &temp);
if (err < 0) if (err < 0)
return err; return err;
return sprintf(buf, "%u\n", temp); return sprintf(buf, "%u\n", temp);
} }
static const struct thermal_zone_of_device_ops fsl_sata_ahci_of_thermal_ops = { static const struct thermal_zone_device_ops fsl_sata_ahci_of_thermal_ops = {
.get_temp = sata_ahci_read_temperature, .get_temp = sata_ahci_read_temperature,
}; };
...@@ -1131,7 +1136,7 @@ static int imx_ahci_probe(struct platform_device *pdev) ...@@ -1131,7 +1136,7 @@ static int imx_ahci_probe(struct platform_device *pdev)
ret = PTR_ERR(hwmon_dev); ret = PTR_ERR(hwmon_dev);
goto disable_clk; goto disable_clk;
} }
devm_thermal_zone_of_sensor_register(hwmon_dev, 0, hwmon_dev, devm_thermal_of_zone_register(hwmon_dev, 0, hwmon_dev,
&fsl_sata_ahci_of_thermal_ops); &fsl_sata_ahci_of_thermal_ops);
dev_info(dev, "%s: sensor 'sata_ahci'\n", dev_name(hwmon_dev)); dev_info(dev, "%s: sensor 'sata_ahci'\n", dev_name(hwmon_dev));
} }
......
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