freebsd-skq/sys/dev/gpio
Andriy Gapon 20077ec02c gpioiic_attach: fix a NULL pointer crash on hints-based systems
The attach method uses GPIO_GET_BUS() to get a "newbus" device
that provides a pin.  But on hints-based systems a GPIO controller
driver might not be fully initialized yet and it does not know gpiobus
hanging off it.  Thus, GPIO_GET_BUS() cannot be called yet.
The reason is that controller drivers typically create a child gpiobus
using gpiobus_attach_bus() and that leads to the following call chain:
gpiobus_attach_bus() -> gpiobus_attach() ->
bus_generic_attach(gpiobus) -> gpioiic_attach().
So, gpioiic_attach() is called before gpiobus_attach_bus() returns.

I observed this bug with nctgpio driver on amd64.
I think that the problem was introduced in r355276.

The fix is to avoid calling GPIO_GET_BUS() from the attach method.
Instead, we know that on hints-based systems only the parent gpiobus can
provide the pins.
Nothing is changed for FDT-based systems.

MFC after:	1 week
2020-05-07 13:11:32 +00:00
..
dwgpio
bytgpio.c
chvgpio_reg.h
chvgpio.c
gpio_if.m
gpiobacklight.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
gpiobus_if.m
gpiobus.c Implement bus_rescan for gpiobus(4). This allows on-the-fly reconfiguration 2019-12-06 22:32:06 +00:00
gpiobusvar.h
gpioc.c
gpioiic.c gpioiic_attach: fix a NULL pointer crash on hints-based systems 2020-05-07 13:11:32 +00:00
gpiokeys_codes.c
gpiokeys.c Revert r355806: kbd drivers: don't double register keyboard drivers 2019-12-26 17:09:36 +00:00
gpiokeys.h
gpioled_fdt.c
gpioled.c
gpiomdio.c
gpiopower.c
gpiopps.c
gpioregulator.c
gpiospi.c
gpioths.c [gpioths] Fix GPIOTHS_DEBUG 2019-12-27 04:11:14 +00:00
ofw_gpiobus.c