From e351ba75c78d0810faec1d4e505992ca34cf7e33 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Tue, 9 Apr 2024 11:56:40 +0100 Subject: [PATCH] media: camera: Ensure gpio_device_get_chip is present In Linux v6.7, both gpio_device_find() and gpio_device_get_chip() were added. However, don't assume that if one is present then so is the other and so add a test to check if gpio_device_get_chip() is also present. Bug 4471899 Change-Id: I0c547a52b0f397aef43884ab76d815573e8ed3f8 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3112133 (cherry picked from commit 9458d6b97ff4eb3b9aa61c5a12119a704bfe2b44) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3119068 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/media/platform/tegra/cdi/cdi_gpio.c | 6 ++++-- drivers/media/platform/tegra/isc/isc_gpio.c | 6 ++++-- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/tegra/cdi/cdi_gpio.c b/drivers/media/platform/tegra/cdi/cdi_gpio.c index 4f4d9caa..6f3959ea 100644 --- a/drivers/media/platform/tegra/cdi/cdi_gpio.c +++ b/drivers/media/platform/tegra/cdi/cdi_gpio.c @@ -46,7 +46,8 @@ static struct gpio_chip *cdi_gpio_get_chip(struct platform_device *pdev, struct cdi_gpio_plat_data *pd) { struct gpio_chip *gc = NULL; -#if defined(NV_GPIO_DEVICE_FIND_PRESENT) /* Linux 6.7 */ +#if defined(NV_GPIO_DEVICE_FIND_PRESENT) && \ + defined(NV_GPIO_DEVICE_GET_CHIP_PRESENT) /* Linux 6.7 */ struct gpio_device *gdev; #endif char name[MAX_STR_SIZE]; @@ -58,7 +59,8 @@ static struct gpio_chip *cdi_gpio_get_chip(struct platform_device *pdev, } strcpy(name, pd->gpio_prnt_chip); -#if defined(NV_GPIO_DEVICE_FIND_PRESENT) /* Linux 6.7 */ +#if defined(NV_GPIO_DEVICE_FIND_PRESENT) && \ + defined(NV_GPIO_DEVICE_GET_CHIP_PRESENT) /* Linux 6.7 */ gdev = gpio_device_find(name, cdi_gpio_chip_match); if (gdev) { gc = gpio_device_get_chip(gdev); diff --git a/drivers/media/platform/tegra/isc/isc_gpio.c b/drivers/media/platform/tegra/isc/isc_gpio.c index d84c434a..c1eca456 100644 --- a/drivers/media/platform/tegra/isc/isc_gpio.c +++ b/drivers/media/platform/tegra/isc/isc_gpio.c @@ -47,7 +47,8 @@ static struct gpio_chip *isc_gpio_get_chip(struct platform_device *pdev, { struct gpio_chip *gc = NULL; char name[MAX_STR_SIZE]; -#if defined(NV_GPIO_DEVICE_FIND_PRESENT) /* Linux 6.7 */ +#if defined(NV_GPIO_DEVICE_FIND_PRESENT) && \ + defined(NV_GPIO_DEVICE_GET_CHIP_PRESENT) /* Linux 6.7 */ struct gpio_device *gdev; #endif @@ -58,7 +59,8 @@ static struct gpio_chip *isc_gpio_get_chip(struct platform_device *pdev, } strcpy(name, pd->gpio_prnt_chip); -#if defined(NV_GPIO_DEVICE_FIND_PRESENT) /* Linux 6.7 */ +#if defined(NV_GPIO_DEVICE_FIND_PRESENT) && \ + defined(NV_GPIO_DEVICE_GET_CHIP_PRESENT) /* Linux 6.7 */ gdev = gpio_device_find(name, isc_gpio_chip_match); if (gdev) { gc = gpio_device_get_chip(gdev); diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 31c15489..2ae1a0a4 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -134,6 +134,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_napi_add_weight NV_CONFTEST_FUNCTION_COMPILE_TESTS += of_get_named_gpio_flags NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpio_chip_struct_has_of_node_present NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpio_device_find +NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpio_device_get_chip NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_chip_struct_has_base_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_ops_struct_has_owner diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 5a6fb0df..7fc1aa54 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7092,6 +7092,23 @@ compile_test() { fi ;; + gpio_device_get_chip) + # + # Determine if function gpio_device_get_chip() is present. + # + # Added by commit 9b418780844c ("gpiolib: reluctantly provide + # gpio_device_get_chip()") in Linux v6.7. + # + CODE=" + #include + void conftest_gpio_device_get_chip(void) + { + gpio_device_get_chip(); + }" + + compile_check_conftest "$CODE" "NV_GPIO_DEVICE_GET_CHIP_PRESENT" "" "functions" + ;; + netif_set_tso_max_size) # # Determine if netif_set_tso_max_size() function is present