summaryrefslogtreecommitdiff
path: root/sys/dev/i2c
diff options
context:
space:
mode:
authorxtraeme <xtraeme@NetBSD.org>2008-05-04 14:45:01 +0000
committerxtraeme <xtraeme@NetBSD.org>2008-05-04 14:45:01 +0000
commit07c2a78bc8d8d76a3ec8c176aa25546e7fa24beb (patch)
tree7fdfdea1d192d4c54db719a038ca53b432e4401b /sys/dev/i2c
parent5232253e5890475f536afef74ff649e6b84f8602 (diff)
device_t/softc split for adt7467c(4) and adm1030, and other related
cosmetic changes.
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r--sys/dev/i2c/adm1030.c34
-rw-r--r--sys/dev/i2c/adm1030var.h9
-rw-r--r--sys/dev/i2c/adt7467.c35
-rw-r--r--sys/dev/i2c/adt7467var.h7
4 files changed, 39 insertions, 46 deletions
diff --git a/sys/dev/i2c/adm1030.c b/sys/dev/i2c/adm1030.c
index c99a6c7149b..125b2e671ce 100644
--- a/sys/dev/i2c/adm1030.c
+++ b/sys/dev/i2c/adm1030.c
@@ -1,4 +1,4 @@
-/* $NetBSD: adm1030.c,v 1.12 2008/04/06 20:25:59 cegger Exp $ */
+/* $NetBSD: adm1030.c,v 1.13 2008/05/04 14:45:01 xtraeme Exp $ */
/*-
* Copyright (C) 2005 Michael Lorenz.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1030.c,v 1.12 2008/04/06 20:25:59 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1030.c,v 1.13 2008/05/04 14:45:01 xtraeme Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -50,8 +50,8 @@ __KERNEL_RCSID(0, "$NetBSD: adm1030.c,v 1.12 2008/04/06 20:25:59 cegger Exp $");
#include "sysmon_envsys.h"
#include <dev/i2c/adm1030var.h>
-static void adm1030c_attach(struct device *, struct device *, void *);
-static int adm1030c_match(struct device *, struct cfdata *, void *);
+static void adm1030c_attach(device_t, device_t, void *);
+static int adm1030c_match(device_t, cfdata_t, void *);
static uint8_t adm1030c_readreg(struct adm1030c_softc *, uint8_t);
static void adm1030c_writereg(struct adm1030c_softc *, uint8_t, uint8_t);
@@ -59,32 +59,27 @@ static int adm1030c_temp2muk(uint8_t);
static int adm1030c_reg2rpm(uint8_t);
static void adm1030c_refresh(struct sysmon_envsys *, envsys_data_t *);
-CFATTACH_DECL(adm1030c, sizeof(struct adm1030c_softc),
+CFATTACH_DECL_NEW(adm1030c, sizeof(struct adm1030c_softc),
adm1030c_match, adm1030c_attach, NULL, NULL);
static int
-adm1030c_match(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+adm1030c_match(device_t parent, cfdata_t cf, void *aux)
{
/* no probing when we're attaching to iic */
return 1;
}
static void
-adm1030c_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+adm1030c_attach(device_t parent, device_t self, void *aux)
{
struct adm1030c_softc *sc = device_private(self);
struct i2c_attach_args *args = aux;
sc->parent = parent;
sc->address = args->ia_addr;
- printf(" ADM1030 thermal monitor and fan controller\n");
+ aprint_normal(" ADM1030 thermal monitor and fan controller\n");
sc->sc_i2c = (struct i2c_controller *)args->ia_tag;
- adm1030c_setup(sc);
+ adm1030c_setup(self);
}
static uint8_t
@@ -171,8 +166,9 @@ sysctl_adm1030c_temp(SYSCTLFN_ARGS)
}
void
-adm1030c_setup(struct adm1030c_softc *sc)
+adm1030c_setup(device_t self)
{
+ struct adm1030c_softc *sc = device_private(self);
int error;
int ret;
struct sysctlnode *me = NULL, *node = NULL;
@@ -183,7 +179,7 @@ adm1030c_setup(struct adm1030c_softc *sc)
ret=sysctl_createv(NULL, 0, NULL, (const struct sysctlnode **)&me,
CTLFLAG_READWRITE,
- CTLTYPE_NODE, device_xname(&sc->sc_dev), NULL,
+ CTLTYPE_NODE, device_xname(self), NULL,
NULL, 0, NULL, 0,
CTL_MACHDEP, CTL_CREATE, CTL_EOL);
@@ -226,17 +222,19 @@ adm1030c_setup(struct adm1030c_softc *sc)
if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor[2]))
goto out;
- sc->sc_sme->sme_name = device_xname(&sc->sc_dev);
+ sc->sc_sme->sme_name = device_xname(self);
sc->sc_sme->sme_cookie = sc;
sc->sc_sme->sme_refresh = adm1030c_refresh;
if ((error = sysmon_envsys_register(sc->sc_sme)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to register with sysmon (%d)\n", error);
+ aprint_error_dev(self,
+ "unable to register with sysmon (%d)\n", error);
goto out;
}
return;
out:
+ free(sc->sc_sensor, M_DEVBUF);
sysmon_envsys_destroy(sc->sc_sme);
}
diff --git a/sys/dev/i2c/adm1030var.h b/sys/dev/i2c/adm1030var.h
index 927140ff4f4..115e80a43ed 100644
--- a/sys/dev/i2c/adm1030var.h
+++ b/sys/dev/i2c/adm1030var.h
@@ -1,4 +1,4 @@
-/* $NetBSD: adm1030var.h,v 1.4 2007/11/16 08:00:14 xtraeme Exp $ */
+/* $NetBSD: adm1030var.h,v 1.5 2008/05/04 14:45:01 xtraeme Exp $ */
/*-
* Copyright (C) 2005 Michael Lorenz.
@@ -35,7 +35,7 @@
#define ADM1030VAR_H
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1030var.h,v 1.4 2007/11/16 08:00:14 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1030var.h,v 1.5 2008/05/04 14:45:01 xtraeme Exp $");
#include <dev/i2c/i2cvar.h>
@@ -43,8 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: adm1030var.h,v 1.4 2007/11/16 08:00:14 xtraeme Exp $
#include "sysmon_envsys.h"
struct adm1030c_softc {
- struct device sc_dev;
- struct device *parent;
+ device_t parent;
struct sysmon_envsys *sc_sme;
envsys_data_t *sc_sensor;
struct i2c_controller *sc_i2c;
@@ -52,6 +51,6 @@ struct adm1030c_softc {
uint8_t regs[3];
};
-void adm1030c_setup(struct adm1030c_softc *);
+void adm1030c_setup(device_t);
#endif
diff --git a/sys/dev/i2c/adt7467.c b/sys/dev/i2c/adt7467.c
index 47c8b1263bd..6d79cbeeb1e 100644
--- a/sys/dev/i2c/adt7467.c
+++ b/sys/dev/i2c/adt7467.c
@@ -1,4 +1,4 @@
-/* $NetBSD: adt7467.c,v 1.11 2008/04/06 20:25:59 cegger Exp $ */
+/* $NetBSD: adt7467.c,v 1.12 2008/05/04 14:45:01 xtraeme Exp $ */
/*-
* Copyright (C) 2005 Michael Lorenz
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adt7467.c,v 1.11 2008/04/06 20:25:59 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adt7467.c,v 1.12 2008/05/04 14:45:01 xtraeme Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -51,8 +51,8 @@ __KERNEL_RCSID(0, "$NetBSD: adt7467.c,v 1.11 2008/04/06 20:25:59 cegger Exp $");
#include <dev/i2c/adt7467var.h>
-static void adt7467c_attach(struct device *, struct device *, void *);
-static int adt7467c_match(struct device *, struct cfdata *, void *);
+static void adt7467c_attach(device_t, device_t, void *);
+static int adt7467c_match(device_t, cfdata_t, void *);
static uint8_t adt7467c_readreg(struct adt7467c_softc *, uint8_t);
static void adt7467c_writereg(struct adt7467c_softc *, uint8_t, uint8_t);
@@ -61,33 +61,28 @@ int temp2muk(uint8_t);
int reg2rpm(uint16_t);
void adt7467c_refresh(struct sysmon_envsys *, envsys_data_t *);
-CFATTACH_DECL(adt7467c, sizeof(struct adt7467c_softc),
+CFATTACH_DECL_NEW(adt7467c, sizeof(struct adt7467c_softc),
adt7467c_match, adt7467c_attach, NULL, NULL);
int
-adt7467c_match(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+adt7467c_match(device_t parent, cfdata_t cf, void *aux)
{
/* no probing if we attach to iic */
return 1;
}
void
-adt7467c_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+adt7467c_attach(device_t parent, device_t self, void *aux)
{
struct adt7467c_softc *sc = device_private(self);
struct i2c_attach_args *args = aux;
sc->parent = parent;
sc->address = args->ia_addr;
- printf(" ADT7467 thermal monitor and fan controller, addr: %02x\n",
- sc->address);
+ aprint_normal(" ADT7467 thermal monitor and fan controller, "
+ "addr: %02x\n", sc->address);
sc->sc_i2c = (struct i2c_controller *)args->ia_tag;
- adt7467c_setup(sc);
+ adt7467c_setup(self);
}
uint8_t adt7467c_readreg(struct adt7467c_softc *sc, uint8_t reg)
@@ -179,8 +174,9 @@ sysctl_adt7467_temp(SYSCTLFN_ARGS)
}
void
-adt7467c_setup(struct adt7467c_softc *sc)
+adt7467c_setup(device_t self)
{
+ struct adt7467c_softc *sc = device_private(self);
const struct sysctlnode *me=NULL;
struct sysctlnode *node=NULL;
int i, ret;
@@ -194,7 +190,7 @@ adt7467c_setup(struct adt7467c_softc *sc)
ret = sysctl_createv(NULL, 0, NULL, &me,
CTLFLAG_READWRITE,
- CTLTYPE_NODE, device_xname(&sc->sc_dev), NULL,
+ CTLTYPE_NODE, device_xname(self), NULL,
NULL, 0, NULL, 0,
CTL_MACHDEP, CTL_CREATE, CTL_EOL);
@@ -238,12 +234,13 @@ adt7467c_setup(struct adt7467c_softc *sc)
stuff = adt7467c_readreg(sc, 0x40);
adt7467c_writereg(sc, 0x40, stuff);
- sc->sc_sme->sme_name = device_xname(&sc->sc_dev);
+ sc->sc_sme->sme_name = device_xname(self);
sc->sc_sme->sme_cookie = sc;
sc->sc_sme->sme_refresh = adt7467c_refresh;
if ((error = sysmon_envsys_register(sc->sc_sme)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to register with sysmon (%d)\n", error);
+ aprint_error_dev(self,
+ "unable to register with sysmon (%d)\n", error);
goto out;
}
diff --git a/sys/dev/i2c/adt7467var.h b/sys/dev/i2c/adt7467var.h
index f0465813412..8aa442f4f51 100644
--- a/sys/dev/i2c/adt7467var.h
+++ b/sys/dev/i2c/adt7467var.h
@@ -1,4 +1,4 @@
-/* $NetBSD: adt7467var.h,v 1.4 2007/11/16 08:00:14 xtraeme Exp $ */
+/* $NetBSD: adt7467var.h,v 1.5 2008/05/04 14:45:01 xtraeme Exp $ */
/*-
* Copyright (C) 2005 Michael Lorenz
@@ -35,7 +35,7 @@
#define ADT7456VAR_H
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adt7467var.h,v 1.4 2007/11/16 08:00:14 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adt7467var.h,v 1.5 2008/05/04 14:45:01 xtraeme Exp $");
#include <dev/i2c/i2cvar.h>
@@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: adt7467var.h,v 1.4 2007/11/16 08:00:14 xtraeme Exp $
#define ADT7467_MAXSENSORS 5
struct adt7467c_softc {
- struct device sc_dev;
struct device *parent;
int sc_node, address;
struct sysmon_envsys *sc_sme;
@@ -54,6 +53,6 @@ struct adt7467c_softc {
uint8_t regs[32];
};
-void adt7467c_setup(struct adt7467c_softc *);
+void adt7467c_setup(device_t);
#endif