mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
cmd: pinmux: update result of do_status
Update the result of do_status and always returns a CMD_RET_ value (-ENOSYS was a possible result of show_pinmux). This patch also adds pincontrol name in error messages (dev->name) and treats correctly the status sub command when pin-controller device is not selected. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
9e6da34c72
commit
4c60fd993a
3 changed files with 20 additions and 17 deletions
31
cmd/pinmux.c
31
cmd/pinmux.c
|
@ -52,20 +52,21 @@ static int show_pinmux(struct udevice *dev)
|
||||||
pins_count = pinctrl_get_pins_count(dev);
|
pins_count = pinctrl_get_pins_count(dev);
|
||||||
|
|
||||||
if (pins_count == -ENOSYS) {
|
if (pins_count == -ENOSYS) {
|
||||||
printf("Ops get_pins_count not supported\n");
|
printf("Ops get_pins_count not supported by %s\n", dev->name);
|
||||||
return pins_count;
|
return pins_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < pins_count; i++) {
|
for (i = 0; i < pins_count; i++) {
|
||||||
ret = pinctrl_get_pin_name(dev, i, pin_name, PINNAME_SIZE);
|
ret = pinctrl_get_pin_name(dev, i, pin_name, PINNAME_SIZE);
|
||||||
if (ret == -ENOSYS) {
|
if (ret) {
|
||||||
printf("Ops get_pin_name not supported\n");
|
printf("Ops get_pin_name error (%d) by %s\n", ret, dev->name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pinctrl_get_pin_muxing(dev, i, pin_mux, PINMUX_SIZE);
|
ret = pinctrl_get_pin_muxing(dev, i, pin_mux, PINMUX_SIZE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("Ops get_pin_muxing error (%d)\n", ret);
|
printf("Ops get_pin_muxing error (%d) by %s in %s\n",
|
||||||
|
ret, pin_name, dev->name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,25 +81,27 @@ static int do_status(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
{
|
{
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
int ret = CMD_RET_USAGE;
|
|
||||||
|
|
||||||
if (currdev && (argc < 2 || strcmp(argv[1], "-a")))
|
if (argc < 2) {
|
||||||
return show_pinmux(currdev);
|
if (!currdev) {
|
||||||
|
printf("pin-controller device not selected\n");
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
}
|
||||||
|
show_pinmux(currdev);
|
||||||
|
return CMD_RET_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc < 2 || strcmp(argv[1], "-a"))
|
if (strcmp(argv[1], "-a"))
|
||||||
return ret;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
uclass_foreach_dev_probe(UCLASS_PINCTRL, dev) {
|
uclass_foreach_dev_probe(UCLASS_PINCTRL, dev) {
|
||||||
/* insert a separator between each pin-controller display */
|
/* insert a separator between each pin-controller display */
|
||||||
printf("--------------------------\n");
|
printf("--------------------------\n");
|
||||||
printf("%s:\n", dev->name);
|
printf("%s:\n", dev->name);
|
||||||
ret = show_pinmux(dev);
|
show_pinmux(dev);
|
||||||
if (ret < 0)
|
|
||||||
printf("Can't display pin muxing for %s\n",
|
|
||||||
dev->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return CMD_RET_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_list(struct cmd_tbl *cmdtp, int flag, int argc,
|
static int do_list(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
|
|
@ -587,7 +587,7 @@ int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf,
|
||||||
*
|
*
|
||||||
* This allows to know the number of pins owned by a given pin-controller
|
* This allows to know the number of pins owned by a given pin-controller
|
||||||
*
|
*
|
||||||
* Return: Number of pins if OK, or negative error code on failure
|
* Return: Number of pins if OK, or -ENOSYS when not supported
|
||||||
*/
|
*/
|
||||||
int pinctrl_get_pins_count(struct udevice *dev);
|
int pinctrl_get_pins_count(struct udevice *dev);
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@ def test_pinmux_usage_1(u_boot_console):
|
||||||
@pytest.mark.buildconfigspec('cmd_pinmux')
|
@pytest.mark.buildconfigspec('cmd_pinmux')
|
||||||
def test_pinmux_usage_2(u_boot_console):
|
def test_pinmux_usage_2(u_boot_console):
|
||||||
"""Test that 'pinmux status' executed without previous "pinmux dev"
|
"""Test that 'pinmux status' executed without previous "pinmux dev"
|
||||||
command displays pinmux usage."""
|
command displays error message."""
|
||||||
output = u_boot_console.run_command('pinmux status')
|
output = u_boot_console.run_command('pinmux status')
|
||||||
assert 'Usage:' in output
|
assert 'pin-controller device not selected' in output
|
||||||
|
|
||||||
@pytest.mark.buildconfigspec('cmd_pinmux')
|
@pytest.mark.buildconfigspec('cmd_pinmux')
|
||||||
@pytest.mark.boardspec('sandbox')
|
@pytest.mark.boardspec('sandbox')
|
||||||
|
|
Loading…
Reference in a new issue