@@ -1548,13 +1548,15 @@ static int cmd_i3c_ccc_getvendor(const struct shell *shell_ctx, size_t argc, cha
15481548 uint8_t defbyte ;
15491549 size_t num_xfer ;
15501550 uint8_t id ;
1551+ int err = 0 ;
15511552 int ret ;
15521553
15531554 dev = device_get_binding (argv [ARGV_DEV ]);
15541555 if (!dev ) {
15551556 shell_error (shell_ctx , "I3C: Device driver %s not found." , argv [ARGV_DEV ]);
15561557 return - ENODEV ;
15571558 }
1559+
15581560 tdev = device_get_binding (argv [ARGV_TDEV ]);
15591561 if (!tdev ) {
15601562 shell_error (shell_ctx , "I3C: Device driver %s not found." , argv [ARGV_TDEV ]);
@@ -1566,8 +1568,14 @@ static int cmd_i3c_ccc_getvendor(const struct shell *shell_ctx, size_t argc, cha
15661568 return - ENODEV ;
15671569 }
15681570
1569- if (argc > 3 ) {
1570- defbyte = strtol (argv [3 ], NULL , 16 );
1571+ id = (uint8_t )shell_strtoul (argv [3 ], 0 , & err );
1572+ if (err != 0 ) {
1573+ shell_error (sh , "I3C: Invalid ID." );
1574+ return - EINVAL ;
1575+ }
1576+
1577+ if (argc > 4 ) {
1578+ defbyte = strtol (argv [4 ], NULL , 16 );
15711579 ret = i3c_ccc_do_getvendor_defbyte (desc , id , defbyte , buf , MAX_I3C_BYTES ,
15721580 & num_xfer );
15731581 } else {
@@ -1593,6 +1601,7 @@ static int cmd_i3c_ccc_setvendor(const struct shell *shell_ctx, size_t argc, cha
15931601 uint8_t buf [MAX_I3C_BYTES ] = {0 };
15941602 uint8_t data_length ;
15951603 uint8_t id ;
1604+ int err = 0 ;
15961605 int ret ;
15971606 int i ;
15981607
@@ -1601,6 +1610,7 @@ static int cmd_i3c_ccc_setvendor(const struct shell *shell_ctx, size_t argc, cha
16011610 shell_error (shell_ctx , "I3C: Device driver %s not found." , argv [ARGV_DEV ]);
16021611 return - ENODEV ;
16031612 }
1613+
16041614 tdev = device_get_binding (argv [ARGV_TDEV ]);
16051615 if (!tdev ) {
16061616 shell_error (shell_ctx , "I3C: Device driver %s not found." , argv [ARGV_TDEV ]);
@@ -1613,6 +1623,12 @@ static int cmd_i3c_ccc_setvendor(const struct shell *shell_ctx, size_t argc, cha
16131623 }
16141624 data = (struct i3c_driver_data * )dev -> data ;
16151625
1626+ id = (uint8_t )shell_strtoul (argv [3 ], 0 , & err );
1627+ if (err != 0 ) {
1628+ shell_error (sh , "I3C: Invalid ID." );
1629+ return - EINVAL ;
1630+ }
1631+
16161632 data_length = argc - 4 ;
16171633 for (i = 0 ; i < data_length ; i ++ ) {
16181634 buf [i ] = (uint8_t )strtol (argv [4 + i ], NULL , 16 );
@@ -1634,6 +1650,7 @@ static int cmd_i3c_ccc_setvendor_bc(const struct shell *shell_ctx, size_t argc,
16341650 uint8_t buf [MAX_I3C_BYTES ] = {0 };
16351651 uint8_t data_length ;
16361652 uint8_t id ;
1653+ int err = 0 ;
16371654 int ret ;
16381655 int i ;
16391656
@@ -1643,6 +1660,12 @@ static int cmd_i3c_ccc_setvendor_bc(const struct shell *shell_ctx, size_t argc,
16431660 return - ENODEV ;
16441661 }
16451662
1663+ id = (uint8_t )shell_strtoul (argv [2 ], 0 , & err );
1664+ if (err != 0 ) {
1665+ shell_error (sh , "I3C: Invalid ID." );
1666+ return - EINVAL ;
1667+ }
1668+
16461669 data_length = argc - 3 ;
16471670 for (i = 0 ; i < data_length ; i ++ ) {
16481671 buf [i ] = (uint8_t )strtol (argv [3 + i ], NULL , 16 );
0 commit comments