Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Dec 2009 21:53:20 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r201005 - in head/sys: dev/mk48txx sparc64/sparc64
Message-ID:  <200912252153.nBPLrK89072584@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Fri Dec 25 21:53:20 2009
New Revision: 201005
URL: http://svn.freebsd.org/changeset/base/201005

Log:
  - Take advantage of bus_{read,write}_*(9).
  - Set dow = -1 in mk48txx_gettime() because some drivers (for example
    the NetBSD and OpenBSD mk48txx(4)) don't set it correctly.

Modified:
  head/sys/dev/mk48txx/mk48txx.c
  head/sys/dev/mk48txx/mk48txxvar.h
  head/sys/sparc64/sparc64/eeprom.c

Modified: head/sys/dev/mk48txx/mk48txx.c
==============================================================================
--- head/sys/dev/mk48txx/mk48txx.c	Fri Dec 25 21:41:05 2009	(r201004)
+++ head/sys/dev/mk48txx/mk48txx.c	Fri Dec 25 21:53:20 2009	(r201005)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/eventhandler.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
+#include <sys/rman.h>
 #include <sys/watchdog.h>
 
 #include <machine/bus.h>
@@ -175,8 +176,16 @@ mk48txx_gettime(device_t dev, struct tim
 	ct.min = FROMBCD(FROMREG(MK48TXX_IMIN, MK48TXX_MIN_MASK));
 	ct.hour = FROMBCD(FROMREG(MK48TXX_IHOUR, MK48TXX_HOUR_MASK));
 	ct.day = FROMBCD(FROMREG(MK48TXX_IDAY, MK48TXX_DAY_MASK));
+#if 0
 	/* Map dow from 1 - 7 to 0 - 6; FROMBCD() isn't necessary here. */
 	ct.dow = FROMREG(MK48TXX_IWDAY, MK48TXX_WDAY_MASK) - 1;
+#else
+	/*
+	 * Set dow = -1 because some drivers (for example the NetBSD and
+	 * OpenBSD mk48txx(4)) don't set it correctly.
+	 */
+	ct.dow = - 1;
+#endif
 	ct.mon = FROMBCD(FROMREG(MK48TXX_IMON, MK48TXX_MON_MASK));
 	year = FROMBCD(FROMREG(MK48TXX_IYEAR, MK48TXX_YEAR_MASK));
 	year += sc->sc_year0;
@@ -266,7 +275,7 @@ mk48txx_def_nvrd(device_t dev, int off)
 	struct mk48txx_softc *sc;
 
 	sc = device_get_softc(dev);
-	return (bus_space_read_1(sc->sc_bst, sc->sc_bsh, off));
+	return (bus_read_1(sc->sc_res, off));
 }
 
 static void
@@ -275,7 +284,7 @@ mk48txx_def_nvwr(device_t dev, int off, 
 	struct mk48txx_softc *sc;
 
 	sc = device_get_softc(dev);
-	bus_space_write_1(sc->sc_bst, sc->sc_bsh, off, v);
+	bus_write_1(sc->sc_res, off, v);
 }
 
 static void

Modified: head/sys/dev/mk48txx/mk48txxvar.h
==============================================================================
--- head/sys/dev/mk48txx/mk48txxvar.h	Fri Dec 25 21:41:05 2009	(r201004)
+++ head/sys/dev/mk48txx/mk48txxvar.h	Fri Dec 25 21:53:20 2009	(r201005)
@@ -35,8 +35,7 @@ typedef uint8_t (*mk48txx_nvrd_t)(device
 typedef void (*mk48txx_nvwr_t)(device_t dev, int off, uint8_t v);
 
 struct mk48txx_softc {
-	bus_space_tag_t		sc_bst;	/* bus space tag */
-	bus_space_handle_t	sc_bsh;	/* bus space handle */
+	struct resource		*sc_res;/* bus resource */
 
 	struct mtx		sc_mtx;	/* hardware mutex */
 	eventhandler_tag	sc_wet;	/* watchdog event handler tag */

Modified: head/sys/sparc64/sparc64/eeprom.c
==============================================================================
--- head/sys/sparc64/sparc64/eeprom.c	Fri Dec 25 21:41:05 2009	(r201004)
+++ head/sys/sparc64/sparc64/eeprom.c	Fri Dec 25 21:53:20 2009	(r201005)
@@ -107,7 +107,7 @@ DRIVER_MODULE(eeprom, sbus, eeprom_drive
 static int
 eeprom_probe(device_t dev)
 {
- 
+
 	if (strcmp("eeprom", ofw_bus_get_name(dev)) == 0) {
 		device_set_desc(dev, "EEPROM/clock");
 		return (0);
@@ -134,8 +134,6 @@ eeprom_attach(device_t dev)
 		error = ENXIO;
 		goto fail_mtx;
 	}
-	sc->sc_bst = rman_get_bustag(res);
-	sc->sc_bsh = rman_get_bushandle(res);
 
 	if ((sc->sc_model = ofw_bus_get_model(dev)) == NULL) {
 		device_printf(dev, "cannot determine model\n");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912252153.nBPLrK89072584>