Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Modularize lm_isa and lm_wbsio, splitting the common par...
details: https://anonhg.NetBSD.org/src/rev/90514ce85e9e
branches: trunk
changeset: 772827:90514ce85e9e
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Tue Jan 17 16:50:07 2012 +0000
description:
Modularize lm_isa and lm_wbsio, splitting the common part out
into a 3rd module. Add wbsio module too.
diffstat:
sys/dev/isa/lm_isa.c | 138 +++++----------------------
sys/dev/isa/lm_isa_common.c | 172 +++++++++++++++++++++++++++++++++++
sys/dev/isa/lm_isa_common_var.h | 46 +++++++++
sys/dev/isa/lm_wbsio.c | 79 ++++++++++++++++
sys/modules/lm/Makefile | 12 ++
sys/modules/lm_isa/Makefile | 13 ++
sys/modules/lm_isa/lm_isa.ioconf | 10 ++
sys/modules/lm_isa_common/Makefile | 12 ++
sys/modules/lm_wbsio/Makefile | 13 ++
sys/modules/lm_wbsio/lm_wbsio.ioconf | 10 ++
sys/modules/wbsio/Makefile | 13 ++
sys/modules/wbsio/wbsio.ioconf | 11 ++
12 files changed, 418 insertions(+), 111 deletions(-)
diffs (truncated from 605 to 300 lines):
diff -r 3865b5915878 -r 90514ce85e9e sys/dev/isa/lm_isa.c
--- a/sys/dev/isa/lm_isa.c Tue Jan 17 16:34:52 2012 +0000
+++ b/sys/dev/isa/lm_isa.c Tue Jan 17 16:50:07 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lm_isa.c,v 1.23 2010/02/21 05:16:29 cnst Exp $ */
+/* $NetBSD: lm_isa.c,v 1.24 2012/01/17 16:50:07 jakllsch Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,12 +30,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lm_isa.c,v 1.23 2010/02/21 05:16:29 cnst Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm_isa.c,v 1.24 2012/01/17 16:50:07 jakllsch Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
+#include <sys/module.h>
#include <sys/conf.h>
#include <sys/bus.h>
@@ -43,121 +44,36 @@
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
-#include <dev/sysmon/sysmonvar.h>
-
-#include <dev/ic/nslm7xvar.h>
-
-int lm_isa_match(device_t, cfdata_t, void *);
-void lm_isa_attach(device_t, device_t, void *);
-int lm_isa_detach(device_t, int);
-
-uint8_t lm_isa_readreg(struct lm_softc *, int);
-void lm_isa_writereg(struct lm_softc *, int, int);
-
-struct lm_isa_softc {
- struct lm_softc lmsc;
- bus_space_tag_t lm_iot;
- bus_space_handle_t lm_ioh;
-};
+#include <dev/isa/lm_isa_common_var.h>
CFATTACH_DECL_NEW(lm_isa, sizeof(struct lm_isa_softc),
lm_isa_match, lm_isa_attach, lm_isa_detach, NULL);
-CFATTACH_DECL_NEW(lm_wbsio, sizeof(struct lm_isa_softc),
- lm_isa_match, lm_isa_attach, lm_isa_detach, NULL);
-
-int
-lm_isa_match(device_t parent, cfdata_t match, void *aux)
-{
- bus_space_handle_t ioh;
- struct isa_attach_args *ia = aux;
- struct lm_isa_softc sc;
- int rv;
-
- /* Must supply an address */
- if (ia->ia_nio < 1)
- return 0;
-
- if (ISA_DIRECT_CONFIG(ia))
- return 0;
-
- if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
- return 0;
+MODULE(MODULE_CLASS_DRIVER, lm_isa, "lm_isa_common");
- if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 8, 0, &ioh))
- return 0;
-
-
- /* Bus independent probe */
- sc.lm_iot = ia->ia_iot;
- sc.lm_ioh = ioh;
- sc.lmsc.lm_writereg = lm_isa_writereg;
- sc.lmsc.lm_readreg = lm_isa_readreg;
- rv = lm_probe(&sc.lmsc);
-
- bus_space_unmap(ia->ia_iot, ioh, 8);
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
- if (rv) {
- ia->ia_nio = 1;
- ia->ia_io[0].ir_size = 8;
-
- ia->ia_niomem = 0;
- ia->ia_nirq = 0;
- ia->ia_ndrq = 0;
- }
-
- return rv;
-}
-
+static int
+lm_isa_modcmd(modcmd_t cmd, void *priv)
+{
+ int error = 0;
-void
-lm_isa_attach(device_t parent, device_t self, void *aux)
-{
- struct lm_isa_softc *sc = device_private(self);
- struct isa_attach_args *ia = aux;
-
- sc->lm_iot = ia->ia_iot;
-
- if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 8, 0,
- &sc->lm_ioh)) {
- aprint_error(": can't map i/o space\n");
- return;
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+#ifdef _MODULE
+ error = config_init_component(cfdriver_ioconf_lm_isa,
+ cfattach_ioconf_lm_isa, cfdata_ioconf_lm_isa);
+#endif
+ return error;
+ case MODULE_CMD_FINI:
+#ifdef _MODULE
+ error = config_fini_component(cfdriver_ioconf_lm_isa,
+ cfattach_ioconf_lm_isa, cfdata_ioconf_lm_isa);
+#endif
+ return error;
+ default:
+ return ENOTTY;
}
-
- /* Bus-independent attachment */
- sc->lmsc.sc_dev = self;
- sc->lmsc.lm_writereg = lm_isa_writereg;
- sc->lmsc.lm_readreg = lm_isa_readreg;
-
- lm_attach(&sc->lmsc);
}
-
-int
-lm_isa_detach(device_t self, int flags)
-{
- struct lm_isa_softc *sc = device_private(self);
-
- lm_detach(&sc->lmsc);
- bus_space_unmap(sc->lm_iot, sc->lm_ioh, 8);
- return 0;
-}
-
-uint8_t
-lm_isa_readreg(struct lm_softc *lmsc, int reg)
-{
- struct lm_isa_softc *sc = (struct lm_isa_softc *)lmsc;
-
- bus_space_write_1(sc->lm_iot, sc->lm_ioh, LMC_ADDR, reg);
- return bus_space_read_1(sc->lm_iot, sc->lm_ioh, LMC_DATA);
-}
-
-
-void
-lm_isa_writereg(struct lm_softc *lmsc, int reg, int val)
-{
- struct lm_isa_softc *sc = (struct lm_isa_softc *)lmsc;
-
- bus_space_write_1(sc->lm_iot, sc->lm_ioh, LMC_ADDR, reg);
- bus_space_write_1(sc->lm_iot, sc->lm_ioh, LMC_DATA, val);
-}
-
diff -r 3865b5915878 -r 90514ce85e9e sys/dev/isa/lm_isa_common.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/isa/lm_isa_common.c Tue Jan 17 16:50:07 2012 +0000
@@ -0,0 +1,172 @@
+/* $NetBSD: lm_isa_common.c,v 1.1 2012/01/17 16:50:07 jakllsch Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Bill Squier.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: lm_isa_common.c,v 1.1 2012/01/17 16:50:07 jakllsch Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/module.h>
+#include <sys/conf.h>
+
+#include <sys/bus.h>
+
+#include <dev/isa/isareg.h>
+#include <dev/isa/isavar.h>
+
+#include <dev/ic/nslm7xvar.h>
+
+int lm_isa_match(device_t, cfdata_t, void *);
+void lm_isa_attach(device_t, device_t, void *);
+int lm_isa_detach(device_t, int);
+
+static uint8_t lm_isa_readreg(struct lm_softc *, int);
+static void lm_isa_writereg(struct lm_softc *, int, int);
+
+struct lm_isa_softc {
+ struct lm_softc lmsc;
+ bus_space_tag_t lm_iot;
+ bus_space_handle_t lm_ioh;
+};
+
+#if 0
+CFATTACH_DECL_NEW(lm_isa, sizeof(struct lm_isa_softc),
+ lm_isa_match, lm_isa_attach, lm_isa_detach, NULL);
+
+CFATTACH_DECL_NEW(lm_wbsio, sizeof(struct lm_isa_softc),
+ lm_isa_match, lm_isa_attach, lm_isa_detach, NULL);
+#endif
+
+int
+lm_isa_match(device_t parent, cfdata_t match, void *aux)
+{
+ bus_space_handle_t ioh;
+ struct isa_attach_args *ia = aux;
+ struct lm_isa_softc sc;
+ int rv;
+
+ /* Must supply an address */
+ if (ia->ia_nio < 1)
+ return 0;
+
+ if (ISA_DIRECT_CONFIG(ia))
+ return 0;
+
+ if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
+ return 0;
+
+ if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 8, 0, &ioh))
+ return 0;
+
+
+ /* Bus independent probe */
+ sc.lm_iot = ia->ia_iot;
+ sc.lm_ioh = ioh;
+ sc.lmsc.lm_writereg = lm_isa_writereg;
+ sc.lmsc.lm_readreg = lm_isa_readreg;
+ rv = lm_probe(&sc.lmsc);
+
+ bus_space_unmap(ia->ia_iot, ioh, 8);
+
+ if (rv) {
+ ia->ia_nio = 1;
+ ia->ia_io[0].ir_size = 8;
+
+ ia->ia_niomem = 0;
+ ia->ia_nirq = 0;
+ ia->ia_ndrq = 0;
+ }
+
+ return rv;
+}
+
+
+void
+lm_isa_attach(device_t parent, device_t self, void *aux)
+{
+ struct lm_isa_softc *sc = device_private(self);
+ struct isa_attach_args *ia = aux;
+
+ sc->lm_iot = ia->ia_iot;
+
+ if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 8, 0,
+ &sc->lm_ioh)) {
+ aprint_error(": can't map i/o space\n");
+ return;
+ }
Home |
Main Index |
Thread Index |
Old Index