[RFC PATCH 0/1] gpio: Handle NULL pointers gracefully
Pratyush Yadav
p.yadav at ti.com
Sat May 30 00:03:54 CEST 2020
Hi,
Patch [0] added devm_gpiod_get_index_optional() which would return NULL
when when no GPIO was assigned to the requested function. This is
convenient for drivers that need to handle optional GPIOs.
We need to take a stance on who is responsible for the NULL check: the
driver or the GPIO core? Do we want to trust drivers to take care of the
NULL checks, or do we want to distrust them and make sure they don't
send us anything bogus in the GPIO core. Linux does not generally trust
drivers and usually verifies anything it gets from them. And FWIW, I see
that the clk and phy subsystems in U-Boot also perform checks like this.
The downside of the checks is of course that they increase code size.
They might also slightly decrease performance. The benefit is that we
don't burden drivers with taking care of this.
The patch itself is based on a similar patch by Jean-Jacques.
[0] https://patchwork.ozlabs.org/project/uboot/patch/20200529213808.2815-2-p.yadav@ti.com/
Pratyush Yadav (1):
gpio: Handle NULL pointers gracefully
drivers/gpio/Kconfig | 9 ++++
drivers/gpio/gpio-uclass.c | 86 ++++++++++++++++++++++++++++++++++----
include/asm-generic/gpio.h | 2 +-
3 files changed, 88 insertions(+), 9 deletions(-)
--
2.26.2
More information about the U-Boot
mailing list