thermal: pex9749: Use conftest

Rather than using kernel version checks to determine which kernel APIs
to use, use the definitions generated by the conftest script which
determines which kernel APIs are present in the kernel.

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 4221847

Change-Id: I160c74224c582cc3b3a327544fc16b021226d54a
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2993808
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Jon Hunter
2023-10-09 13:13:12 +01:00
committed by mobile promotions
parent f6e070f87e
commit 86fece401a

View File

@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. // Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/thermal.h> #include <linux/thermal.h>
@@ -108,7 +110,7 @@ static int pex9749_calc_temp(u16 v)
return temp; return temp;
} }
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) #if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT)
static int pex9749_get_temp(struct thermal_zone_device *tz, int *temp) static int pex9749_get_temp(struct thermal_zone_device *tz, int *temp)
{ {
struct pex9749_priv *priv = tz->devdata; struct pex9749_priv *priv = tz->devdata;
@@ -156,7 +158,7 @@ out:
return ret; return ret;
} }
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) #if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT)
static struct thermal_zone_device_ops pex9749_ops = { static struct thermal_zone_device_ops pex9749_ops = {
#else #else
static struct thermal_zone_of_device_ops pex9749_ops = { static struct thermal_zone_of_device_ops pex9749_ops = {
@@ -205,7 +207,7 @@ static int pex9749_probe(struct i2c_client *client, const struct i2c_device_id *
return -ENOMEM; return -ENOMEM;
priv->client = client; priv->client = client;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) #if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT)
priv->tzd = devm_thermal_of_zone_register(dev, PEX9749, priv, &pex9749_ops); priv->tzd = devm_thermal_of_zone_register(dev, PEX9749, priv, &pex9749_ops);
#else #else
priv->tzd = devm_thermal_zone_of_sensor_register(dev, PEX9749, priv, &pex9749_ops); priv->tzd = devm_thermal_zone_of_sensor_register(dev, PEX9749, priv, &pex9749_ops);