From 9c60bcb19a2d69c8da53c1fb290e32648bf06019 Mon Sep 17 00:00:00 2001 From: Yishai Jaffe Date: Sun, 8 Dec 2024 10:52:25 +0200 Subject: [PATCH] gpio: shell: use new shell_device_get_binding function Use shell_device_get_binding() to minimize code. Signed-off-by: Yishai Jaffe --- drivers/gpio/Kconfig | 1 - drivers/gpio/gpio_shell.c | 26 ++------------------------ 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 96d69068cd5..331e34aac2c 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -17,7 +17,6 @@ source "subsys/logging/Kconfig.template.log_config" config GPIO_SHELL bool "GPIO Shell" depends on SHELL - imply DEVICE_DT_METADATA help Enable GPIO Shell for testing. diff --git a/drivers/gpio/gpio_shell.c b/drivers/gpio/gpio_shell.c index d05683327c9..d85b72e2dca 100644 --- a/drivers/gpio/gpio_shell.c +++ b/drivers/gpio/gpio_shell.c @@ -134,9 +134,10 @@ DT_FOREACH_STATUS_OKAY_NODE(IS_GPIO_CTRL_PIN_GET) static const struct gpio_ctrl gpio_list[] = {DT_FOREACH_STATUS_OKAY_NODE(IS_GPIO_CTRL_LIST)}; -static const struct gpio_ctrl *get_gpio_ctrl_helper(const struct device *dev) +static const struct gpio_ctrl *get_gpio_ctrl(const char *name) { size_t i; + const struct device *dev = shell_device_get_binding(name); if (dev == NULL) { return NULL; @@ -151,29 +152,6 @@ static const struct gpio_ctrl *get_gpio_ctrl_helper(const struct device *dev) return NULL; } -/* Look up a device by some human-readable string identifier. We - * always search among device names. If the feature is available, we - * search by node label as well. - */ -static const struct gpio_ctrl *get_gpio_ctrl(char *id) -{ - const struct gpio_ctrl *ctrl; - - ctrl = get_gpio_ctrl_helper(device_get_binding(id)); - if (ctrl != NULL) { - return ctrl; - } - -#ifdef CONFIG_DEVICE_DT_METADATA - ctrl = get_gpio_ctrl_helper(device_get_by_dt_nodelabel(id)); - if (ctrl != NULL) { - return ctrl; - } -#endif /* CONFIG_DEVICE_DT_METADATA */ - - return NULL; -} - int line_cmp(const char *input, const char *line_name) { int i = 0;