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 <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3104559
(cherry picked from commit 037fa78728)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3104651
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2024-03-26 14:05:41 +00:00
committed by mobile promotions
parent 94090ac30e
commit 5ff50fc9ea
3 changed files with 41 additions and 5 deletions

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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 <linux/gpio/driver.h>
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 <linux/gpio/driver.h>
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)