Skip to content

Commit

Permalink
shell: use shell_device_get_binding
Browse files Browse the repository at this point in the history
Use shell_device_get_binding() instead of device_get_binding() so that
we get the device based on its name and in addition by its label.

Signed-off-by: Yishai Jaffe <[email protected]>
  • Loading branch information
yishai1999 authored and kartben committed Dec 18, 2024
1 parent 13ea587 commit 1b4cef3
Show file tree
Hide file tree
Showing 24 changed files with 134 additions and 134 deletions.
8 changes: 4 additions & 4 deletions drivers/audio/codec_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static int cmd_start(const struct shell *sh, size_t argc, char *argv[])
{
const struct device *dev;

dev = device_get_binding(argv[args_indx.device]);
dev = shell_device_get_binding(argv[args_indx.device]);
if (!dev) {
shell_error(sh, "Audio Codec device not found");
return -ENODEV;
Expand All @@ -95,7 +95,7 @@ static int cmd_stop(const struct shell *sh, size_t argc, char *argv[])
{
const struct device *dev;

dev = device_get_binding(argv[args_indx.device]);
dev = shell_device_get_binding(argv[args_indx.device]);
if (!dev) {
shell_error(sh, "Audio Codec device not found");
return -ENODEV;
Expand All @@ -114,7 +114,7 @@ static int cmd_set_prop(const struct shell *sh, size_t argc, char *argv[])
char *endptr;
audio_property_value_t property_value;

dev = device_get_binding(argv[args_indx.device]);
dev = shell_device_get_binding(argv[args_indx.device]);
if (!dev) {
shell_error(sh, "Audio Codec device not found");
return -ENODEV;
Expand Down Expand Up @@ -159,7 +159,7 @@ static int cmd_apply_prop(const struct shell *sh, size_t argc, char *argv[])
{
const struct device *dev;

dev = device_get_binding(argv[args_indx.device]);
dev = shell_device_get_binding(argv[args_indx.device]);
if (!dev) {
shell_error(sh, "Audio Codec device not found");
return -ENODEV;
Expand Down
2 changes: 1 addition & 1 deletion drivers/bbram/bbram_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static inline int parse_device(const struct shell *sh, size_t argc, char *argv[]
return -EINVAL;
}

*bbram_dev = device_get_binding(argv[1]);
*bbram_dev = shell_device_get_binding(argv[1]);
if (!*bbram_dev) {
shell_error(sh, "Given BBRAM device was not found");
return -ENODEV;
Expand Down
24 changes: 12 additions & 12 deletions drivers/can/can_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static void can_shell_print_extended_modes(const struct shell *sh, can_mode_t ca

static int cmd_can_start(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
int err;

if (!can_device_check(dev)) {
Expand All @@ -302,7 +302,7 @@ static int cmd_can_start(const struct shell *sh, size_t argc, char **argv)

static int cmd_can_stop(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
int err;

if (!can_device_check(dev)) {
Expand All @@ -323,7 +323,7 @@ static int cmd_can_stop(const struct shell *sh, size_t argc, char **argv)

static int cmd_can_show(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
const struct device *phy;
const struct can_timing *timing_min;
const struct can_timing *timing_max;
Expand Down Expand Up @@ -434,7 +434,7 @@ static int cmd_can_show(const struct shell *sh, size_t argc, char **argv)

static int cmd_can_bitrate_set(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
struct can_timing timing = { 0 };
uint16_t sample_pnt;
uint32_t bitrate;
Expand Down Expand Up @@ -505,7 +505,7 @@ static int cmd_can_bitrate_set(const struct shell *sh, size_t argc, char **argv)

static int cmd_can_dbitrate_set(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
struct can_timing timing = { 0 };
uint16_t sample_pnt;
uint32_t bitrate;
Expand Down Expand Up @@ -614,7 +614,7 @@ static int can_shell_parse_timing(const struct shell *sh, size_t argc, char **ar

static int cmd_can_timing_set(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
struct can_timing timing = { 0 };
int err;

Expand Down Expand Up @@ -643,7 +643,7 @@ static int cmd_can_timing_set(const struct shell *sh, size_t argc, char **argv)

static int cmd_can_dtiming_set(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
struct can_timing timing = { 0 };
int err;

Expand Down Expand Up @@ -672,7 +672,7 @@ static int cmd_can_dtiming_set(const struct shell *sh, size_t argc, char **argv)

static int cmd_can_mode_set(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
can_mode_t mode = CAN_MODE_NORMAL;
can_mode_t raw;
char *endptr;
Expand Down Expand Up @@ -720,7 +720,7 @@ static int cmd_can_mode_set(const struct shell *sh, size_t argc, char **argv)

static int cmd_can_send(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
static unsigned int frame_counter;
unsigned int frame_no;
struct can_frame frame = { 0 };
Expand Down Expand Up @@ -841,7 +841,7 @@ static int cmd_can_send(const struct shell *sh, size_t argc, char **argv)

static int cmd_can_filter_add(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
struct can_filter filter;
uint32_t id_mask;
int argidx = 2;
Expand Down Expand Up @@ -941,7 +941,7 @@ static int cmd_can_filter_add(const struct shell *sh, size_t argc, char **argv)

static int cmd_can_filter_remove(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
int filter_id;
char *endptr;

Expand All @@ -965,7 +965,7 @@ static int cmd_can_filter_remove(const struct shell *sh, size_t argc, char **arg

static int cmd_can_recover(const struct shell *sh, size_t argc, char **argv)
{
const struct device *dev = device_get_binding(argv[1]);
const struct device *dev = shell_device_get_binding(argv[1]);
k_timeout_t timeout = K_FOREVER;
int millisec;
char *endptr;
Expand Down
2 changes: 1 addition & 1 deletion drivers/comparator/comparator_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static int get_device_from_str(const struct shell *sh,
const char *dev_str,
const struct device **dev)
{
*dev = device_get_binding(dev_str);
*dev = shell_device_get_binding(dev_str);

if (*dev == NULL) {
shell_error(sh, "%s not %s", dev_str, "found");
Expand Down
2 changes: 1 addition & 1 deletion drivers/counter/counter_timer_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static inline int parse_device(const struct shell *shctx, size_t argc, char *arg
{
ARG_UNUSED(argc);

*timer_dev = device_get_binding(argv[ARGV_DEV]);
*timer_dev = shell_device_get_binding(argv[ARGV_DEV]);
if (*timer_dev == NULL) {
shell_error(shctx, "Timer: Device %s not found", argv[ARGV_DEV]);
return -ENODEV;
Expand Down
4 changes: 2 additions & 2 deletions drivers/dac/dac_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static int cmd_setup(const struct shell *sh, size_t argc, char **argv)
int argidx;
int err;

dac = device_get_binding(argv[args_indx.device]);
dac = shell_device_get_binding(argv[args_indx.device]);
if (!dac) {
shell_error(sh, "DAC device not found");
return -EINVAL;
Expand Down Expand Up @@ -76,7 +76,7 @@ static int cmd_write_value(const struct shell *sh, size_t argc, char **argv)
uint32_t value;
int err;

dac = device_get_binding(argv[args_indx.device]);
dac = shell_device_get_binding(argv[args_indx.device]);
if (!dac) {
shell_error(sh, "DAC device not found");
return -EINVAL;
Expand Down
8 changes: 4 additions & 4 deletions drivers/eeprom/eeprom_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int cmd_read(const struct shell *sh, size_t argc, char **argv)
addr = strtoul(argv[args_indx.offset], NULL, 0);
len = strtoul(argv[args_indx.length], NULL, 0);

eeprom = device_get_binding(argv[args_indx.device]);
eeprom = shell_device_get_binding(argv[args_indx.device]);
if (!eeprom) {
shell_error(sh, "EEPROM device not found");
return -EINVAL;
Expand Down Expand Up @@ -98,7 +98,7 @@ static int cmd_write(const struct shell *sh, size_t argc, char **argv)
wr_buf[i] = byte;
}

eeprom = device_get_binding(argv[args_indx.device]);
eeprom = shell_device_get_binding(argv[args_indx.device]);
if (!eeprom) {
shell_error(sh, "EEPROM device not found");
return -EINVAL;
Expand Down Expand Up @@ -134,7 +134,7 @@ static int cmd_size(const struct shell *sh, size_t argc, char **argv)
{
const struct device *eeprom;

eeprom = device_get_binding(argv[args_indx.device]);
eeprom = shell_device_get_binding(argv[args_indx.device]);
if (!eeprom) {
shell_error(sh, "EEPROM device not found");
return -EINVAL;
Expand Down Expand Up @@ -167,7 +167,7 @@ static int cmd_fill(const struct shell *sh, size_t argc, char **argv)
}
memset(wr_buf, pattern, MIN(len, CONFIG_EEPROM_SHELL_BUFFER_SIZE));

eeprom = device_get_binding(argv[args_indx.device]);
eeprom = shell_device_get_binding(argv[args_indx.device]);
if (!eeprom) {
shell_error(sh, "EEPROM device not found");
return -EINVAL;
Expand Down
6 changes: 3 additions & 3 deletions drivers/flash/flash_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static int parse_helper(const struct shell *sh, size_t *argc,

if (*endptr != '\0') {
/* flash controller from user input */
*flash_dev = device_get_binding((*argv)[1]);
*flash_dev = shell_device_get_binding((*argv)[1]);
if (!*flash_dev) {
shell_error(sh, "Given flash device was not found");
return -ENODEV;
Expand Down Expand Up @@ -193,8 +193,8 @@ static int cmd_copy(const struct shell *sh, size_t argc, char *argv[])
return -EINVAL;
}

src_dev = device_get_binding(argv[1]);
dst_dev = device_get_binding(argv[2]);
src_dev = shell_device_get_binding(argv[1]);
dst_dev = shell_device_get_binding(argv[2]);
src_offset = strtoul(argv[3], NULL, 0);
dst_offset = strtoul(argv[4], NULL, 0);
/* size will be padded to write_size bytes */
Expand Down
2 changes: 1 addition & 1 deletion drivers/fpga/fpga_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
static int parse_common_args(const struct shell *sh, char **argv,
const struct device **dev)
{
*dev = device_get_binding(argv[1]);
*dev = shell_device_get_binding(argv[1]);
if (!*dev) {
shell_error(sh, "FPGA device %s not found", argv[1]);
return -ENODEV;
Expand Down
10 changes: 5 additions & 5 deletions drivers/i2c/i2c_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int cmd_i2c_scan(const struct shell *shell_ctx,
const struct device *dev;
uint8_t cnt = 0, first = 0x04, last = 0x77;

dev = device_get_binding(argv[ARGV_DEV]);
dev = shell_device_get_binding(argv[ARGV_DEV]);

if (!dev) {
shell_error(shell_ctx, "I2C: Device driver %s not found.",
Expand Down Expand Up @@ -102,7 +102,7 @@ static int cmd_i2c_recover(const struct shell *shell_ctx,
const struct device *dev;
int err;

dev = device_get_binding(argv[ARGV_DEV]);
dev = shell_device_get_binding(argv[ARGV_DEV]);
if (!dev) {
shell_error(shell_ctx, "I2C: Device driver %s not found.",
argv[1]);
Expand Down Expand Up @@ -135,7 +135,7 @@ static int i2c_write_from_buffer(const struct shell *shell_ctx,
int ret;
int i;

dev = device_get_binding(s_dev_name);
dev = shell_device_get_binding(s_dev_name);
if (!dev) {
shell_error(shell_ctx, "I2C: Device driver %s not found.",
s_dev_name);
Expand Down Expand Up @@ -198,7 +198,7 @@ static int i2c_read_to_buffer(const struct shell *shell_ctx,
int dev_addr;
int ret;

dev = device_get_binding(s_dev_name);
dev = shell_device_get_binding(s_dev_name);
if (!dev) {
shell_error(shell_ctx, "I2C: Device driver %s not found.",
s_dev_name);
Expand Down Expand Up @@ -310,7 +310,7 @@ static int cmd_i2c_speed(const struct shell *shell_ctx, size_t argc, char **argv
uint32_t speed;
int ret;

dev = device_get_binding(s_dev_name);
dev = shell_device_get_binding(s_dev_name);
if (!dev) {
shell_error(shell_ctx, "I2C: Device driver %s not found.",
s_dev_name);
Expand Down
Loading

0 comments on commit 1b4cef3

Please sign in to comment.