mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
{isc,cdi}_mgr: Use gpiod_count() for getting number of GPIO
The API gpiod_count() returns the number of the GPIO in given property. This API is supported from long and continue to support. Use this API instead of of_gpio_named_count() which is deprecated from Linux 6.2. Bug 4387902 Change-Id: I2b647b8645e0dd8ff743515ac999fe035e636dc5 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3035503 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
75c908beb6
commit
6627276f82
@@ -1328,22 +1328,21 @@ static int cdi_mgr_of_get_grp_gpio(
|
||||
struct device *dev, struct device_node *np,
|
||||
const char *name, int size, u32 *grp, u32 *flags)
|
||||
{
|
||||
char prop_name[32]; /* 32 is max size of property name */
|
||||
int num, i;
|
||||
|
||||
#if defined(NV_OF_GPIO_NAMED_COUNT_PRESENT) /* Linux 6.2 */
|
||||
num = of_gpio_named_count(np, name);
|
||||
#else
|
||||
num = of_count_phandle_with_args(np, name, "#gpio-cells");
|
||||
#endif
|
||||
dev_dbg(dev, " num gpios of %s: %d\n", name, num);
|
||||
snprintf(prop_name, sizeof(prop_name), "%s-gpios", name);
|
||||
|
||||
num = gpiod_count(dev, name);
|
||||
dev_dbg(dev, " num gpios of %s: %d\n", prop_name, num);
|
||||
if (num < 0)
|
||||
return 0;
|
||||
|
||||
for (i = 0; (i < num) && (i < size); i++) {
|
||||
#if defined(NV_OF_GET_NAMED_GPIO_FLAGS_PRESENT) /* Linux 6.2 */
|
||||
grp[i] = of_get_named_gpio_flags(np, name, i, &flags[i]);
|
||||
grp[i] = of_get_named_gpio_flags(np, prop_name, i, &flags[i]);
|
||||
#else
|
||||
grp[i] = of_get_named_gpio(np, name, i);
|
||||
grp[i] = of_get_named_gpio(np, prop_name, i);
|
||||
flags[i] = 0;
|
||||
#endif
|
||||
if ((int)grp[i] < 0) {
|
||||
@@ -1455,13 +1454,13 @@ static struct cdi_mgr_platform_data *of_cdi_mgr_pdata(struct platform_device
|
||||
dev_dbg(&pdev->dev, " csiport: %d\n", pd->csi_port);
|
||||
|
||||
pd->num_pwr_gpios = cdi_mgr_of_get_grp_gpio(
|
||||
&pdev->dev, child_np, "pwdn-gpios",
|
||||
&pdev->dev, child_np, "pwdn",
|
||||
ARRAY_SIZE(pd->pwr_gpios), pd->pwr_gpios, pd->pwr_flags);
|
||||
if (pd->num_pwr_gpios < 0)
|
||||
return ERR_PTR(pd->num_pwr_gpios);
|
||||
|
||||
pd->num_mcdi_gpios = cdi_mgr_of_get_grp_gpio(
|
||||
&pdev->dev, child_np, "mcdi-gpios",
|
||||
&pdev->dev, child_np, "mcdi",
|
||||
ARRAY_SIZE(pd->mcdi_gpios), pd->mcdi_gpios, pd->mcdi_flags);
|
||||
if (pd->num_mcdi_gpios < 0)
|
||||
return ERR_PTR(pd->num_mcdi_gpios);
|
||||
|
||||
@@ -813,22 +813,21 @@ static int isc_mgr_of_get_grp_gpio(
|
||||
struct device *dev, struct device_node *np,
|
||||
const char *name, int size, u32 *grp, u32 *flags)
|
||||
{
|
||||
char prop_name[32]; /* 32 is max size of property name */
|
||||
int num, i;
|
||||
|
||||
#if defined(NV_OF_GPIO_NAMED_COUNT_PRESENT) /* Linux 6.2 */
|
||||
num = of_gpio_named_count(np, name);
|
||||
#else
|
||||
num = of_count_phandle_with_args(np, name, "#gpio-cells");
|
||||
#endif
|
||||
dev_dbg(dev, " num gpios of %s: %d\n", name, num);
|
||||
snprintf(prop_name, sizeof(prop_name), "%s-gpios", name);
|
||||
|
||||
num = gpiod_count(dev, name);
|
||||
dev_dbg(dev, " num gpios of %s: %d\n", prop_name, num);
|
||||
if (num < 0)
|
||||
return 0;
|
||||
|
||||
for (i = 0; (i < num) && (i < size); i++) {
|
||||
#if defined(NV_OF_GET_NAMED_GPIO_FLAGS_PRESENT) /* Linux 6.2 */
|
||||
grp[i] = of_get_named_gpio_flags(np, name, i, &flags[i]);
|
||||
grp[i] = of_get_named_gpio_flags(np, prop_name, i, &flags[i]);
|
||||
#else
|
||||
grp[i] = of_get_named_gpio(np, name, i);
|
||||
grp[i] = of_get_named_gpio(np, prop_name, i);
|
||||
flags[i] = 0;
|
||||
#endif
|
||||
if ((int)grp[i] < 0) {
|
||||
@@ -933,13 +932,13 @@ static struct isc_mgr_platform_data *of_isc_mgr_pdata(struct platform_device
|
||||
dev_dbg(&pdev->dev, " csiport: %d\n", pd->csi_port);
|
||||
|
||||
pd->num_pwr_gpios = isc_mgr_of_get_grp_gpio(
|
||||
&pdev->dev, np, "pwdn-gpios",
|
||||
&pdev->dev, np, "pwdn",
|
||||
ARRAY_SIZE(pd->pwr_gpios), pd->pwr_gpios, pd->pwr_flags);
|
||||
if (pd->num_pwr_gpios < 0)
|
||||
return ERR_PTR(pd->num_pwr_gpios);
|
||||
|
||||
pd->num_misc_gpios = isc_mgr_of_get_grp_gpio(
|
||||
&pdev->dev, np, "misc-gpios",
|
||||
&pdev->dev, np, "misc",
|
||||
ARRAY_SIZE(pd->misc_gpios), pd->misc_gpios, pd->misc_flags);
|
||||
if (pd->num_misc_gpios < 0)
|
||||
return ERR_PTR(pd->num_misc_gpios);
|
||||
|
||||
@@ -129,7 +129,6 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += mii_bus_struct_has_write_c45
|
||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_set_tso_max_size
|
||||
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_gpio_named_count
|
||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpio_chip_struct_has_of_node_present
|
||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpiochip_find
|
||||
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data
|
||||
|
||||
@@ -5473,27 +5473,6 @@ compile_test() {
|
||||
compile_check_conftest "$CODE" "NV_OF_GET_NAMED_GPIO_FLAGS_PRESENT" "" "functions"
|
||||
;;
|
||||
|
||||
of_gpio_named_count)
|
||||
#
|
||||
# Determine if of_gpio_named_count() function is present
|
||||
#
|
||||
# This APIS is removed in commit c7835652a85 ("gpiolib: of: stop
|
||||
# exporting of_gpio_named_count()")
|
||||
# in Linux 6.2.
|
||||
#
|
||||
CODE="
|
||||
#if defined(NV_LINUX_OF_GPIO_H_PRESENT)
|
||||
#include <linux/of_gpio.h>
|
||||
#endif
|
||||
void conftest_of_gpio_named_count(void)
|
||||
{
|
||||
of_gpio_named_count();
|
||||
}
|
||||
"
|
||||
|
||||
compile_check_conftest "$CODE" "NV_OF_GPIO_NAMED_COUNT_PRESENT" "" "functions"
|
||||
;;
|
||||
|
||||
gpio_chip_struct_has_of_node_present)
|
||||
#
|
||||
# Determine if struct gpio_chip has the of_node member or not.
|
||||
|
||||
Reference in New Issue
Block a user