Defer attaching and probing iicbus and its children until interrupts are
available, in i2c controller drivers that require interrupts for transfers. This is the result of auditing all 22 existing drivers that attach iicbus. These drivers were the only ones remaining that require interrupts and were not using config_intrhook to defer attachment. That has led, over the years, to various i2c slave device drivers needing to use config_intrhook themselves rather than performing bus transactions in their probe() and attach() methods, just in case they were attached too early.
This commit is contained in:
parent
100db364eb
commit
1e4042d44e
@ -160,8 +160,8 @@ at91_twi_attach(device_t dev)
|
||||
|
||||
if ((sc->iicbus = device_add_child(dev, "iicbus", -1)) == NULL)
|
||||
device_printf(dev, "could not allocate iicbus instance\n");
|
||||
/* probe and attach the iicbus */
|
||||
bus_generic_attach(dev);
|
||||
/* Probe and attach the iicbus when interrupts are available. */
|
||||
config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
|
||||
out:
|
||||
if (err)
|
||||
at91_twi_deactivate(dev);
|
||||
|
@ -309,7 +309,10 @@ bcm_bsc_attach(device_t dev)
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
return (bus_generic_attach(dev));
|
||||
/* Probe and attach the iicbus when interrupts are available. */
|
||||
config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -443,7 +443,8 @@ i2c_attach(device_t dev)
|
||||
|
||||
/* We don't do a hardware reset here because iicbus_attach() does it. */
|
||||
|
||||
bus_generic_attach(dev);
|
||||
/* Probe and attach the iicbus when interrupts are available. */
|
||||
config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -37,11 +37,6 @@
|
||||
* incorporate that sometime in the future. The idea being that for transaction
|
||||
* larger than a certain size the DMA engine is used, for anything less the
|
||||
* normal interrupt/fifo driven option is used.
|
||||
*
|
||||
*
|
||||
* WARNING: This driver uses mtx_sleep and interrupts to perform transactions,
|
||||
* which means you can't do a transaction during startup before the interrupts
|
||||
* have been enabled. Hint - the freebsd function config_intrhook_establish().
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
@ -909,8 +904,8 @@ ti_i2c_attach(device_t dev)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Probe and attach the iicbus */
|
||||
bus_generic_attach(dev);
|
||||
/* Probe and attach the iicbus when interrupts are available. */
|
||||
config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
|
||||
|
||||
out:
|
||||
if (err) {
|
||||
|
@ -408,11 +408,10 @@ glxiic_attach(device_t dev)
|
||||
glxiic_gpio_enable(sc);
|
||||
glxiic_smb_enable(sc, IIC_FASTEST, 0);
|
||||
|
||||
error = bus_generic_attach(dev);
|
||||
if (error != 0) {
|
||||
device_printf(dev, "Could not probe and attach children\n");
|
||||
error = ENXIO;
|
||||
}
|
||||
/* Probe and attach the iicbus when interrupts are available. */
|
||||
config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev);
|
||||
error = 0;
|
||||
|
||||
out:
|
||||
if (error != 0) {
|
||||
callout_drain(&sc->callout);
|
||||
|
Loading…
Reference in New Issue
Block a user