summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-04-17 16:50:18 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-04-17 16:50:18 +0000
commit7d4b1c6f2891eacf9056f14e8d50e8cc4aba0bc0 (patch)
tree40db592f63f787f75a61e0a35eeebf1f30912af6 /sys
parent05acceafeafbcb8c02684e95005cee2e7b439931 (diff)
use sizeof(thing) instead of hard-coding it
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/i2c/pca9532.c14
-rw-r--r--sys/dev/i2c/rs5c372.c14
2 files changed, 14 insertions, 14 deletions
diff --git a/sys/dev/i2c/pca9532.c b/sys/dev/i2c/pca9532.c
index f26b2007569..15635a7f500 100644
--- a/sys/dev/i2c/pca9532.c
+++ b/sys/dev/i2c/pca9532.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pca9532.c,v 1.2 2006/06/17 23:00:47 drahn Exp $ */
+/* $OpenBSD: pca9532.c,v 1.3 2008/04/17 16:50:17 deraadt Exp $ */
/*
* Copyright (c) 2006 Dale Rahn <drahn@openbsd.org>
*
@@ -72,11 +72,11 @@ pcaled_match(struct device *parent, void *v, void *arg)
iic_acquire_bus(ia->ia_tag, I2C_F_POLL);
cmd = 0;
if (iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
- &cmd, 1, &data, 1, I2C_F_POLL))
+ &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL))
goto fail;
cmd = 9;
if (iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
- &cmd, 1, &data, 1, I2C_F_POLL))
+ &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL))
goto fail;
ok = 1;
fail:
@@ -106,7 +106,7 @@ pcaled_attach(struct device *parent, struct device *self, void *arg)
else
cmd = 1;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
- &cmd, 1, &data, 1, I2C_F_POLL))
+ &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL))
goto fail; /* XXX */
sc->sc_gpio_pin[i].pin_state = (data >> (i & 3)) & 1;
}
@@ -141,7 +141,7 @@ pcaled_gpio_pin_read(void *arg, int pin)
else
cmd = 1;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
- &cmd, 1, &data, 1, I2C_F_POLL))
+ &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL))
goto fail; /* XXX */
fail:
@@ -163,13 +163,13 @@ pcaled_gpio_pin_write (void *arg, int pin, int value)
else
cmd = 9;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
- &cmd, 1, &data, 1, I2C_F_POLL))
+ &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL))
goto fail; /* XXX */
data &= ~(0x3 << (2*(pin & 3)));
data |= (value << (2*(pin & 3)));
if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
- &cmd, 1, &data, 1, I2C_F_POLL))
+ &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL))
goto fail; /* XXX */
fail:
diff --git a/sys/dev/i2c/rs5c372.c b/sys/dev/i2c/rs5c372.c
index 88635aedcd0..04eb2942469 100644
--- a/sys/dev/i2c/rs5c372.c
+++ b/sys/dev/i2c/rs5c372.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rs5c372.c,v 1.3 2007/10/18 03:59:32 cnst Exp $ */
+/* $OpenBSD: rs5c372.c,v 1.4 2008/04/17 16:50:17 deraadt Exp $ */
/* $NetBSD: rs5c372.c,v 1.5 2006/03/29 06:41:24 thorpej Exp $ */
/*
@@ -130,7 +130,7 @@ ricohrtc_match(struct device *parent, void *v, void *arg)
cmd = RICOHRTC_SECONDS;
if (iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
- &cmd, 1, &data, 1, I2C_F_POLL)) {
+ &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL)) {
iic_release_bus(ia->ia_tag, I2C_F_POLL);
printf("ricohrtc read %d fail\n", cmd);
return (0);
@@ -142,7 +142,7 @@ ricohrtc_match(struct device *parent, void *v, void *arg)
cmd = RICOHRTC_MINUTES;
if (iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
- &cmd, 1, &data, 1, I2C_F_POLL)) {
+ &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL)) {
iic_release_bus(ia->ia_tag, I2C_F_POLL);
printf("ricohrtc read %d fail\n", cmd);
return (0);
@@ -155,7 +155,7 @@ ricohrtc_match(struct device *parent, void *v, void *arg)
cmd = RICOHRTC_HOURS;
if (iic_exec(ia->ia_tag, I2C_OP_READ_WITH_STOP, ia->ia_addr,
- &cmd, 1, &data, 1, I2C_F_POLL)) {
+ &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL)) {
iic_release_bus(ia->ia_tag, I2C_F_POLL);
printf("ricohrtc read %d fail\n", cmd);
return (0);
@@ -253,7 +253,7 @@ ricohrtc_reg_write(struct ricohrtc_softc *sc, int reg, uint8_t val)
reg &= 0xf;
cmd = (reg << 4);
if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_address,
- &cmd, 1, &val, 1, I2C_F_POLL)) {
+ &cmd, sizeof cmd, &val, sizeof val, I2C_F_POLL)) {
iic_release_bus(sc->sc_tag, I2C_F_POLL);
printf("%s: ricohrtc_reg_write: failed to write reg%d\n",
sc->sc_dev.dv_xname, reg);
@@ -271,7 +271,7 @@ ricohrtc_clock_read(struct ricohrtc_softc *sc, struct clock_ymdhms *dt)
iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
cmd = (RICOHRTC_SECONDS << 4);
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_address,
- &cmd, 1, bcd, RICOHRTC_NRTC_REGS, I2C_F_POLL)) {
+ &cmd, sizeof cmd, bcd, RICOHRTC_NRTC_REGS, I2C_F_POLL)) {
iic_release_bus(sc->sc_tag, I2C_F_POLL);
printf("%s: ricohrtc_clock_read: failed to read rtc\n",
sc->sc_dev.dv_xname);
@@ -312,7 +312,7 @@ ricohrtc_clock_write(struct ricohrtc_softc *sc, struct clock_ymdhms *dt)
iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
cmd = (RICOHRTC_SECONDS << 4);
if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_address,
- &cmd, 1, bcd, RICOHRTC_NRTC_REGS, I2C_F_POLL)) {
+ &cmd, sizeof cmd, bcd, RICOHRTC_NRTC_REGS, I2C_F_POLL)) {
iic_release_bus(sc->sc_tag, I2C_F_POLL);
printf("%s: ricohrtc_clock_write: failed to write rtc\n",
sc->sc_dev.dv_xname);