From b3dd2b7bfc7ad38602dfc00a784a4e7c97a067c2 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Mon, 17 May 2004 18:55:45 +0000 Subject: [PATCH] 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 --- sys/dev/smbus/smb.c | 59 ++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/sys/dev/smbus/smb.c b/sys/dev/smbus/smb.c index 47a159a443f..c8edb938605 100644 --- a/sys/dev/smbus/smb.c +++ b/sys/dev/smbus/smb.c @@ -24,8 +24,8 @@ * SUCH DAMAGE. * * $FreeBSD$ - * */ + #include #include #include @@ -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,50 +157,38 @@ 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--; return (0); } -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);