media: camera: Update conftest for gpio_device_find

When adding conftest tests for detecting if specific functions are
present, it is always better to check if the newly added function is
present versus the function that has been removed. The reason being that
is the newly added function is modified in the future then the conftest
tests can be extended to check for updates to the function.

Therefore, instead of checking if the function gpiochip_find() is
present, which was removed in Linux v6.7, check if the function
gpio_device_find() is present, which replaced gpiochip_find in Linux
v6.7.

Bug 4346767
Bug 4471899

Change-Id: I32bf1c3da32abbf3c8d3ef9ea350decf1564e0bc
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
(cherry picked from commit 68e7840dd8)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3111544
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2024-04-03 11:46:43 +01:00
committed by mobile promotions
parent f78df7fa59
commit 94090ac30e
4 changed files with 33 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2017-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h> #include <nvidia/conftest.h>
@@ -42,7 +42,7 @@ static struct gpio_chip *cdi_gpio_get_chip(struct platform_device *pdev,
struct cdi_gpio_plat_data *pd) struct cdi_gpio_plat_data *pd)
{ {
struct gpio_chip *gc = NULL; struct gpio_chip *gc = NULL;
#if !defined(NV_GPIOCHIP_FIND_PRESENT) /* Linux 6.7 */ #if defined(NV_GPIO_DEVICE_FIND_PRESENT) /* Linux 6.7 */
struct gpio_device *gdev; struct gpio_device *gdev;
#endif #endif
char name[MAX_STR_SIZE]; char name[MAX_STR_SIZE];
@@ -54,14 +54,14 @@ static struct gpio_chip *cdi_gpio_get_chip(struct platform_device *pdev,
} }
strcpy(name, pd->gpio_prnt_chip); strcpy(name, pd->gpio_prnt_chip);
#if defined(NV_GPIOCHIP_FIND_PRESENT) /* Linux 6.7 */ #if defined(NV_GPIO_DEVICE_FIND_PRESENT) /* Linux 6.7 */
gc = gpiochip_find(name, cdi_gpio_chip_match);
#else
gdev = gpio_device_find(name, cdi_gpio_chip_match); gdev = gpio_device_find(name, cdi_gpio_chip_match);
if (gdev) { if (gdev) {
gc = gpio_device_get_chip(gdev); gc = gpio_device_get_chip(gdev);
gpio_device_put(gdev); gpio_device_put(gdev);
} }
#else
gc = gpiochip_find(name, cdi_gpio_chip_match);
#endif #endif
if (!gc) { if (!gc) {
dev_err(&pdev->dev, "%s: unable to find gpio parent chip %s\n", dev_err(&pdev->dev, "%s: unable to find gpio parent chip %s\n",

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2017-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h> #include <nvidia/conftest.h>
@@ -43,7 +43,7 @@ static struct gpio_chip *isc_gpio_get_chip(struct platform_device *pdev,
{ {
struct gpio_chip *gc = NULL; struct gpio_chip *gc = NULL;
char name[MAX_STR_SIZE]; char name[MAX_STR_SIZE];
#if !defined(NV_GPIOCHIP_FIND_PRESENT) /* Linux 6.7 */ #if defined(NV_GPIO_DEVICE_FIND_PRESENT) /* Linux 6.7 */
struct gpio_device *gdev; struct gpio_device *gdev;
#endif #endif
@@ -54,14 +54,14 @@ static struct gpio_chip *isc_gpio_get_chip(struct platform_device *pdev,
} }
strcpy(name, pd->gpio_prnt_chip); strcpy(name, pd->gpio_prnt_chip);
#if defined(NV_GPIOCHIP_FIND_PRESENT) /* Linux 6.7 */ #if defined(NV_GPIO_DEVICE_FIND_PRESENT) /* Linux 6.7 */
gc = gpiochip_find(name, isc_gpio_chip_match);
#else
gdev = gpio_device_find(name, isc_gpio_chip_match); gdev = gpio_device_find(name, isc_gpio_chip_match);
if (gdev) { if (gdev) {
gc = gpio_device_get_chip(gdev); gc = gpio_device_get_chip(gdev);
gpio_device_put(gdev); gpio_device_put(gdev);
} }
#else
gc = gpiochip_find(name, isc_gpio_chip_match);
#endif #endif
if (!gc) { if (!gc) {
dev_err(&pdev->dev, "%s: unable to find gpio parent chip %s\n", dev_err(&pdev->dev, "%s: unable to find gpio parent chip %s\n",

View File

@@ -133,7 +133,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_set_tso_max_size
NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_napi_add_weight NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_napi_add_weight
NV_CONFTEST_FUNCTION_COMPILE_TESTS += of_get_named_gpio_flags 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_chip_struct_has_of_node_present
NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpiochip_find NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpio_device_find
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_chip_struct_has_base_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_chip_struct_has_base_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_ops_struct_has_owner NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_ops_struct_has_owner

View File

@@ -5508,24 +5508,6 @@ compile_test() {
compile_check_conftest "$CODE" "NV_GPIO_CHIP_STRUCT_HAS_OF_NODE_PRESENT" "" "types" compile_check_conftest "$CODE" "NV_GPIO_CHIP_STRUCT_HAS_OF_NODE_PRESENT" "" "types"
;; ;;
gpiochip_find)
#
# Determine if function gpiochip_find() present or not.
#
# The function gpiochip_find() is removed from commit 2654521d774f9
# ("gpiolib: remove gpiochip_find()" in Linux 6.7
#
CODE="
#include <linux/gpio/driver.h>
void conftest_gpiochip_find_present(void)
{
gpiochip_find();
}
"
compile_check_conftest "$CODE" "NV_GPIOCHIP_FIND_PRESENT" "" "functions"
;;
devm_gpio_request_one) devm_gpio_request_one)
# #
# Determine if devm_gpio_request_one() function is present # Determine if devm_gpio_request_one() function is present
@@ -7062,6 +7044,26 @@ compile_test() {
compile_check_conftest "$CODE" "NV_GENDPD_XLATE_T_HAS_CONST_OF_PHANDLE_ARGS" "" "types" compile_check_conftest "$CODE" "NV_GENDPD_XLATE_T_HAS_CONST_OF_PHANDLE_ARGS" "" "types"
;; ;;
gpio_device_find)
#
# Determine if function gpio_device_find() present.
#
# 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="
#include <linux/gpio/driver.h>
void conftest_gpio_device_find(void)
{
gpio_device_find();
}
"
compile_check_conftest "$CODE" "NV_GPIO_DEVICE_FIND_PRESENT" "" "functions"
;;
netif_set_tso_max_size) netif_set_tso_max_size)
# #
# Determine if netif_set_tso_max_size() function is present # Determine if netif_set_tso_max_size() function is present