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 <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/2991966
(cherry picked from commit 4b2fd8250d)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/2995574
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Jon Hunter
2023-09-08 12:41:26 +01:00
committed by mobile promotions
parent 9890cbf901
commit 5be46c6927

View File

@@ -14,6 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <nvidia/conftest.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/module.h>
@@ -51,10 +53,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) {