summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authornsouch <nsouch@FreeBSD.org>1999-02-13 17:57:19 +0000
committernsouch <nsouch@FreeBSD.org>1999-02-13 17:57:19 +0000
commitb54915a02a005ac44ae03d3389cbd4bb9eb36eb0 (patch)
tree37871233440dda9b3049179b011bef26a64be298 /sys
parent9c9f54385422ba14291ad62aa195016e871d5b8a (diff)
downloadFreeBSD-src-b54915a02a005ac44ae03d3389cbd4bb9eb36eb0.zip
FreeBSD-src-b54915a02a005ac44ae03d3389cbd4bb9eb36eb0.tar.gz
Fix smbus allocation and add the alsmb (see alpm(4)) driver.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/smbus/smb.c18
-rw-r--r--sys/dev/smbus/smbconf.c17
-rw-r--r--sys/dev/smbus/smbconf.h8
-rw-r--r--sys/dev/smbus/smbus.c4
4 files changed, 29 insertions, 18 deletions
diff --git a/sys/dev/smbus/smb.c b/sys/dev/smbus/smb.c
index b5d2919..a26f3fa 100644
--- a/sys/dev/smbus/smb.c
+++ b/sys/dev/smbus/smb.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: smb.c,v 1.5 1999/01/09 18:08:23 nsouch Exp $
+ * $Id: smb.c,v 1.6 1999/01/14 22:55:03 nsouch Exp $
*
*/
#include <sys/param.h>
@@ -35,6 +35,7 @@
#include <sys/buf.h>
#include <sys/uio.h>
#include <sys/malloc.h>
+#include <sys/fcntl.h>
#include <machine/clock.h>
@@ -183,17 +184,20 @@ smbioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
if (!sc || !s)
return (EINVAL);
+ /* allocate the bus */
+ if ((error = smbus_request_bus(parent, smbdev,
+ (flags & O_NONBLOCK) ? SMB_DONTWAIT : (SMB_WAIT | SMB_INTR))))
+ return (error);
+
switch (cmd) {
case SMB_QUICK_WRITE:
error=smbus_quick(parent, s->slave, SMB_QWRITE);
- goto end;
+ break;
case SMB_QUICK_READ:
error=smbus_quick(parent, s->slave, SMB_QREAD);
- goto end;
- };
+ break;
- switch (cmd) {
case SMB_SENDB:
error=smbus_sendb(parent, s->slave, s->cmd);
break;
@@ -243,7 +247,9 @@ smbioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
error = ENODEV;
}
-end:
+ /* release the bus */
+ smbus_release_bus(parent, smbdev);
+
return (error);
}
diff --git a/sys/dev/smbus/smbconf.c b/sys/dev/smbus/smbconf.c
index 458916f..1e7d8c4 100644
--- a/sys/dev/smbus/smbconf.c
+++ b/sys/dev/smbus/smbconf.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: smbconf.c,v 1.3 1998/11/22 22:01:42 nsouch Exp $
+ * $Id: smbconf.c,v 1.4 1999/01/09 18:08:23 nsouch Exp $
*
*/
#include <sys/param.h>
@@ -104,16 +104,12 @@ smbus_request_bus(device_t bus, device_t dev, int how)
int s, error = 0;
/* first, ask the underlying layers if the request is ok */
- do {
- error = SMBUS_CALLBACK(device_get_parent(bus),
- SMB_REQUEST_BUS, (caddr_t)&how);
- if (error)
- error = smbus_poll(sc, how);
- } while (error);
+ error = SMBUS_CALLBACK(device_get_parent(bus), SMB_REQUEST_BUS,
+ (caddr_t)&how);
while (!error) {
s = splhigh();
- if (sc->owner) {
+ if (sc->owner && sc->owner != dev) {
splx(s);
error = smbus_poll(sc, how);
@@ -123,6 +119,11 @@ smbus_request_bus(device_t bus, device_t dev, int how)
splx(s);
return (0);
}
+
+ /* free any allocated resource */
+ if (error)
+ SMBUS_CALLBACK(device_get_parent(bus), SMB_RELEASE_BUS,
+ (caddr_t)&how);
}
return (error);
diff --git a/sys/dev/smbus/smbconf.h b/sys/dev/smbus/smbconf.h
index 3c06489..c5fca85 100644
--- a/sys/dev/smbus/smbconf.h
+++ b/sys/dev/smbus/smbconf.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: smbconf.h,v 1.2 1998/10/31 11:39:54 nsouch Exp $
+ * $Id: smbconf.h,v 1.3 1999/01/27 19:58:53 dillon Exp $
*/
#ifndef __SMBONF_H
#define __SMBONF_H
@@ -54,7 +54,11 @@
#define SMB_ENOERR 0x0
#define SMB_EBUSERR 0x1
#define SMB_ENOTSUPP 0x2
-#define SMB_ENOACK 0x3
+#define SMB_ENOACK 0x4
+#define SMB_ECOLLI 0x8
+#define SMB_EABORT 0x10
+#define SMB_ETIMEOUT 0x20
+#define SMB_EBUSY 0x40
/*
* How Quick command is executed
diff --git a/sys/dev/smbus/smbus.c b/sys/dev/smbus/smbus.c
index ca06710..4171a0f 100644
--- a/sys/dev/smbus/smbus.c
+++ b/sys/dev/smbus/smbus.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: smbus.c,v 1.6 1998/12/28 19:07:51 nsouch Exp $
+ * $Id: smbus.c,v 1.7 1999/01/09 18:08:24 nsouch Exp $
*
*/
#include <sys/param.h>
@@ -159,4 +159,4 @@ smbus_read_ivar(device_t bus, device_t dev, int index, u_long* result)
DRIVER_MODULE(smbus, iicsmb, smbus_driver, smbus_devclass, 0, 0);
DRIVER_MODULE(smbus, bti2c, smbus_driver, smbus_devclass, 0, 0);
DRIVER_MODULE(smbus, intsmb, smbus_driver, smbus_devclass, 0, 0);
-DRIVER_MODULE(smbus, smbv, smbus_driver, smbus_devclass, 0, 0);
+DRIVER_MODULE(smbus, alsmb, smbus_driver, smbus_devclass, 0, 0);
OpenPOWER on IntegriCloud