diff options
author | joerg <joerg@FreeBSD.org> | 2004-05-17 18:55:45 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 2004-05-17 18:55:45 +0000 |
commit | 54a0a97b3417f27d633ad44a756501c3e720a461 (patch) | |
tree | a8f0a96edca681f9cb13d88b87b38d45261c3fc8 /sys/dev/smbus | |
parent | 120eb398897894be74030773fc9d38d5146d65fb (diff) | |
download | FreeBSD-src-54a0a97b3417f27d633ad44a756501c3e720a461.zip FreeBSD-src-54a0a97b3417f27d633ad44a756501c3e720a461.tar.gz |
Fix various style(9) bugs. This includes the removal of wrong
reimplementations of enodev() (for the smbread() and smbwrite()
functions), as well as fixing various errno values to conform to
errno(3).
Bruce also points out that a number of the pointer == NULL tests
are probably nonsense because the respective checks are already
done at upper layers.
(Mostly) submitted by: bde
Diffstat (limited to 'sys/dev/smbus')
-rw-r--r-- | sys/dev/smbus/smb.c | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/sys/dev/smbus/smb.c b/sys/dev/smbus/smb.c index 47a159a..c8edb93 100644 --- a/sys/dev/smbus/smb.c +++ b/sys/dev/smbus/smb.c @@ -24,8 +24,8 @@ * SUCH DAMAGE. * * $FreeBSD$ - * */ + #include <sys/param.h> #include <sys/kernel.h> #include <sys/systm.h> @@ -83,8 +83,6 @@ static driver_t smb_driver = { static d_open_t smbopen; static d_close_t smbclose; -static d_write_t smbwrite; -static d_read_t smbread; static d_ioctl_t smbioctl; static struct cdevsw smb_cdevsw = { @@ -92,8 +90,6 @@ static struct cdevsw smb_cdevsw = { .d_flags = D_NEEDGIANT, .d_open = smbopen, .d_close = smbclose, - .d_read = smbread, - .d_write = smbwrite, .d_ioctl = smbioctl, .d_name = "smb", }; @@ -145,10 +141,10 @@ smbopen (dev_t dev, int flags, int fmt, struct thread *td) { struct smb_softc *sc = IIC_SOFTC(minor(dev)); - if (!sc) - return (EINVAL); + if (sc == NULL) + return (ENXIO); - if (sc->sc_count) + if (sc->sc_count != 0) return (EBUSY); sc->sc_count++; @@ -161,11 +157,12 @@ smbclose(dev_t dev, int flags, int fmt, struct thread *td) { struct smb_softc *sc = IIC_SOFTC(minor(dev)); - if (!sc) - return (EINVAL); + if (sc == NULL) + return (ENXIO); - if (!sc->sc_count) - return (EINVAL); + if (sc->sc_count == 0) + /* This is not supposed to happen. */ + return (0); sc->sc_count--; @@ -173,38 +170,25 @@ smbclose(dev_t dev, int flags, int fmt, struct thread *td) } static int -smbwrite(dev_t dev, struct uio * uio, int ioflag) -{ - /* not supported */ - - return (EINVAL); -} - -static int -smbread(dev_t dev, struct uio * uio, int ioflag) -{ - /* not supported */ - - return (EINVAL); -} - -static int smbioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) { - device_t smbdev = IIC_DEVICE(minor(dev)); - struct smb_softc *sc = IIC_SOFTC(minor(dev)); - device_t parent = device_get_parent(smbdev); char buf[SMB_MAXBLOCKSIZE]; - char c; - short w; - - int error = 0; + device_t parent; struct smbcmd *s = (struct smbcmd *)data; + struct smb_softc *sc = IIC_SOFTC(minor(dev)); + device_t smbdev = IIC_DEVICE(minor(dev)); + int error; + short w; + char c; - if (!sc || !s) + if (sc == NULL) + return (ENXIO); + if (s == NULL) return (EINVAL); - /* allocate the bus */ + parent = device_get_parent(smbdev); + + /* Allocate the bus. */ if ((error = smbus_request_bus(parent, smbdev, (flags & O_NONBLOCK) ? SMB_DONTWAIT : (SMB_WAIT | SMB_INTR)))) return (error); @@ -299,7 +283,6 @@ smbioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) error = ENOTTY; } - /* release the bus */ smbus_release_bus(parent, smbdev); return (error); |