gpio: shell: use new shell_device_get_binding function

Use shell_device_get_binding() to minimize code.

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
This commit is contained in:
Yishai Jaffe 2024-12-08 10:52:25 +02:00 committed by Benjamin Cabé
parent 59c7d5715b
commit 9c60bcb19a
2 changed files with 2 additions and 25 deletions

View file

@ -17,7 +17,6 @@ source "subsys/logging/Kconfig.template.log_config"
config GPIO_SHELL config GPIO_SHELL
bool "GPIO Shell" bool "GPIO Shell"
depends on SHELL depends on SHELL
imply DEVICE_DT_METADATA
help help
Enable GPIO Shell for testing. Enable GPIO Shell for testing.

View file

@ -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 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; size_t i;
const struct device *dev = shell_device_get_binding(name);
if (dev == NULL) { if (dev == NULL) {
return NULL; return NULL;
@ -151,29 +152,6 @@ static const struct gpio_ctrl *get_gpio_ctrl_helper(const struct device *dev)
return NULL; 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 line_cmp(const char *input, const char *line_name)
{ {
int i = 0; int i = 0;