[PATCH v4 19/21] dm: treewide: Do not use the return value of simple uclass iterator
Michal Suchanek
msuchanek at suse.de
Sun Sep 25 10:28:12 CEST 2022
uclass_first_device/uclass_next_device return value will be removed,
don't use it.
Signed-off-by: Michal Suchanek <msuchanek at suse.de>
---
cmd/virtio.c | 9 +++------
drivers/gpio/gpio-uclass.c | 14 ++++++--------
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/cmd/virtio.c b/cmd/virtio.c
index ea3ed2e631..f7a2ef4313 100644
--- a/cmd/virtio.c
+++ b/cmd/virtio.c
@@ -23,18 +23,15 @@ static int do_virtio(struct cmd_tbl *cmdtp, int flag, int argc,
* device_probe() for children (i.e. virtio devices)
*/
struct udevice *bus, *child;
- int ret;
- ret = uclass_first_device(UCLASS_VIRTIO, &bus);
- if (ret)
+ uclass_first_device(UCLASS_VIRTIO, &bus);
+ if (!bus)
return CMD_RET_FAILURE;
while (bus) {
device_foreach_child_probe(child, bus)
;
- ret = uclass_next_device(&bus);
- if (ret)
- break;
+ uclass_next_device(&bus);
}
return CMD_RET_SUCCESS;
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 0ed32b7217..3a35f1e30a 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -59,11 +59,10 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
{
struct gpio_dev_priv *uc_priv;
struct udevice *dev;
- int ret;
- for (ret = uclass_first_device(UCLASS_GPIO, &dev);
+ for (uclass_first_device(UCLASS_GPIO, &dev);
dev;
- ret = uclass_next_device(&dev)) {
+ uclass_next_device(&dev)) {
uc_priv = dev_get_uclass_priv(dev);
if (gpio >= uc_priv->gpio_base &&
gpio < uc_priv->gpio_base + uc_priv->gpio_count) {
@@ -73,7 +72,7 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
}
/* No such GPIO */
- return ret ? ret : -ENOENT;
+ return -ENOENT;
}
#if CONFIG_IS_ENABLED(DM_GPIO_LOOKUP_LABEL)
@@ -121,12 +120,11 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
struct udevice *dev;
ulong offset;
int numeric;
- int ret;
numeric = isdigit(*name) ? dectoul(name, NULL) : -1;
- for (ret = uclass_first_device(UCLASS_GPIO, &dev);
+ for (uclass_first_device(UCLASS_GPIO, &dev);
dev;
- ret = uclass_next_device(&dev)) {
+ uclass_next_device(&dev)) {
int len;
uc_priv = dev_get_uclass_priv(dev);
@@ -154,7 +152,7 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
}
if (!dev)
- return ret ? ret : -EINVAL;
+ return -EINVAL;
gpio_desc_init(desc, dev, offset);
--
2.37.3
More information about the U-Boot
mailing list