Split device_t/softc for ug(4) and other related cosmetic changes.

This commit is contained in:
xtraeme 2008-03-26 16:09:37 +00:00
parent b0cfcf1f00
commit 8bea7f6b6e
4 changed files with 39 additions and 45 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ug_acpi.c,v 1.3 2007/10/19 11:59:36 ad Exp $ */
/* $NetBSD: ug_acpi.c,v 1.4 2008/03/26 16:09:37 xtraeme Exp $ */
/*
* Copyright (c) 2007 Mihai Chelaru <kefren@netbsd.ro>
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ug_acpi.c,v 1.3 2007/10/19 11:59:36 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ug_acpi.c,v 1.4 2008/03/26 16:09:37 xtraeme Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -49,10 +49,10 @@ __KERNEL_RCSID(0, "$NetBSD: ug_acpi.c,v 1.3 2007/10/19 11:59:36 ad Exp $");
#include <dev/ic/ugvar.h>
/* autoconf(9) functions */
static int ug_acpi_match(struct device *, struct cfdata *, void *);
static void ug_acpi_attach(struct device *, struct device *, void *);
static int ug_acpi_match(device_t, cfdata_t, void *);
static void ug_acpi_attach(device_t, device_t, void *);
CFATTACH_DECL(ug_acpi, sizeof(struct ug_softc), ug_acpi_match,
CFATTACH_DECL_NEW(ug_acpi, sizeof(struct ug_softc), ug_acpi_match,
ug_acpi_attach, NULL, NULL);
/*
@ -66,8 +66,7 @@ static const char* const ug_acpi_ids[] = {
};
static int
ug_acpi_match(struct device *parent, struct cfdata *match,
void *aux)
ug_acpi_match(device_t parent, cfdata_t match, void *aux)
{
struct acpi_attach_args *aa = aux;
@ -78,9 +77,9 @@ ug_acpi_match(struct device *parent, struct cfdata *match,
}
static void
ug_acpi_attach(struct device *parent, struct device *self, void *aux)
ug_acpi_attach(device_t parent, device_t self, void *aux)
{
struct ug_softc *sc = (struct ug_softc*)self;
struct ug_softc *sc = device_private(self);
struct acpi_attach_args *aa = aux;
struct acpi_resources res;
struct acpi_io *io;
@ -91,7 +90,7 @@ ug_acpi_attach(struct device *parent, struct device *self, void *aux)
aprint_normal("\n");
/* parse resources */
rv = acpi_resource_parse(&sc->sc_dev, aa->aa_node->ad_handle, "_CRS",
rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS",
&res, &acpi_resource_parse_ops_default);
if (ACPI_FAILURE(rv))
return;
@ -99,26 +98,25 @@ ug_acpi_attach(struct device *parent, struct device *self, void *aux)
/* find our i/o registers */
io = acpi_res_io(&res, 0);
if (io == NULL) {
aprint_error("%s: unable to find i/o register resource\n",
sc->sc_dev.dv_xname);
aprint_error_dev(self,
"unable to find i/o register resource\n");
acpi_resource_cleanup(&res);
return;
}
if (bus_space_map(aa->aa_iot, io->ar_base, io->ar_length,
0, &ioh)) {
aprint_error("%s: can't map i/o space\n",
sc->sc_dev.dv_xname);
aprint_error_dev(self, "can't map i/o space\n");
acpi_resource_cleanup(&res);
return;
}
aprint_normal("%s", sc->sc_dev.dv_xname);
aprint_normal("%s", device_xname(self));
sc->version = 2; /* uGuru 2005 */
sc->sc_ioh = ioh;
sc->sc_iot = aa->aa_iot;
ug2_attach(sc);
ug2_attach(self);
acpi_resource_cleanup(&res);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ug.c,v 1.10 2007/11/17 08:23:46 kefren Exp $ */
/* $NetBSD: ug.c,v 1.11 2008/03/26 16:09:37 xtraeme Exp $ */
/*
* Copyright (c) 2007 Mihai Chelaru <kefren@netbsd.ro>
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ug.c,v 1.10 2007/11/17 08:23:46 kefren Exp $");
__KERNEL_RCSID(0, "$NetBSD: ug.c,v 1.11 2008/03/26 16:09:37 xtraeme Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -476,8 +476,9 @@ ug_refresh(struct sysmon_envsys *sme, envsys_data_t *edata)
}
void
ug2_attach(struct ug_softc *sc)
ug2_attach(device_t dv)
{
struct ug_softc *sc = device_private(dv);
uint8_t buf[2];
int i;
struct ug2_motherboard_info *ai;
@ -486,23 +487,22 @@ ug2_attach(struct ug_softc *sc)
aprint_normal(": Abit uGuru 2005 system monitor\n");
if (ug2_read(sc, UG2_MISC_BANK, UG2_BOARD_ID, 2, buf) != 2) {
aprint_error("%s: Cannot detect board ID. Using default\n",
sc->sc_dev.dv_xname);
aprint_error_dev(dv, "Cannot detect board ID. Using default\n");
buf[0] = UG_MAX_MSB_BOARD;
buf[1] = UG_MAX_LSB_BOARD;
}
if (buf[0] > UG_MAX_MSB_BOARD || buf[1] > UG_MAX_LSB_BOARD ||
buf[1] < UG_MIN_LSB_BOARD) {
aprint_error("%s: Invalid board ID(%X,%X). Using default\n",
sc->sc_dev.dv_xname, buf[0], buf[1]);
aprint_error_dev(dv, "Invalid board ID(%X,%X). Using default\n",
buf[0], buf[1]);
buf[0] = UG_MAX_MSB_BOARD;
buf[1] = UG_MAX_LSB_BOARD;
}
ai = &ug2_mb[buf[1] - UG_MIN_LSB_BOARD];
aprint_normal("%s: mainboard %s (%.2X%.2X)\n", sc->sc_dev.dv_xname,
aprint_normal_dev(dv, "mainboard %s (%.2X%.2X)\n",
ai->name, buf[0], buf[1]);
sc->mbsens = (void*)ai->sensors;
@ -534,13 +534,12 @@ ug2_attach(struct ug_softc *sc)
}
#undef COPYDESCR
sc->sc_sme->sme_name = sc->sc_dev.dv_xname;
sc->sc_sme->sme_name = device_xname(dv);
sc->sc_sme->sme_cookie = sc;
sc->sc_sme->sme_refresh = ug2_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(dv, "unable to register with sysmon\n");
sysmon_envsys_destroy(sc->sc_sme);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ugvar.h,v 1.3 2007/11/16 08:00:15 xtraeme Exp $ */
/* $NetBSD: ugvar.h,v 1.4 2008/03/26 16:09:37 xtraeme Exp $ */
/*
* Copyright (c) 2007 Mihai Chelaru <kefren@netbsd.ro>
@ -29,8 +29,6 @@
#define _UGVAR_H_
struct ug_softc {
struct device sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
@ -60,7 +58,7 @@ int ug_reset(struct ug_softc *);
uint8_t ug_read(struct ug_softc *, unsigned short);
int ug_waitfor(struct ug_softc *, uint16_t, uint8_t);
void ug_setup_sensors(struct ug_softc *);
void ug2_attach(struct ug_softc *);
void ug2_attach(device_t);
int ug2_wait_ready(struct ug_softc *);
int ug2_wait_readable(struct ug_softc *);
int ug2_sync(struct ug_softc *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ug_isa.c,v 1.5 2007/11/16 08:00:15 xtraeme Exp $ */
/* $NetBSD: ug_isa.c,v 1.6 2008/03/26 16:09:37 xtraeme Exp $ */
/*
* Copyright (c) 2007 Mihai Chelaru <kefren@netbsd.ro>
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ug_isa.c,v 1.5 2007/11/16 08:00:15 xtraeme Exp $");
__KERNEL_RCSID(0, "$NetBSD: ug_isa.c,v 1.6 2008/03/26 16:09:37 xtraeme Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -57,17 +57,17 @@ __KERNEL_RCSID(0, "$NetBSD: ug_isa.c,v 1.5 2007/11/16 08:00:15 xtraeme Exp $");
#include <dev/ic/ugvar.h>
/* autoconf(9) functions */
static int ug_isa_match(struct device *, struct cfdata *, void *);
static void ug_isa_attach(struct device *, struct device *, void *);
static int ug_isa_detach(struct device *, int);
static int ug_isa_match(device_t, cfdata_t, void *);
static void ug_isa_attach(device_t, device_t, void *);
static int ug_isa_detach(device_t, int);
CFATTACH_DECL(ug_isa, sizeof(struct ug_softc),
CFATTACH_DECL_NEW(ug_isa, sizeof(struct ug_softc),
ug_isa_match, ug_isa_attach, ug_isa_detach, NULL);
extern uint8_t ug_ver;
static int
ug_isa_match(struct device *parent, struct cfdata *match, void *aux)
ug_isa_match(device_t parent, cfdata_t match, void *aux)
{
struct isa_attach_args *ia = aux;
struct ug_softc wrap_sc;
@ -121,9 +121,9 @@ ug_isa_match(struct device *parent, struct cfdata *match, void *aux)
}
static void
ug_isa_attach(struct device *parent, struct device *self, void *aux)
ug_isa_attach(device_t parent, device_t self, void *aux)
{
struct ug_softc *sc = (void *)self;
struct ug_softc *sc = device_private(self);
struct isa_attach_args *ia = aux;
int i;
@ -137,14 +137,14 @@ ug_isa_attach(struct device *parent, struct device *self, void *aux)
sc->version = ug_ver;
if (sc->version == 2) {
ug2_attach(sc);
ug2_attach(self);
return;
}
aprint_normal(": Abit uGuru system monitor\n");
if (!ug_reset(sc))
aprint_error("%s: reset failed.\n", sc->sc_dev.dv_xname);
aprint_error_dev(self, "reset failed.\n");
ug_setup_sensors(sc);
sc->sc_sme = sysmon_envsys_create();
@ -161,15 +161,14 @@ ug_isa_attach(struct device *parent, struct device *self, void *aux)
sc->sc_sme->sme_refresh = ug_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);
}
}
static int
ug_isa_detach(struct device *self, int flags)
ug_isa_detach(device_t self, int flags)
{
struct ug_softc *sc = device_private(self);