summaryrefslogtreecommitdiff
path: root/drivers/serial
diff options
context:
space:
mode:
authorMichal Suchanek <[email protected]>2022-10-12 21:57:59 +0200
committerSimon Glass <[email protected]>2022-10-17 21:17:12 -0600
commitc726fc01cf669e3e2979da8665ef660e7d3ba464 (patch)
tree5d11dc2d0e58fac8a08cb1e2425ff0ae10ad0a8a /drivers/serial
parent8676ae36ae4617b20b5cc49972c54c63c7b27bb3 (diff)
dm: treewide: Use uclass_first_device_err when accessing one device
There is a number of users that use uclass_first_device to access the first and (assumed) only device in uclass. Some check the return value of uclass_first_device and also that a device was returned which is exactly what uclass_first_device_err does. Some are not checking that a device was returned and can potentially crash if no device exists in the uclass. Finally there is one that returns NULL on error either way. Convert all of these to use uclass_first_device_err instead, the return value will be removed from uclass_first_device in a later patch. Signed-off-by: Michal Suchanek <[email protected]> Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/serial-uclass.c2
-rw-r--r--drivers/serial/serial_bcm283x_mu.c2
-rw-r--r--drivers/serial/serial_bcm283x_pl011.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index da3e1eb3ab1..83cda1f2040 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -143,7 +143,7 @@ static void serial_find_console_or_panic(void)
#else
if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) ||
!uclass_get_device(UCLASS_SERIAL, INDEX, &dev) ||
- (!uclass_first_device(UCLASS_SERIAL, &dev) && dev)) {
+ !uclass_first_device_err(UCLASS_SERIAL, &dev)) {
gd->cur_serial_dev = dev;
return;
}
diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c
index 493a42b4ccc..12cbcb9858c 100644
--- a/drivers/serial/serial_bcm283x_mu.c
+++ b/drivers/serial/serial_bcm283x_mu.c
@@ -147,7 +147,7 @@ static bool bcm283x_is_serial_muxed(void)
int serial_gpio = 15;
struct udevice *dev;
- if (uclass_first_device(UCLASS_PINCTRL, &dev) || !dev)
+ if (uclass_first_device_err(UCLASS_PINCTRL, &dev))
return false;
if (pinctrl_get_gpio_mux(dev, 0, serial_gpio) != BCM2835_GPIO_ALT5)
diff --git a/drivers/serial/serial_bcm283x_pl011.c b/drivers/serial/serial_bcm283x_pl011.c
index fe746294cdc..7d172cdac0a 100644
--- a/drivers/serial/serial_bcm283x_pl011.c
+++ b/drivers/serial/serial_bcm283x_pl011.c
@@ -24,7 +24,7 @@ static bool bcm283x_is_serial_muxed(void)
int serial_gpio = 15;
struct udevice *dev;
- if (uclass_first_device(UCLASS_PINCTRL, &dev) || !dev)
+ if (uclass_first_device_err(UCLASS_PINCTRL, &dev))
return false;
if (pinctrl_get_gpio_mux(dev, 0, serial_gpio) != BCM2835_GPIO_ALT0)