summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorxtraeme <xtraeme@NetBSD.org>2008-04-04 10:11:01 +0000
committerxtraeme <xtraeme@NetBSD.org>2008-04-04 10:11:01 +0000
commit63e2f604f650cf8f13d5ff5dbfd39cc062f89b7a (patch)
tree80ab4e5b35cf128dcfdc0a36defdf7497a888886 /sys/dev
parentad882177bc5fab4049612a606acbb36477ac0c22 (diff)
Split device_t/softc and other related cosmetic changes.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/i2c/lm75.c51
-rw-r--r--sys/dev/spi/tmp121.c21
2 files changed, 33 insertions, 39 deletions
diff --git a/sys/dev/i2c/lm75.c b/sys/dev/i2c/lm75.c
index 7e75410857f..74505ba3db4 100644
--- a/sys/dev/i2c/lm75.c
+++ b/sys/dev/i2c/lm75.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lm75.c,v 1.17 2007/12/11 12:09:22 lukem Exp $ */
+/* $NetBSD: lm75.c,v 1.18 2008/04/04 10:11:01 xtraeme Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.17 2007/12/11 12:09:22 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.18 2008/04/04 10:11:01 xtraeme Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -49,25 +49,24 @@ __KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.17 2007/12/11 12:09:22 lukem Exp $");
#include <dev/i2c/lm75reg.h>
struct lmtemp_softc {
- struct device sc_dev;
i2c_tag_t sc_tag;
int sc_address;
- envsys_data_t sc_sensor;
struct sysmon_envsys *sc_sme;
+ envsys_data_t sc_sensor;
uint32_t (*sc_lmtemp_decode)(const uint8_t *);
};
-static int lmtemp_match(struct device *, struct cfdata *, void *);
-static void lmtemp_attach(struct device *, struct device *, void *);
+static int lmtemp_match(device_t, cfdata_t, void *);
+static void lmtemp_attach(device_t, device_t, void *);
-CFATTACH_DECL(lmtemp, sizeof(struct lmtemp_softc),
+CFATTACH_DECL_NEW(lmtemp, sizeof(struct lmtemp_softc),
lmtemp_match, lmtemp_attach, NULL, NULL);
static void lmtemp_refresh(struct sysmon_envsys *, envsys_data_t *);
-static int lmtemp_config_write(struct lmtemp_softc *, uint8_t);
+static int lmtemp_config_write(struct lmtemp_softc *, uint8_t);
static uint32_t lmtemp_decode_lm75(const uint8_t *);
static uint32_t lmtemp_decode_ds75(const uint8_t *);
static uint32_t lmtemp_decode_lm77(const uint8_t *);
@@ -96,7 +95,7 @@ static const struct {
};
static int
-lmtemp_match(struct device *parent, struct cfdata *cf, void *aux)
+lmtemp_match(device_t parent, cfdata_t cf, void *aux)
{
struct i2c_attach_args *ia = aux;
int i;
@@ -105,17 +104,17 @@ lmtemp_match(struct device *parent, struct cfdata *cf, void *aux)
if (lmtemptbl[i].lmtemp_type == cf->cf_flags)
break;
if (lmtemptbl[i].lmtemp_type == -1)
- return (0);
+ return 0;
if ((ia->ia_addr & lmtemptbl[i].lmtemp_addrmask) ==
lmtemptbl[i].lmtemp_addr)
- return (1);
+ return 1;
- return (0);
+ return 0;
}
static void
-lmtemp_attach(struct device *parent, struct device *self, void *aux)
+lmtemp_attach(device_t parent, device_t self, void *aux)
{
struct lmtemp_softc *sc = device_private(self);
struct i2c_attach_args *ia = aux;
@@ -123,7 +122,7 @@ lmtemp_attach(struct device *parent, struct device *self, void *aux)
for (i = 0; lmtemptbl[i].lmtemp_type != -1 ; i++)
if (lmtemptbl[i].lmtemp_type ==
- device_cfdata(&sc->sc_dev)->cf_flags)
+ device_cfdata(self)->cf_flags)
break;
sc->sc_tag = ia->ia_tag;
@@ -135,8 +134,7 @@ lmtemp_attach(struct device *parent, struct device *self, void *aux)
/* Set the configuration of the LM75 to defaults. */
iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
if (lmtemp_config_write(sc, 0) != 0) {
- aprint_error("%s: unable to write config register\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "unable to write config register\n");
iic_release_bus(sc->sc_tag, I2C_F_POLL);
return;
}
@@ -145,8 +143,8 @@ lmtemp_attach(struct device *parent, struct device *self, void *aux)
sc->sc_sme = sysmon_envsys_create();
/* Initialize sensor data. */
sc->sc_sensor.units = ENVSYS_STEMP;
- (void)strlcpy(sc->sc_sensor.desc,
- sc->sc_dev.dv_xname, sizeof(sc->sc_sensor.desc));
+ (void)strlcpy(sc->sc_sensor.desc, device_xname(self),
+ sizeof(sc->sc_sensor.desc));
if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor)) {
sysmon_envsys_destroy(sc->sc_sme);
return;
@@ -155,13 +153,12 @@ lmtemp_attach(struct device *parent, struct device *self, void *aux)
sc->sc_lmtemp_decode = lmtemptbl[i].lmtemp_decode;
/* Hook into system monitor. */
- sc->sc_sme->sme_name = sc->sc_dev.dv_xname;
+ sc->sc_sme->sme_name = device_xname(self);
sc->sc_sme->sme_cookie = sc;
sc->sc_sme->sme_refresh = lmtemp_refresh;
if (sysmon_envsys_register(sc->sc_sme)) {
- aprint_error("%s: unable to register with sysmon\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "unable to register with sysmon\n");
sysmon_envsys_destroy(sc->sc_sme);
}
}
@@ -174,8 +171,8 @@ lmtemp_config_write(struct lmtemp_softc *sc, uint8_t val)
cmdbuf[0] = LM75_REG_CONFIG;
cmdbuf[1] = val;
- return (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
- sc->sc_address, cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL));
+ return iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
+ sc->sc_address, cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL);
}
static int
@@ -190,10 +187,10 @@ lmtemp_temp_read(struct lmtemp_softc *sc, uint8_t which, uint32_t *valp)
error = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
sc->sc_address, cmdbuf, 1, buf, LM75_TEMP_LEN, 0);
if (error)
- return (error);
+ return error;
*valp = sc->sc_lmtemp_decode(buf);
- return (0);
+ return 0;
}
static void
@@ -250,7 +247,7 @@ lmtemp_decode_lm75(const uint8_t *buf)
val += 500000;
}
- return (val);
+ return val;
}
static uint32_t
@@ -288,6 +285,6 @@ lmtemp_decode_lm77(const uint8_t *buf)
/* Temp is given in 1/2 deg. C, we convert to uK. */
val = temp * 500000 + 273150000;
- return (val);
+ return val;
}
diff --git a/sys/dev/spi/tmp121.c b/sys/dev/spi/tmp121.c
index ca790ffac4a..29844196eab 100644
--- a/sys/dev/spi/tmp121.c
+++ b/sys/dev/spi/tmp121.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tmp121.c,v 1.3 2007/11/16 08:00:16 xtraeme Exp $ */
+/* $NetBSD: tmp121.c,v 1.4 2008/04/04 10:13:59 xtraeme Exp $ */
/*-
* Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmp121.c,v 1.3 2007/11/16 08:00:16 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmp121.c,v 1.4 2008/04/04 10:13:59 xtraeme Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -54,24 +54,22 @@ __KERNEL_RCSID(0, "$NetBSD: tmp121.c,v 1.3 2007/11/16 08:00:16 xtraeme Exp $");
#include <dev/spi/spivar.h>
struct tmp121temp_softc {
- struct device sc_dev;
-
struct spi_handle *sc_sh;
struct sysmon_envsys *sc_sme;
envsys_data_t sc_sensor;
};
-static int tmp121temp_match(struct device *, struct cfdata *, void *);
-static void tmp121temp_attach(struct device *, struct device *, void *);
+static int tmp121temp_match(device_t, cfdata_t, void *);
+static void tmp121temp_attach(device_t, device_t, void *);
-static void tmp121temp_refresh(struct sysmon_envsys *, envsys_data_t *);
+static void tmp121temp_refresh(struct sysmon_envsys *, envsys_data_t *);
-CFATTACH_DECL(tmp121temp, sizeof(struct tmp121temp_softc),
+CFATTACH_DECL_NEW(tmp121temp, sizeof(struct tmp121temp_softc),
tmp121temp_match, tmp121temp_attach, NULL, NULL);
static int
-tmp121temp_match(struct device *parent, struct cfdata *cf, void *aux)
+tmp121temp_match(device_t parent, cfdata_t cf, void *aux)
{
struct spi_attach_args *sa = aux;
@@ -83,7 +81,7 @@ tmp121temp_match(struct device *parent, struct cfdata *cf, void *aux)
}
static void
-tmp121temp_attach(struct device *parent, struct device *self, void *aux)
+tmp121temp_attach(device_t parent, device_t self, void *aux)
{
struct tmp121temp_softc *sc = device_private(self);
struct spi_attach_args *sa = aux;
@@ -107,8 +105,7 @@ tmp121temp_attach(struct device *parent, struct device *self, void *aux)
sc->sc_sme->sme_cookie = sc;
if (sysmon_envsys_register(sc->sc_sme)) {
- aprint_error("%s: unable to register with sysmon\n",
- device_xname(self));
+ aprint_error_dev(self, "unable to register with sysmon\n");
sysmon_envsys_destroy(sc->sc_sme);
}
}