From 5ff50fc9ea502a0993c85c8936728a7e23de0ccd Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Tue, 26 Mar 2024 14:05:41 +0000 Subject: [PATCH] media: camera: Fix build for Linux v6.9 In Linux v6.9 the data argument of the function pointer passed to gpio_device_find() was updated to be a const type. This breaks building the CDI and ISC drivers for Linux v6.9. Update the test in conftest that detects the presence of the gpio_device_find() function to perform a second test to see if the argument for the function pointer is a const type. Update the drivers that use the gpio_device_find() function accordingly to fix the build. Bug 4471899 Change-Id: I562451a401bcaebcf0acf9a7d563cb0ea1d87807 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3104559 (cherry picked from commit 037fa787286b654964875dd7dd75e93ab80b41f4) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3104651 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/media/platform/tegra/cdi/cdi_gpio.c | 4 +++ drivers/media/platform/tegra/isc/isc_gpio.c | 4 +++ scripts/conftest/conftest.sh | 38 ++++++++++++++++++--- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/tegra/cdi/cdi_gpio.c b/drivers/media/platform/tegra/cdi/cdi_gpio.c index be48e37a..4f4d9caa 100644 --- a/drivers/media/platform/tegra/cdi/cdi_gpio.c +++ b/drivers/media/platform/tegra/cdi/cdi_gpio.c @@ -33,7 +33,11 @@ static int of_cdi_gpio_pdata(struct platform_device *pdev, return err; } +#if defined(NV_GPIO_DEVICE_FIND_HAS_CONST_DATA_ARG) /* Linux v6.9 */ +static int cdi_gpio_chip_match(struct gpio_chip *chip, const void *data) +#else static int cdi_gpio_chip_match(struct gpio_chip *chip, void *data) +#endif { return !strcmp(chip->label, data); } diff --git a/drivers/media/platform/tegra/isc/isc_gpio.c b/drivers/media/platform/tegra/isc/isc_gpio.c index a4712274..d84c434a 100644 --- a/drivers/media/platform/tegra/isc/isc_gpio.c +++ b/drivers/media/platform/tegra/isc/isc_gpio.c @@ -33,7 +33,11 @@ static int of_isc_gpio_pdata(struct platform_device *pdev, return err; } +#if defined(NV_GPIO_DEVICE_FIND_HAS_CONST_DATA_ARG) /* Linux v6.9 */ +static int isc_gpio_chip_match(struct gpio_chip *chip, const void *data) +#else static int isc_gpio_chip_match(struct gpio_chip *chip, void *data) +#endif { return !strcmp(chip->label, data); } diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index c161f905..5a6fb0df 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7046,22 +7046,50 @@ compile_test() { gpio_device_find) # - # Determine if function gpio_device_find() present. + # Determine if function gpio_device_find() present and if it is + # present, then determine if the function pointer passed to this + # has a const data argument. # # The function gpio_device_find() was add by commit cfe102f63308 # ("gpiolib: provide gpio_device_find()") in Linux v6.7 replacing # the legacy and broken gpiochip_find(), which has since been # removed. # - CODE=" + # Commit faf6efd2e5e2 ("gpio: constify opaque pointer in + # gpio_device_find() match function") updated the data argument in + # the match function pointer to be const in Linux v6.9. + # + echo "$CONFTEST_PREAMBLE #include void conftest_gpio_device_find(void) { gpio_device_find(); - } - " + }" > conftest$$.c - compile_check_conftest "$CODE" "NV_GPIO_DEVICE_FIND_PRESENT" "" "functions" + $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1 + rm -f conftest$$.c + + if [ -f conftest$$.o ]; then + # gpio_find_device() is not present + echo "#undef NV_GPIO_DEVICE_FIND_PRESENT" | append_conftest "functions" + echo "#undef NV_GPIO_DEVICE_FIND_HAS_CONST_DATA_ARG" | append_conftest "types" + rm -f conftest$$.o + else + # gpio_find_device() is present and now check + # the type for the function pointer data argument + echo "#define NV_GPIO_DEVICE_FIND_PRESENT" | append_conftest "functions" + + CODE=" + #include + void conftest_gpio_device_find(void *data, + int (*match)(struct gpio_chip *gc, + const void *data)) + { + gpio_device_find(data, match); + }" + + compile_check_conftest "$CODE" "NV_GPIO_DEVICE_FIND_HAS_CONST_DATA_ARG" "" "types" + fi ;; netif_set_tso_max_size)