svn commit: r308527 - head/sys/dev/smbus
Andriy Gapon
avg at FreeBSD.org
Fri Nov 11 14:41:03 UTC 2016
Author: avg
Date: Fri Nov 11 14:41:02 2016
New Revision: 308527
URL: https://svnweb.freebsd.org/changeset/base/308527
Log:
smb: fix SMB_READB, SMB_READW, SMB_PCALL to work as documented
Previously, those ioctls were defined as 'in' only, so rdata.byte and
rdata.word were never updated in the userland. The read data went only
to rbuf if it was provided. Thus, consumers were forced to always use it.
Now the ioctls are marked as in-out.
Compatibility handlers are provided for old ioctls.
PR: 213481
Reported by: Lewis Donzis <lew at perftech.com>
MFC after: 2 weeks
Relnotes: maybe
Differential Revision: https://reviews.freebsd.org/D8430
Modified:
head/sys/dev/smbus/smb.c
head/sys/dev/smbus/smb.h
Modified: head/sys/dev/smbus/smb.c
==============================================================================
--- head/sys/dev/smbus/smb.c Fri Nov 11 14:30:09 2016 (r308526)
+++ head/sys/dev/smbus/smb.c Fri Nov 11 14:41:02 2016 (r308527)
@@ -41,7 +41,9 @@
#include "smbus_if.h"
-#define BUFSIZE 1024
+#define SMB_OLD_READB _IOW('i', 7, struct smbcmd)
+#define SMB_OLD_READW _IOW('i', 8, struct smbcmd)
+#define SMB_OLD_PCALL _IOW('i', 9, struct smbcmd)
struct smb_softc {
device_t sc_dev;
@@ -224,7 +226,9 @@ smbioctl(struct cdev *dev, u_long cmd, c
s->cmd, s->wdata.word));
break;
+ case SMB_OLD_READB:
case SMB_READB:
+ /* NB: for SMB_OLD_READB the read data goes to rbuf only. */
error = smbus_error(smbus_readb(parent, s->slave, s->cmd,
&s->rdata.byte));
if (error)
@@ -235,7 +239,9 @@ smbioctl(struct cdev *dev, u_long cmd, c
}
break;
+ case SMB_OLD_READW:
case SMB_READW:
+ /* NB: for SMB_OLD_READW the read data goes to rbuf only. */
error = smbus_error(smbus_readw(parent, s->slave, s->cmd,
&s->rdata.word));
if (error)
@@ -248,7 +254,9 @@ smbioctl(struct cdev *dev, u_long cmd, c
}
break;
+ case SMB_OLD_PCALL:
case SMB_PCALL:
+ /* NB: for SMB_OLD_PCALL the read data goes to rbuf only. */
error = smbus_error(smbus_pcall(parent, s->slave, s->cmd,
s->wdata.word, &s->rdata.word));
if (error)
Modified: head/sys/dev/smbus/smb.h
==============================================================================
--- head/sys/dev/smbus/smb.h Fri Nov 11 14:30:09 2016 (r308526)
+++ head/sys/dev/smbus/smb.h Fri Nov 11 14:41:02 2016 (r308527)
@@ -63,11 +63,10 @@ struct smbcmd {
#define SMB_RECVB _IOWR('i', 4, struct smbcmd)
#define SMB_WRITEB _IOW('i', 5, struct smbcmd)
#define SMB_WRITEW _IOW('i', 6, struct smbcmd)
-#define SMB_READB _IOW('i', 7, struct smbcmd)
-#define SMB_READW _IOW('i', 8, struct smbcmd)
-#define SMB_PCALL _IOW('i', 9, struct smbcmd)
+#define SMB_READB _IOWR('i', 7, struct smbcmd)
+#define SMB_READW _IOWR('i', 8, struct smbcmd)
+#define SMB_PCALL _IOWR('i', 9, struct smbcmd)
#define SMB_BWRITE _IOW('i', 10, struct smbcmd)
-#define SMB_OLD_BREAD _IOW('i', 11, struct smbcmd)
#define SMB_BREAD _IOWR('i', 11, struct smbcmd)
#define SMB_OLD_TRANS _IOWR('i', 12, struct smbcmd)
More information about the svn-src-head
mailing list