From 65900a51a9fa500516c781f1393f8b52a32eb112 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Tue, 21 May 2024 15:52:18 +0100 Subject: [PATCH] media: virtual-i2c-mux: Fix build for Linux v6.10 In Linux v6.10, the 'class' argument was removed from the i2c_mux_add_adapter() function. Add a test to conftest to detect the correct number of arguments for i2c_mux_add_adapter() and update the virtual-i2c-mux driver accordingly to fix the build for Linux v6.10. Bug 4593750 Change-Id: I7333a511b487b7c2f2fa0ce7c34f2df5f061fbe4 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3142398 (cherry picked from commit 5e0562c90d119ffbea1d8511f588c7aaa57fee08) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3142376 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/media/i2c/virtual_i2c_mux.c | 8 ++++++-- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/virtual_i2c_mux.c b/drivers/media/i2c/virtual_i2c_mux.c index e85d3337..8e461108 100644 --- a/drivers/media/i2c/virtual_i2c_mux.c +++ b/drivers/media/i2c/virtual_i2c_mux.c @@ -1,5 +1,5 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All Rights Reserved. */ +// SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. /* * virtual_i2c_mux.c - virtual i2c mux driver for P3762 & P3783 GMSL boards. */ @@ -87,7 +87,11 @@ static int virtual_i2c_mux_probe(struct i2c_client *client, for (chan = 0; chan < children; chan++) { pr_info("%s: chan = %d\n",__func__, chan); +#if defined(NV_I2C_MUX_ADD_ADAPTER_HAS_NO_CLASS_ARG) + ret = i2c_mux_add_adapter(muxc, 0, chan); +#else ret = i2c_mux_add_adapter(muxc, 0, chan, 0); +#endif if (ret) goto err_children; } diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index cfee0789..3dabb976 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -128,6 +128,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_new_client_device NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_driver_struct_probe_without_i2c_device_id_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_driver_struct_has_probe_new NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_driver_struct_remove_return_type_int +NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_mux_add_adapter_has_no_class_argument NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += kthread_complete_and_exit diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 68d94792..950e7300 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -5467,6 +5467,23 @@ compile_test() { compile_check_conftest "$CODE" "NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT" "" "types" ;; + i2c_mux_add_adapter_has_no_class_argument) + # + # Determine if the i2c_mux_add_adapter() has no class argument. + # + # Commit fec1982d7072 ("i2c: mux: Remove class argument from i2c_mux_add_adapter()") + # removed the 'class' argument from i2c_mux_add_adapter() in Linux v6.10. + # + CODE=" + #define _LINUX_EFI_H + #include + int conftest_i2c_mux_add_adapter_has_no_class_argument(struct i2c_mux_core *muxc) { + return i2c_mux_add_adapter(muxc, 0, 0); + }" + + compile_check_conftest "$CODE" "NV_I2C_MUX_ADD_ADAPTER_HAS_NO_CLASS_ARG" "" "types" + ;; + of_get_named_gpio) # # Determine if of_get_named_gpio() function is present