From d1c969184b0b27c1517c19765f652ca3bc2a4c6a Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Wed, 8 Nov 2023 14:15:29 +0000 Subject: [PATCH] tegra_hv: Use const in class attributes APIs for Linux 6.4 and above The callback APIs of class attribute are updated on Linux6.4 and above to have the constant type pointer argument. Update the driver compatible with the updated APIs for Linux 6.4 and above. Bug 4370594 Change-Id: Ic06cb0d752797bb272f110aa0bb35bdd3afa1e6a Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3013107 (cherry picked from commit c8a83b569243c11720cd906296d6f153ab8d2cdb) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3059176 Tested-by: Jonathan Hunter Reviewed-by: Jonathan Hunter GVS: Gerrit_Virtual_Submit --- Makefile | 9 +++++++++ drivers/virt/tegra/tegra_hv.c | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index de4f6b10..ea06bf2c 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,15 @@ LINUXINCLUDE += -I$(srctree.nvidia-oot)/include subdir-ccflags-y += -Werror subdir-ccflags-y += -Wmissing-prototypes +LINUX_VERSION := $(shell expr $(VERSION) \* 256 + $(PATCHLEVEL)) +LINUX_VERSION_6_4 := $(shell expr 6 \* 256 + 4) + +# Changes done in Linux 6.4 onwards +ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_4); echo $$?),0) +# Argument on class attribute callback changed to constant type +subdir-ccflags-y += -DNV_CLASS_ATTRIBUTE_STRUCT_HAS_CONST_STRUCT_CLASS_ARG +endif + ifeq ($(CONFIG_TEGRA_VIRTUALIZATION),y) subdir-ccflags-y += -DCONFIG_TEGRA_VIRTUALIZATION endif diff --git a/drivers/virt/tegra/tegra_hv.c b/drivers/virt/tegra/tegra_hv.c index 3b85a97b..8210c371 100644 --- a/drivers/virt/tegra/tegra_hv.c +++ b/drivers/virt/tegra/tegra_hv.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ #include @@ -393,8 +393,13 @@ static void tegra_hv_cleanup(struct tegra_hv_data *hvd) } } +#if defined(NV_CLASS_ATTRIBUTE_STRUCT_HAS_CONST_STRUCT_CLASS_ARG) +static ssize_t vmid_show(const struct class *class, + const struct class_attribute *attr, char *buf) +#else static ssize_t vmid_show(struct class *class, struct class_attribute *attr, char *buf) +#endif { struct tegra_hv_data *hvd = get_hvd();