Skip to content

Commit 9c60bcb

Browse files
yishai1999kartben
authored andcommitted
gpio: shell: use new shell_device_get_binding function
Use shell_device_get_binding() to minimize code. Signed-off-by: Yishai Jaffe <[email protected]>
1 parent 59c7d57 commit 9c60bcb

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

drivers/gpio/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ source "subsys/logging/Kconfig.template.log_config"
1717
config GPIO_SHELL
1818
bool "GPIO Shell"
1919
depends on SHELL
20-
imply DEVICE_DT_METADATA
2120
help
2221
Enable GPIO Shell for testing.
2322

drivers/gpio/gpio_shell.c

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ DT_FOREACH_STATUS_OKAY_NODE(IS_GPIO_CTRL_PIN_GET)
134134

135135
static const struct gpio_ctrl gpio_list[] = {DT_FOREACH_STATUS_OKAY_NODE(IS_GPIO_CTRL_LIST)};
136136

137-
static const struct gpio_ctrl *get_gpio_ctrl_helper(const struct device *dev)
137+
static const struct gpio_ctrl *get_gpio_ctrl(const char *name)
138138
{
139139
size_t i;
140+
const struct device *dev = shell_device_get_binding(name);
140141

141142
if (dev == NULL) {
142143
return NULL;
@@ -151,29 +152,6 @@ static const struct gpio_ctrl *get_gpio_ctrl_helper(const struct device *dev)
151152
return NULL;
152153
}
153154

154-
/* Look up a device by some human-readable string identifier. We
155-
* always search among device names. If the feature is available, we
156-
* search by node label as well.
157-
*/
158-
static const struct gpio_ctrl *get_gpio_ctrl(char *id)
159-
{
160-
const struct gpio_ctrl *ctrl;
161-
162-
ctrl = get_gpio_ctrl_helper(device_get_binding(id));
163-
if (ctrl != NULL) {
164-
return ctrl;
165-
}
166-
167-
#ifdef CONFIG_DEVICE_DT_METADATA
168-
ctrl = get_gpio_ctrl_helper(device_get_by_dt_nodelabel(id));
169-
if (ctrl != NULL) {
170-
return ctrl;
171-
}
172-
#endif /* CONFIG_DEVICE_DT_METADATA */
173-
174-
return NULL;
175-
}
176-
177155
int line_cmp(const char *input, const char *line_name)
178156
{
179157
int i = 0;

0 commit comments

Comments
 (0)