summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorXavier Santolaria <xsa@cvs.openbsd.org>2008-04-25 16:37:45 +0000
committerXavier Santolaria <xsa@cvs.openbsd.org>2008-04-25 16:37:45 +0000
commit6356d99e93ec44f374376c780246b6ef6c21ded2 (patch)
tree0ee01c9986807f3c6d6664776f71a30d53216e40 /sys/arch
parenta9512276a49b114af9fc563f895fb561d2031614 (diff)
Pretty dmesg output on attach and error handling.
Prodded by deraadt; ok dlg derradt
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/macppc/dev/asms.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sys/arch/macppc/dev/asms.c b/sys/arch/macppc/dev/asms.c
index 50621c33179..5f4ad4fae1d 100644
--- a/sys/arch/macppc/dev/asms.c
+++ b/sys/arch/macppc/dev/asms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asms.c,v 1.6 2007/06/24 05:34:35 dlg Exp $ */
+/* $OpenBSD: asms.c,v 1.7 2008/04/25 16:37:44 xsa Exp $ */
/*
* Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org>
*
@@ -92,7 +92,7 @@ asms_attach(struct device *parent, struct device *self, void *aux)
{
struct asms_softc *sc = (struct asms_softc *)self;
struct i2c_attach_args *ia = aux;
- u_int8_t cmd, data;
+ u_int8_t cmd, data, rev1, rev2, ver1, ver2;
int i, vflag = 0;
sc->sc_tag = ia->ia_tag;
@@ -144,21 +144,19 @@ asms_attach(struct device *parent, struct device *self, void *aux)
cmd = ASMS_REG_RDATA1;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) {
+ sc->sc_addr, &cmd, sizeof cmd, &rev1, sizeof rev1, 0)) {
iic_release_bus(sc->sc_tag, 0);
printf(": cannot read data register\n");
return;
}
- printf(", rev %x", data);
cmd = ASMS_REG_RDATA2;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) {
+ sc->sc_addr, &cmd, sizeof cmd, &rev2, sizeof rev2, 0)) {
iic_release_bus(sc->sc_tag, 0);
printf(": cannot read data register\n");
return;
}
- printf(".%x", data);
cmd = ASMS_REG_COMMAND; data = ASMS_CMD_READ_VER;
if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
@@ -171,21 +169,19 @@ asms_attach(struct device *parent, struct device *self, void *aux)
cmd = ASMS_REG_RDATA1;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) {
+ sc->sc_addr, &cmd, sizeof cmd, &ver1, sizeof ver1, 0)) {
iic_release_bus(sc->sc_tag, 0);
printf(": cannot read data register\n");
return;
}
- printf(", version %x", data);
cmd = ASMS_REG_RDATA2;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) {
+ sc->sc_addr, &cmd, sizeof cmd, &ver2, sizeof ver2, 0)) {
iic_release_bus(sc->sc_tag, 0);
printf(": cannot read data register\n");
return;
}
- printf(".%x", data);
cmd = ASMS_REG_VENDOR;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
@@ -247,6 +243,8 @@ asms_attach(struct device *parent, struct device *self, void *aux)
iic_release_bus(sc->sc_tag, 0);
+ printf(": rev %x.%x, version %x.%x", rev1, rev2, ver1, ver2);
+
/* Initialize sensor data. */
strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname,
sizeof(sc->sc_sensordev.xname));