Fix smbus allocation and add the alsmb (see alpm(4)) driver.

This commit is contained in:
nsouch 1999-02-13 17:57:19 +00:00
parent 59a9f956c6
commit d31dc3808a
4 changed files with 29 additions and 18 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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

View File

@ -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);