[PATCH v5 10/15] dm: treewide: Use uclass_first_device_err when accessing one device
Simon Glass
sjg at chromium.org
Thu Sep 29 12:00:44 CEST 2022
On Tue, 27 Sept 2022 at 15:38, Michal Suchanek <msuchanek at suse.de> wrote:
>
> 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.
>
> Also print the symbolic error when the return value is printed.
>
> Signed-off-by: Michal Suchanek <msuchanek at suse.de>
> ---
> arch/arm/mach-omap2/am33xx/board.c | 4 ++--
> arch/x86/cpu/broadwell/cpu.c | 4 +---
> arch/x86/cpu/intel_common/cpu.c | 4 +---
> arch/x86/lib/pinctrl_ich6.c | 4 +---
> board/intel/cougarcanyon2/cougarcanyon2.c | 4 +---
> drivers/mmc/omap_hsmmc.c | 2 +-
> drivers/serial/serial-uclass.c | 2 +-
> drivers/serial/serial_bcm283x_mu.c | 2 +-
> drivers/serial/serial_bcm283x_pl011.c | 2 +-
> drivers/sysreset/sysreset_ast.c | 2 +-
> drivers/video/exynos/exynos_fb.c | 24 ++++++++++-------------
> drivers/video/mali_dp.c | 2 +-
> drivers/video/stm32/stm32_dsi.c | 6 ++++--
> drivers/video/tegra124/dp.c | 7 ++++---
> lib/acpi/acpi_table.c | 2 +-
> lib/efi_loader/efi_gop.c | 2 +-
> net/eth-uclass.c | 4 ++--
> test/boot/bootmeth.c | 2 +-
> test/dm/acpi.c | 14 ++++++-------
> test/dm/devres.c | 4 ++--
> test/dm/i2c.c | 8 ++++----
> test/dm/virtio_device.c | 8 ++++----
> test/dm/virtio_rng.c | 2 +-
> test/fuzz/cmd_fuzz.c | 2 +-
> test/fuzz/virtio.c | 2 +-
> 25 files changed, 55 insertions(+), 64 deletions(-)
With the errno change dropped:
Reviewed-by: Simon Glass <sjg at chromium.org>
More information about the U-Boot
mailing list