summaryrefslogtreecommitdiffstats
path: root/sys/dev/smbus/smb.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/smbus/smb.c')
-rw-r--r--sys/dev/smbus/smb.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/sys/dev/smbus/smb.c b/sys/dev/smbus/smb.c
index ca4fbe6..e5944bd 100644
--- a/sys/dev/smbus/smb.c
+++ b/sys/dev/smbus/smb.c
@@ -55,6 +55,7 @@ struct smb_softc {
#define IIC_DEVICE(unit) \
(devclass_get_device(smb_devclass, (unit)))
+static void smb_identify(driver_t *driver, device_t parent);
static int smb_probe(device_t);
static int smb_attach(device_t);
static int smb_detach(device_t);
@@ -63,6 +64,7 @@ static devclass_t smb_devclass;
static device_method_t smb_methods[] = {
/* device interface */
+ DEVMETHOD(device_identify, smb_identify),
DEVMETHOD(device_probe, smb_probe),
DEVMETHOD(device_attach, smb_attach),
DEVMETHOD(device_detach, smb_detach),
@@ -92,6 +94,14 @@ static struct cdevsw smb_cdevsw = {
.d_name = "smb",
};
+static void
+smb_identify(driver_t *driver, device_t parent)
+{
+
+ if (device_find_child(parent, "smb", -1) == NULL)
+ BUS_ADD_CHILD(parent, 0, "smb", -1);
+}
+
static int
smb_probe(device_t dev)
{
@@ -171,6 +181,7 @@ smbioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *t
device_t smbdev = IIC_DEVICE(minor(dev));
int error;
short w;
+ u_char count;
char c;
if (sc == NULL)
@@ -259,15 +270,17 @@ smbioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *t
}
break;
+ case SMB_OLD_BREAD:
case SMB_BREAD:
if (s->count && s->data.byte_ptr) {
- if (s->count > SMB_MAXBLOCKSIZE)
- s->count = SMB_MAXBLOCKSIZE;
+ count = min(s->count, SMB_MAXBLOCKSIZE);
error = smbus_error(smbus_bread(parent, s->slave,
- s->cmd, s->count, buf));
+ s->cmd, &count, buf));
if (error)
break;
- error = copyout(buf, s->data.byte_ptr, s->count);
+ error = copyout(buf, s->data.byte_ptr,
+ min(count, s->count));
+ s->count = count;
}
break;
OpenPOWER on IntegriCloud