MFp4: Make iicbus_trasnfer_gen suitable for bridge drivers. Use it in the

bitbang bridge.
This commit is contained in:
Warner Losh 2007-03-23 23:03:54 +00:00
parent ee952d0ef6
commit 99a1402117
2 changed files with 11 additions and 5 deletions

View file

@ -94,6 +94,7 @@ static device_method_t iicbb_methods[] = {
DEVMETHOD(iicbus_write, iicbb_write),
DEVMETHOD(iicbus_read, iicbb_read),
DEVMETHOD(iicbus_reset, iicbb_reset),
DEVMETHOD(iicbus_transfer, iicbus_transfer_gen),
{ 0, 0 }
};
@ -421,6 +422,7 @@ DRIVER_MODULE(iicbb, ixpiic, iicbb_driver, iicbb_devclass, 0, 0);
DRIVER_MODULE(iicbb, lpbb, iicbb_driver, iicbb_devclass, 0, 0);
DRIVER_MODULE(iicbb, viapm, iicbb_driver, iicbb_devclass, 0, 0);
DRIVER_MODULE(iicbb, cxm_iic, iicbb_driver, iicbb_devclass, 0, 0);
DRIVER_MODULE(iicbb, at91_bbiic, iicbb_driver, iicbb_devclass, 0, 0);
MODULE_DEPEND(iicbb, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER);
MODULE_VERSION(iicbb, IICBB_MODVER);

View file

@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/bus.h>
@ -356,13 +357,16 @@ iicbus_transfer(device_t bus, struct iic_msg *msgs, uint32_t nmsgs)
* buffer addresses.
*/
int
iicbus_transfer_gen(device_t bus, struct iic_msg *msgs, uint32_t nmsgs)
iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
{
int i, error, max, lenread, lenwrote;
int i, error, lenread, lenwrote, nkid;
device_t *children, bus;
for (i = 0, max = 0; i < nmsgs; i++)
if (max < msgs[i].len)
max = msgs[i].len;
device_get_children(dev, &children, &nkid);
if (nkid != 1)
return EIO;
bus = children[0];
free(children, M_TEMP);
for (i = 0, error = 0; i < nmsgs && error == 0; i++) {
if (msgs[i].flags & IIC_M_RD)
error = iicbus_block_read(bus, msgs[i].slave,