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 9c29188f..587548ee 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7079,22 +7079,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)