Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/isa This only needs one bus_space_tag_t.
details: https://anonhg.NetBSD.org/src/rev/3e81a64f55ef
branches: trunk
changeset: 754516:3e81a64f55ef
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Sun May 02 18:49:13 2010 +0000
description:
This only needs one bus_space_tag_t.
While here, rename one of the bus_space_handle_ts
to be be descriptive of its function.
Fixes crash caused by uninitialized bus_space_tag_t
discovered by Paul Goyette.
diffstat:
sys/dev/isa/itesio_isa.c | 75 +++++++++++++++++++++++---------------------
sys/dev/isa/itesio_isavar.h | 5 +-
2 files changed, 41 insertions(+), 39 deletions(-)
diffs (205 lines):
diff -r 30cbfb7f372d -r 3e81a64f55ef sys/dev/isa/itesio_isa.c
--- a/sys/dev/isa/itesio_isa.c Sun May 02 18:03:31 2010 +0000
+++ b/sys/dev/isa/itesio_isa.c Sun May 02 18:49:13 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: itesio_isa.c,v 1.17 2008/04/26 19:01:53 xtraeme Exp $ */
+/* $NetBSD: itesio_isa.c,v 1.18 2010/05/02 18:49:13 jakllsch Exp $ */
/* Derived from $OpenBSD: it.c,v 1.19 2006/04/10 00:57:54 deraadt Exp $ */
/*
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: itesio_isa.c,v 1.17 2008/04/26 19:01:53 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: itesio_isa.c,v 1.18 2010/05/02 18:49:13 jakllsch Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -162,8 +162,8 @@
sc->sc_iot = ia->ia_iot;
if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, 2, 0,
- &sc->sc_ioh)) {
- aprint_error(": can't map i/o space\n");
+ &sc->sc_pnp_ioh)) {
+ aprint_error(": can't map pnp i/o space\n");
return;
}
@@ -172,36 +172,37 @@
/*
* Enter to the Super I/O MB PNP mode.
*/
- itesio_enter(sc->sc_iot, sc->sc_ioh);
+ itesio_enter(sc->sc_iot, sc->sc_pnp_ioh);
/*
* Get info from the Super I/O Global Configuration Registers:
* Chip IDs and Device Revision.
*/
- sc->sc_chipid = (itesio_readreg(sc->sc_iot, sc->sc_ioh,
+ sc->sc_chipid = (itesio_readreg(sc->sc_iot, sc->sc_pnp_ioh,
ITESIO_CHIPID1) << 8);
- sc->sc_chipid |= itesio_readreg(sc->sc_iot, sc->sc_ioh,
+ sc->sc_chipid |= itesio_readreg(sc->sc_iot, sc->sc_pnp_ioh,
ITESIO_CHIPID2);
- sc->sc_devrev = (itesio_readreg(sc->sc_iot, sc->sc_ioh,
+ sc->sc_devrev = (itesio_readreg(sc->sc_iot, sc->sc_pnp_ioh,
ITESIO_DEVREV) & 0x0f);
/*
* Select the EC LDN to get the Base Address.
*/
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_LDNSEL, ITESIO_EC_LDN);
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_LDNSEL,
+ ITESIO_EC_LDN);
sc->sc_hwmon_baseaddr =
- (itesio_readreg(sc->sc_iot, sc->sc_ioh, ITESIO_EC_MSB) << 8);
- sc->sc_hwmon_baseaddr |= itesio_readreg(sc->sc_iot, sc->sc_ioh,
+ (itesio_readreg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_EC_MSB) << 8);
+ sc->sc_hwmon_baseaddr |= itesio_readreg(sc->sc_iot, sc->sc_pnp_ioh,
ITESIO_EC_LSB);
/*
* We are done, exit MB PNP mode.
*/
- itesio_exit(sc->sc_iot, sc->sc_ioh);
+ itesio_exit(sc->sc_iot, sc->sc_pnp_ioh);
aprint_normal(": iTE IT%4xF Super I/O (rev %d)\n",
sc->sc_chipid, sc->sc_devrev);
aprint_normal_dev(self, "Hardware Monitor registers at 0x%x\n",
sc->sc_hwmon_baseaddr);
- if (bus_space_map(sc->sc_ec_iot, sc->sc_hwmon_baseaddr, 8, 0,
+ if (bus_space_map(sc->sc_iot, sc->sc_hwmon_baseaddr, 8, 0,
&sc->sc_ec_ioh)) {
aprint_error_dev(self, "cannot map hwmon i/o space\n");
goto out2;
@@ -274,9 +275,9 @@
return;
out:
- bus_space_unmap(sc->sc_ec_iot, sc->sc_ec_ioh, 8);
+ bus_space_unmap(sc->sc_iot, sc->sc_ec_ioh, 8);
out2:
- bus_space_unmap(sc->sc_iot, sc->sc_ioh, 2);
+ bus_space_unmap(sc->sc_iot, sc->sc_pnp_ioh, 2);
}
static int
@@ -287,10 +288,10 @@
if (sc->sc_hwmon_enabled)
sysmon_envsys_unregister(sc->sc_sme);
if (sc->sc_hwmon_mapped)
- bus_space_unmap(sc->sc_ec_iot, sc->sc_ec_ioh, 8);
+ bus_space_unmap(sc->sc_iot, sc->sc_ec_ioh, 8);
if (sc->sc_wdt_enabled) {
sysmon_wdog_unregister(&sc->sc_smw);
- bus_space_unmap(sc->sc_iot, sc->sc_ioh, 2);
+ bus_space_unmap(sc->sc_iot, sc->sc_pnp_ioh, 2);
}
return 0;
@@ -302,15 +303,15 @@
static uint8_t
itesio_ecreadreg(struct itesio_softc *sc, int reg)
{
- bus_space_write_1(sc->sc_ec_iot, sc->sc_ec_ioh, ITESIO_EC_ADDR, reg);
- return bus_space_read_1(sc->sc_ec_iot, sc->sc_ec_ioh, ITESIO_EC_DATA);
+ bus_space_write_1(sc->sc_iot, sc->sc_ec_ioh, ITESIO_EC_ADDR, reg);
+ return bus_space_read_1(sc->sc_iot, sc->sc_ec_ioh, ITESIO_EC_DATA);
}
static void
itesio_ecwritereg(struct itesio_softc *sc, int reg, int val)
{
- bus_space_write_1(sc->sc_ec_iot, sc->sc_ec_ioh, ITESIO_EC_ADDR, reg);
- bus_space_write_1(sc->sc_ec_iot, sc->sc_ec_ioh, ITESIO_EC_DATA, val);
+ bus_space_write_1(sc->sc_iot, sc->sc_ec_ioh, ITESIO_EC_ADDR, reg);
+ bus_space_write_1(sc->sc_iot, sc->sc_ec_ioh, ITESIO_EC_DATA, val);
}
/*
@@ -536,15 +537,16 @@
int period = smw->smw_period;
/* Enter MB PNP mode and select the WDT LDN */
- itesio_enter(sc->sc_iot, sc->sc_ioh);
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_LDNSEL, ITESIO_WDT_LDN);
+ itesio_enter(sc->sc_iot, sc->sc_pnp_ioh);
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_LDNSEL,
+ ITESIO_WDT_LDN);
if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) {
/* Disable the watchdog */
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_CTL, 0);
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_CNF, 0);
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_MSB, 0);
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_LSB, 0);
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_WDT_CTL, 0);
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_WDT_CNF, 0);
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_WDT_TMO_MSB, 0);
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_WDT_TMO_LSB, 0);
} else {
/* Enable the watchdog */
if (period > ITESIO_WDT_MAXTIMO || period < 1)
@@ -553,16 +555,16 @@
period *= 2;
/* set the timeout and start the watchdog */
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_MSB,
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_WDT_TMO_MSB,
period >> 8);
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_LSB,
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_WDT_TMO_LSB,
period & 0xff);
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_CNF,
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_WDT_CNF,
ITESIO_WDT_CNF_SECS | ITESIO_WDT_CNF_KRST |
ITESIO_WDT_CNF_PWROK);
}
/* we are done, exit MB PNP mode */
- itesio_exit(sc->sc_iot, sc->sc_ioh);
+ itesio_exit(sc->sc_iot, sc->sc_pnp_ioh);
return 0;
}
@@ -574,13 +576,14 @@
int period = smw->smw_period * 2;
/* refresh timeout value and exit */
- itesio_enter(sc->sc_iot, sc->sc_ioh);
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_LDNSEL, ITESIO_WDT_LDN);
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_MSB,
+ itesio_enter(sc->sc_iot, sc->sc_pnp_ioh);
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_LDNSEL,
+ ITESIO_WDT_LDN);
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_WDT_TMO_MSB,
period >> 8);
- itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_LSB,
+ itesio_writereg(sc->sc_iot, sc->sc_pnp_ioh, ITESIO_WDT_TMO_LSB,
period & 0xff);
- itesio_exit(sc->sc_iot, sc->sc_ioh);
+ itesio_exit(sc->sc_iot, sc->sc_pnp_ioh);
return 0;
}
diff -r 30cbfb7f372d -r 3e81a64f55ef sys/dev/isa/itesio_isavar.h
--- a/sys/dev/isa/itesio_isavar.h Sun May 02 18:03:31 2010 +0000
+++ b/sys/dev/isa/itesio_isavar.h Sun May 02 18:49:13 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: itesio_isavar.h,v 1.6 2008/04/26 19:01:53 xtraeme Exp $ */
+/* $NetBSD: itesio_isavar.h,v 1.7 2010/05/02 18:49:13 jakllsch Exp $ */
/* $OpenBSD: itvar.h,v 1.2 2003/11/05 20:57:10 grange Exp $ */
/*
@@ -139,9 +139,8 @@
struct itesio_softc {
bus_space_tag_t sc_iot;
- bus_space_handle_t sc_ioh;
- bus_space_tag_t sc_ec_iot;
+ bus_space_handle_t sc_pnp_ioh;
bus_space_handle_t sc_ec_ioh;
struct sysmon_wdog sc_smw;
Home |
Main Index |
Thread Index |
Old Index