Date: Tue, 17 Feb 2015 20:29:43 +0000 (UTC) From: Luiz Otavio O Souza <loos@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278918 - head/sys/dev/iicbus Message-ID: <201502172029.t1HKThAd017436@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: loos Date: Tue Feb 17 20:29:42 2015 New Revision: 278918 URL: https://svnweb.freebsd.org/changeset/base/278918 Log: Replace hardcoded sizes by sizeof() and nitems(). Set all the sysctls as CTLFLAG_MPSAFE. Modified: head/sys/dev/iicbus/lm75.c Modified: head/sys/dev/iicbus/lm75.c ============================================================================== --- head/sys/dev/iicbus/lm75.c Tue Feb 17 20:08:40 2015 (r278917) +++ head/sys/dev/iicbus/lm75.c Tue Feb 17 20:29:42 2015 (r278918) @@ -134,7 +134,7 @@ lm75_read(device_t dev, uint32_t addr, u { addr, IIC_M_RD, len, data }, }; - if (iicbus_transfer(dev, msg, 2) != 0) + if (iicbus_transfer(dev, msg, nitems(msg)) != 0) return (-1); return (0); @@ -147,7 +147,7 @@ lm75_write(device_t dev, uint32_t addr, { addr, IIC_M_WR, len, data }, }; - if (iicbus_transfer(dev, msg, 1) != 0) + if (iicbus_transfer(dev, msg, nitems(msg)) != 0) return (-1); return (0); @@ -228,7 +228,8 @@ lm75_type_detect(struct lm75_softc *sc) */ lm75a = 0; for (i = 4; i <= 6; i++) { - if (lm75_read(sc->sc_dev, sc->sc_addr, i, &buf8, 1) < 0) + if (lm75_read(sc->sc_dev, sc->sc_addr, i, + &buf8, sizeof(buf8)) < 0) return (-1); if (buf8 != LM75_TEST_PATTERN && buf8 != 0xff) return (-1); @@ -288,16 +289,16 @@ lm75_start(void *xdev) /* Configuration parameters. */ SYSCTL_ADD_PROC(ctx, tree, OID_AUTO, "faults", - CTLFLAG_RW | CTLTYPE_UINT, dev, 0, + CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_MPSAFE, dev, 0, lm75_faults_sysctl, "IU", "LM75 fault queue"); SYSCTL_ADD_PROC(ctx, tree, OID_AUTO, "mode", - CTLFLAG_RW | CTLTYPE_STRING, dev, 0, + CTLFLAG_RW | CTLTYPE_STRING | CTLFLAG_MPSAFE, dev, 0, lm75_mode_sysctl, "A", "LM75 mode"); SYSCTL_ADD_PROC(ctx, tree, OID_AUTO, "polarity", - CTLFLAG_RW | CTLTYPE_STRING, dev, 0, + CTLFLAG_RW | CTLTYPE_STRING | CTLFLAG_MPSAFE, dev, 0, lm75_pol_sysctl, "A", "LM75 OS polarity"); SYSCTL_ADD_PROC(ctx, tree, OID_AUTO, "shutdown", - CTLFLAG_RW | CTLTYPE_UINT, dev, 0, + CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_MPSAFE, dev, 0, lm75_shutdown_sysctl, "IU", "LM75 shutdown"); } @@ -306,9 +307,9 @@ lm75_conf_read(struct lm75_softc *sc) { uint8_t buf8; - if (lm75_read(sc->sc_dev, sc->sc_addr, LM75_CONF, &buf8, 1) < 0) + if (lm75_read(sc->sc_dev, sc->sc_addr, LM75_CONF, + &buf8, sizeof(buf8)) < 0) return (-1); - sc->sc_conf = (uint32_t)buf8; return (0); @@ -321,8 +322,7 @@ lm75_conf_write(struct lm75_softc *sc) buf8[0] = LM75_CONF; buf8[1] = (uint8_t)sc->sc_conf & LM75_CONF_MASK; - - if (lm75_write(sc->sc_dev, sc->sc_addr, buf8, 2) < 0) + if (lm75_write(sc->sc_dev, sc->sc_addr, buf8, sizeof(buf8)) < 0) return (-1); return (0); @@ -335,7 +335,7 @@ lm75_temp_read(struct lm75_softc *sc, ui uint16_t buf; int neg, t; - if (lm75_read(sc->sc_dev, sc->sc_addr, reg, buf8, 2) < 0) + if (lm75_read(sc->sc_dev, sc->sc_addr, reg, buf8, sizeof(buf8)) < 0) return (-1); buf = (uint16_t)((buf8[0] << 8) | (buf8[1] & 0xff)); /* @@ -388,8 +388,7 @@ lm75_temp_write(struct lm75_softc *sc, u buf8[0] = reg; buf8[1] = buf >> 8; buf8[2] = buf & 0xff; - - if (lm75_write(sc->sc_dev, sc->sc_addr, buf8, 3) < 0) + if (lm75_write(sc->sc_dev, sc->sc_addr, buf8, sizeof(buf8)) < 0) return (-1); return (0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502172029.t1HKThAd017436>