Date: Tue, 21 Nov 2006 16:19:38 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 110339 for review Message-ID: <200611211619.kALGJcB2046197@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=110339 Change 110339 by imp@imp_lighthouse on 2006/11/21 15:29:12 oops, on read copyout, not write. Affected files ... .. //depot/projects/arm/src/sys/dev/iicbus/iic.c#7 edit Differences ... ==== //depot/projects/arm/src/sys/dev/iicbus/iic.c#7 (text+ko) ==== @@ -246,13 +246,15 @@ char *buf = NULL; void **usrbufs = NULL; - if (!sc) - return (EINVAL); + if (!sc) { printf("iic einval\n"); + return (EINVAL); } if ((error = iicbus_request_bus(device_get_parent(iicdev), iicdev, (flags & O_NONBLOCK) ? IIC_DONTWAIT : - (IIC_WAIT | IIC_INTR)))) + (IIC_WAIT | IIC_INTR)))) { + printf("bus request failed %d\n", error); return (error); + } switch (cmd) { case I2CSTART: @@ -310,18 +312,12 @@ case I2CRDWR: buf = malloc(sizeof(*d->msgs) * d->nmsgs, M_TEMP, M_WAITOK); - if (buf == NULL) { - error = ENOMEM; - break; - } usrbufs = malloc(sizeof(void *) * d->nmsgs, M_TEMP, M_ZERO | M_WAITOK); - if (usrbufs == NULL) { - error = ENOMEM; + error = copyin(d->msgs, buf, sizeof(*d->msgs) * d->nmsgs); + if (error) { + printf("copying returns %d\n", error); break; } - error = copyin(d->msgs, buf, sizeof(*d->msgs) * d->nmsgs); - if (error) - break; /* Allocate kernel buffers for userland data, copyin write data */ for (i = 0; i < d->nmsgs; i++) { m = &((struct iic_msg *)buf)[i]; @@ -331,10 +327,11 @@ copyin(usrbufs[i], m->buf, m->len); } error = iicbus_transfer(parent, (struct iic_msg *)buf, d->nmsgs); + printf("transfer returns %d\n", error); /* Copyout all read segments, free up kernel buffers */ for (i = 0; i < d->nmsgs; i++) { m = &((struct iic_msg *)buf)[i]; - if (!(m->flags & IIC_M_RD)) + if (m->flags & IIC_M_RD) copyout(m->buf, usrbufs[i], m->len); free(m->buf, M_TEMP); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611211619.kALGJcB2046197>