PERFORCE change 111525 for review
Warner Losh
imp at FreeBSD.org
Mon Dec 11 19:26:29 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=111525
Change 111525 by imp at imp_lighthouse on 2006/12/12 03:25:53
MF FreeBSD-tsc-6:
o More generic description
o less verbose dmesg, unless bootverbose (this data should be
exported via sysctl)
o Initialize the lock
o don't do zero length read after the write to verify it succeeded.
This lead a lock leak in at91_twi (to be fixed separately).
MFP4 after: soon
Affected files ...
.. //depot/projects/arm/src/sys/dev/iicbus/icee.c#7 edit
Differences ...
==== //depot/projects/arm/src/sys/dev/iicbus/icee.c#7 (text+ko) ====
@@ -62,7 +62,7 @@
#define ICEE_LOCK(_sc) mtx_lock_spin(&(_sc)->sc_mtx)
#define ICEE_UNLOCK(_sc) mtx_unlock_spin(&(_sc)->sc_mtx)
#define ICEE_LOCK_INIT(_sc) \
- mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev), "icee", MTX_SPIN)
+ mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->sc_dev), "icee", MTX_SPIN)
#define ICEE_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx);
#define ICEE_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED);
#define ICEE_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED);
@@ -86,8 +86,8 @@
static int
icee_probe(device_t dev)
{
- /* XXX really probe? */
- device_set_desc(dev, "AT24C I2C EEPROM");
+ /* XXX really probe? -- not until we know the size... */
+ device_set_desc(dev, "I2C EEPROM");
return (0);
}
@@ -109,8 +109,9 @@
if (sc->rd_sz > MAX_RD_SZ)
sc->rd_sz = MAX_RD_SZ;
resource_int_value(dname, dunit, "wr_sz", &sc->wr_sz);
- device_printf(dev, "size: %d bytes bus_width: %d-bits\n", sc->size,
- sc->type);
+ if (bootverbose)
+ device_printf(dev, "size: %d bytes bus_width: %d-bits\n",
+ sc->size, sc->type);
sc->cdev = make_dev(&icee_cdevsw, device_get_unit(dev), UID_ROOT,
GID_WHEEL, 0600, "icee%d", device_get_unit(dev));
if (sc->cdev == NULL) {
@@ -118,6 +119,7 @@
goto out;
}
sc->cdev->si_drv1 = sc;
+ ICEE_LOCK_INIT(sc);
out:;
return (err);
}
@@ -212,11 +214,10 @@
icee_write(struct cdev *dev, struct uio *uio, int ioflag)
{
struct icee_softc *sc;
- int error, len, i, slave;
+ int error, len, slave;
uint8_t data[MAX_WR_SZ + 2];
- struct iic_msg msgs[3] = {
+ struct iic_msg msgs[1] = {
{ 0, IIC_M_WR, 0, data },
- { 0, IIC_M_RD, 0, data },
};
sc = CDEV2SOFTC(dev);
@@ -244,12 +245,11 @@
data[1] = uio->uio_offset & 0xff;
break;
}
- for (i = 0; i < 2; i++)
- msgs[i].slave = slave;
+ msgs[0].slave = slave;
error = uiomove(data + sc->type / 8, len, uio);
if (error)
break;
- error = iicbus_transfer(sc->sc_dev, msgs, 2);
+ error = iicbus_transfer(sc->sc_dev, msgs, 1);
if (error)
break;
}
More information about the p4-projects
mailing list