From b2486188b56731b78c7726e5c8f1658360e3fa8a Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Mon, 17 Oct 2022 20:17:36 +0100 Subject: [PATCH] thermal: pex9749: Fix build for Linux v6.1 Upstream Linux commit f59ac19b7f44 ("thermal/of: Remove old OF code") removes the structure "thermal_zone_of_device_ops" and function devm_thermal_zone_of_sensor_register() which breaks building the pex9749 driver with Linux v6.1. Update the pex9749 driver as necessary to fix building with Linux v6.1. Bug 3831575 Change-Id: I88ed29142a7abab3f00e57f55d0a8b180a55779c Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2793518 GVS: Gerrit_Virtual_Submit Reviewed-by: Laxman Dewangan --- drivers/thermal/pex9749-thermal.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/thermal/pex9749-thermal.c b/drivers/thermal/pex9749-thermal.c index 40215874..c2080e87 100644 --- a/drivers/thermal/pex9749-thermal.c +++ b/drivers/thermal/pex9749-thermal.c @@ -5,6 +5,7 @@ #include #include #include +#include #define TS_ENABLE BIT(7) #define TS_DATA_VALID BIT(31) @@ -107,9 +108,15 @@ static int pex9749_calc_temp(u16 v) return temp; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) +static int pex9749_get_temp(struct thermal_zone_device *tz, int *temp) +{ + struct pex9749_priv *priv = tz->devdata; +#else static int pex9749_get_temp(void *data, int *temp) { struct pex9749_priv *priv = data; +#endif struct i2c_client *client = priv->client; u32 reg; int ret, retry = 3; @@ -149,7 +156,11 @@ out: return ret; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) +static struct thermal_zone_device_ops pex9749_ops = { +#else static struct thermal_zone_of_device_ops pex9749_ops = { +#endif .get_temp = pex9749_get_temp, }; @@ -190,7 +201,11 @@ static int pex9749_probe(struct i2c_client *client, const struct i2c_device_id * return -ENOMEM; priv->client = client; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) + priv->tzd = devm_thermal_of_zone_register(dev, PEX9749, priv, &pex9749_ops); +#else priv->tzd = devm_thermal_zone_of_sensor_register(dev, PEX9749, priv, &pex9749_ops); +#endif if (IS_ERR(priv->tzd)) return PTR_ERR(priv->tzd);