freebsd-nq/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 o Add support for multi-port instances of Synopsys DesignWare APB GPIO 2019-09-04 15:37:24 +00:00
bytgpio.c Distinguish _CID match and _HID match and make lower priority probe 2018-10-26 00:05:46 +00:00
chvgpio_reg.h
chvgpio.c Distinguish _CID match and _HID match and make lower priority probe 2018-10-26 00:05:46 +00:00
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 Move most of the gpio_pin_* functions from ofw_gpiobus.c to gpiobus.c so 2019-12-01 21:27:09 +00:00
gpioc.c Fix typo: the 4th argument to GPIO_PIN_ACCESS_32 is the set of pins to 2019-04-25 22:27:56 +00:00
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 gpioled: add a new hint for initial state 2019-05-23 11:15:22 +00:00
gpiomdio.c Add a GPIO based MDIO bit-banging bus driver. 2019-12-06 20:21:07 +00:00
gpiopower.c
gpiopps.c Add PNP_INFO to the gpiopps driver. 2019-08-13 15:38:05 +00:00
gpioregulator.c Remove "all rights reserved" from copyright for the file that Jared McNeill 2019-12-03 21:05:33 +00:00
gpiospi.c
gpioths.c [gpioths] Fix GPIOTHS_DEBUG 2019-12-27 04:11:14 +00:00
ofw_gpiobus.c Move most of the gpio_pin_* functions from ofw_gpiobus.c to gpiobus.c so 2019-12-01 21:27:09 +00:00