Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jan 2010 15:47:32 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r202385 - in stable/7/sys: dev/mk48txx sparc64/sparc64
Message-ID:  <201001151547.o0FFlWFx017053@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Fri Jan 15 15:47:31 2010
New Revision: 202385
URL: http://svn.freebsd.org/changeset/base/202385

Log:
  MFC: r201005, r201371
  
  - 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:
  stable/7/sys/dev/mk48txx/mk48txx.c
  stable/7/sys/dev/mk48txx/mk48txxvar.h
  stable/7/sys/sparc64/sparc64/eeprom.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/dev/mk48txx/mk48txx.c
==============================================================================
--- stable/7/sys/dev/mk48txx/mk48txx.c	Fri Jan 15 15:47:31 2010	(r202384)
+++ stable/7/sys/dev/mk48txx/mk48txx.c	Fri Jan 15 15:47:31 2010	(r202385)
@@ -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: stable/7/sys/dev/mk48txx/mk48txxvar.h
==============================================================================
--- stable/7/sys/dev/mk48txx/mk48txxvar.h	Fri Jan 15 15:47:31 2010	(r202384)
+++ stable/7/sys/dev/mk48txx/mk48txxvar.h	Fri Jan 15 15:47:31 2010	(r202385)
@@ -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: stable/7/sys/sparc64/sparc64/eeprom.c
==============================================================================
--- stable/7/sys/sparc64/sparc64/eeprom.c	Fri Jan 15 15:47:31 2010	(r202384)
+++ stable/7/sys/sparc64/sparc64/eeprom.c	Fri Jan 15 15:47:31 2010	(r202385)
@@ -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);
@@ -119,7 +119,6 @@ static int
 eeprom_attach(device_t dev)
 {
 	struct mk48txx_softc *sc;
-	struct resource *res;
 	struct timespec ts;
 	int error, rid;
 
@@ -128,14 +127,13 @@ eeprom_attach(device_t dev)
 	mtx_init(&sc->sc_mtx, "eeprom_mtx", NULL, MTX_DEF);
 
 	rid = 0;
-	res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
-	if (res == NULL) {
+	sc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
+	    RF_ACTIVE);
+	if (sc->sc_res == NULL) {
 		device_printf(dev, "cannot allocate resources\n");
 		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");
@@ -180,7 +178,7 @@ eeprom_attach(device_t dev)
 	return (0);
 
  fail_res:
-	bus_release_resource(dev, SYS_RES_MEMORY, rid, res);
+	bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->sc_res);
  fail_mtx:
 	mtx_destroy(&sc->sc_mtx);
 



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