summaryrefslogtreecommitdiff
path: root/sysutils/xmbmon/files/patch-getMB-smb_ioctl.c
blob: e6df0d911706b5abbf9ddd06a3f2982e553bf3fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
--- getMB-smb_ioctl.c.orig	2003-07-05 15:15:24 UTC
+++ getMB-smb_ioctl.c
@@ -5,6 +5,7 @@
 #ifdef HAVE_SMBUS
 /* assume SMBus ioctl support, only for FreeBSD */
 
+#include <sys/param.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -13,7 +14,11 @@
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
+#if __FreeBSD_version >= 500000
+#include <dev/smbus/smb.h>
+#else
 #include <machine/smb.h>
+#endif
 
 #include "methods.h"
 
@@ -42,10 +47,12 @@ static char buf[128];
 
 static int OpenIO()
 {
-	char byte;
 	struct smbcmd cmd;
 	cmd.slave = smb_slave;
+#if (__FreeBSD_version < 1100071)
+	char byte;
 	cmd.data.byte_ptr = &byte;
+#endif
 
 	if ((iosmb = open(smb_devfile, 000)) < 0) {
 		strcpy(buf, "ioctl(");
@@ -125,7 +132,12 @@ int smbioctl_readB(int slave, int addr)
 	char ret;
 	cmd.slave = slave;
 	cmd.cmd = addr;
+#if (__FreeBSD_version >= 1100071)
+	cmd.rbuf = &ret;
+	cmd.rcount = 1;
+#else
 	cmd.data.byte_ptr = &ret;
+#endif
 	if (ioctl(iosmb, SMB_READB, &cmd) == -1) {
 /*		strcpy(buf, "ioctl(");
 		strcat(buf, smb_devfile + 5);
@@ -142,7 +154,11 @@ void smbioctl_writeB(int slave, int addr
 	struct smbcmd cmd;
 	cmd.slave = slave;
 	cmd.cmd = addr;
+#if (__FreeBSD_version >= 1100071)
+	cmd.wdata.byte = value;
+#else
 	cmd.data.byte = value;
+#endif
 	if (ioctl(iosmb, SMB_WRITEB, &cmd) == -1) {
 		strcpy(buf, "ioctl(");
 		strcat(buf, smb_devfile + 5);
@@ -158,7 +174,12 @@ int smbioctl_readW(int smb_slave, int ad
 	short ret;
 	cmd.slave = smb_slave;
 	cmd.cmd = addr;
+#if (__FreeBSD_version >= 1100071)
+	cmd.rbuf = (char*) &ret;
+	cmd.rcount = 2;
+#else
 	cmd.data.word_ptr = &ret;
+#endif
 	if (ioctl(iosmb, SMB_READW, &cmd) == -1) {
 /*		strcpy(buf, "ioctl(");
 		strcat(buf, smb_devfile + 5);
@@ -175,7 +196,11 @@ void smbioctl_writeW(int slave, int addr
 	struct smbcmd cmd;
 	cmd.slave = slave;
 	cmd.cmd = addr;
+#if (__FreeBSD_version >= 1100071)
+	cmd.wdata.word = value;
+#else
 	cmd.data.word = value;
+#endif
 	if (ioctl(iosmb, SMB_WRITEW, &cmd) == -1) {
 		strcpy(buf, "ioctl(");
 		strcat(buf, smb_devfile + 5);