drivers: drop few redundant device_is_ready
Drop few redundant device_is_ready for functions that are only used as argument to shell_device_filter, as shell_device_filter checks for that alrady. Suggested-by: Yishai Jaffe <yishai1999@gmail.com> Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
parent
11b5e1f8f5
commit
0bc123da11
@ -216,9 +216,9 @@ static int cmd_trigger_is_pending(const struct shell *sh, size_t argc, char **ar
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool device_is_comp_and_ready(const struct device *dev)
|
||||
static bool device_is_comp(const struct device *dev)
|
||||
{
|
||||
return device_is_ready(dev) && DEVICE_API_IS(comparator, dev);
|
||||
return DEVICE_API_IS(comparator, dev);
|
||||
}
|
||||
|
||||
static void dsub_set_trigger_lookup_1(size_t idx, struct shell_static_entry *entry)
|
||||
@ -233,7 +233,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_set_trigger_1, dsub_set_trigger_lookup_1);
|
||||
|
||||
static void dsub_set_trigger_lookup_0(size_t idx, struct shell_static_entry *entry)
|
||||
{
|
||||
const struct device *dev = shell_device_filter(idx, device_is_comp_and_ready);
|
||||
const struct device *dev = shell_device_filter(idx, device_is_comp);
|
||||
|
||||
entry->syntax = dev != NULL ? dev->name : NULL;
|
||||
entry->handler = NULL;
|
||||
@ -245,7 +245,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_set_trigger_0, dsub_set_trigger_lookup_0);
|
||||
|
||||
static void dsub_device_lookup_0(size_t idx, struct shell_static_entry *entry)
|
||||
{
|
||||
const struct device *dev = shell_device_filter(idx, device_is_comp_and_ready);
|
||||
const struct device *dev = shell_device_filter(idx, device_is_comp);
|
||||
|
||||
entry->syntax = (dev != NULL) ? dev->name : NULL;
|
||||
entry->handler = NULL;
|
||||
|
||||
@ -330,14 +330,14 @@ cmd_write_channels(const struct shell *sh, size_t argc, char **argv)
|
||||
return err;
|
||||
}
|
||||
|
||||
static bool device_is_led_and_ready(const struct device *dev)
|
||||
static bool device_is_led(const struct device *dev)
|
||||
{
|
||||
return device_is_ready(dev) && DEVICE_API_IS(led, dev);
|
||||
return DEVICE_API_IS(led, dev);
|
||||
}
|
||||
|
||||
static void device_name_get(size_t idx, struct shell_static_entry *entry)
|
||||
{
|
||||
const struct device *dev = shell_device_filter(idx, device_is_led_and_ready);
|
||||
const struct device *dev = shell_device_filter(idx, device_is_led);
|
||||
|
||||
entry->syntax = (dev != NULL) ? dev->name : NULL;
|
||||
entry->handler = NULL;
|
||||
|
||||
@ -126,14 +126,14 @@ static int cmd_nsec(const struct shell *sh, size_t argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool device_is_pwm_and_ready(const struct device *dev)
|
||||
static bool device_is_pwm(const struct device *dev)
|
||||
{
|
||||
return device_is_ready(dev) && DEVICE_API_IS(pwm, dev);
|
||||
return DEVICE_API_IS(pwm, dev);
|
||||
}
|
||||
|
||||
static void device_name_get(size_t idx, struct shell_static_entry *entry)
|
||||
{
|
||||
const struct device *dev = shell_device_filter(idx, device_is_pwm_and_ready);
|
||||
const struct device *dev = shell_device_filter(idx, device_is_pwm);
|
||||
|
||||
entry->syntax = (dev != NULL) ? dev->name : NULL;
|
||||
entry->handler = NULL;
|
||||
|
||||
@ -67,9 +67,9 @@ static void print_callback(const struct device *dev, const enum stepper_event ev
|
||||
}
|
||||
}
|
||||
|
||||
static bool stepper_device_check(const struct device *dev)
|
||||
static bool device_is_stepper(const struct device *dev)
|
||||
{
|
||||
return DEVICE_API_IS(stepper, dev) && device_is_ready(dev);
|
||||
return DEVICE_API_IS(stepper, dev);
|
||||
}
|
||||
|
||||
static const struct stepper_direction_map stepper_direction_map[] = {
|
||||
@ -119,7 +119,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_stepper_microstep, cmd_stepper_microstep);
|
||||
|
||||
static void cmd_pos_stepper_motor_name(size_t idx, struct shell_static_entry *entry)
|
||||
{
|
||||
const struct device *dev = shell_device_filter(idx, stepper_device_check);
|
||||
const struct device *dev = shell_device_filter(idx, device_is_stepper);
|
||||
|
||||
entry->syntax = (dev != NULL) ? dev->name : NULL;
|
||||
entry->handler = NULL;
|
||||
@ -131,7 +131,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_pos_stepper_motor_name, cmd_pos_stepper_motor_name
|
||||
|
||||
static void cmd_pos_stepper_motor_name_dir(size_t idx, struct shell_static_entry *entry)
|
||||
{
|
||||
const struct device *dev = shell_device_filter(idx, stepper_device_check);
|
||||
const struct device *dev = shell_device_filter(idx, device_is_stepper);
|
||||
|
||||
if (dev != NULL) {
|
||||
entry->syntax = dev->name;
|
||||
@ -147,7 +147,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_pos_stepper_motor_name_dir, cmd_pos_stepper_motor_
|
||||
|
||||
static void cmd_pos_stepper_motor_name_microstep(size_t idx, struct shell_static_entry *entry)
|
||||
{
|
||||
const struct device *dev = shell_device_filter(idx, stepper_device_check);
|
||||
const struct device *dev = shell_device_filter(idx, device_is_stepper);
|
||||
|
||||
if (dev != NULL) {
|
||||
entry->syntax = dev->name;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user