Commit 9c60bcb1 authored by Yishai Jaffe's avatar Yishai Jaffe Committed by Benjamin Cabé
Browse files

gpio: shell: use new shell_device_get_binding function



Use shell_device_get_binding() to minimize code.

Signed-off-by: default avatarYishai Jaffe <yishai1999@gmail.com>
parent 59c7d571
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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.

+2 −24
Original line number Diff line number Diff line
@@ -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;