From 4b2fd8250d3827316f696208dc3e45f28d6c36a6 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Fri, 8 Sep 2023 12:41:26 +0100 Subject: [PATCH] tegra: hwpm: Use conftest for 'struct class' changes In Linux v6.2, the 'struct class.devnode()' function was updated to take a 'const struct device *' instead of a 'struct device *'. A test has been added to the conftest script to check for this and so instead of relying on kernel version, use the definition generated by conftest to select the appropriate function to use. This is beneficial for working with 3rd party Linux kernels that may have back-ported upstream changes into their kernel and so the kernel version checks do not work. Bug 4119327 Change-Id: I751b7401adee7b337192e255253b974cbd803642 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/2991966 Reviewed-by: Vedashree Vidwans GVS: Gerrit_Virtual_Submit --- drivers/tegra/hwpm/os/linux/driver.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/tegra/hwpm/os/linux/driver.c b/drivers/tegra/hwpm/os/linux/driver.c index ac9c36d..0d29e7b 100644 --- a/drivers/tegra/hwpm/os/linux/driver.c +++ b/drivers/tegra/hwpm/os/linux/driver.c @@ -14,6 +14,8 @@ * along with this program. If not, see . */ +#include + #include #include #include @@ -50,10 +52,10 @@ static const struct of_device_id tegra_soc_hwpm_of_match[] = { }; MODULE_DEVICE_TABLE(of, tegra_soc_hwpm_of_match); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0)) -static char *tegra_hwpm_get_devnode(struct device *dev, umode_t *mode) -#else +#if defined(NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG) static char *tegra_hwpm_get_devnode(const struct device *dev, umode_t *mode) +#else +static char *tegra_hwpm_get_devnode(struct device *dev, umode_t *mode) #endif { if (!mode) {