Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/evbppc/walnut/dev - convert to use device_t, cfatta...
details: https://anonhg.NetBSD.org/src/rev/8124b6d844d0
branches: trunk
changeset: 766081:8124b6d844d0
user: cliff <cliff%NetBSD.org@localhost>
date: Wed Jun 15 05:29:32 2011 +0000
description:
- convert to use device_t, cfattach_t, CFATTACH_DECL_NEW etc.
- in dsrtcattach() use struct clock_ymdhms instead of rtc in DEBUG code block,
and move that block down after sc_todr.cookie is initialized so dsrtc_read() works.
diffstat:
sys/arch/evbppc/walnut/dev/ds1743.c | 36 +++++++++++++++++++-----------------
1 files changed, 19 insertions(+), 17 deletions(-)
diffs (100 lines):
diff -r 3762dfb913ce -r 8124b6d844d0 sys/arch/evbppc/walnut/dev/ds1743.c
--- a/sys/arch/evbppc/walnut/dev/ds1743.c Wed Jun 15 05:21:38 2011 +0000
+++ b/sys/arch/evbppc/walnut/dev/ds1743.c Wed Jun 15 05:29:32 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ds1743.c,v 1.7 2006/09/18 22:05:47 gdamore Exp $ */
+/* $NetBSD: ds1743.c,v 1.8 2011/06/15 05:29:32 cliff Exp $ */
/*
* Copyright (c) 2001-2002 Wasabi Sysetms, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ds1743.c,v 1.7 2006/09/18 22:05:47 gdamore Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ds1743.c,v 1.8 2011/06/15 05:29:32 cliff Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -52,14 +52,14 @@
#include <evbppc/walnut/dev/pbusvar.h>
struct dsrtc_softc {
- struct device sc_dev;
+ device_t sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
struct todr_chip_handle sc_todr;
};
-static void dsrtcattach(struct device *, struct device *, void *);
-static int dsrtcmatch(struct device *, struct cfdata *, void *);
+static void dsrtcattach(device_t, device_t, void *);
+static int dsrtcmatch(device_t, cfdata_t, void *);
#if 0 /* Nothing uses these yet */
static int ds1743_ram_read(struct dsrtc_softc *, int);
static void ds1743_ram_write(struct dsrtc_softc *, int, int);
@@ -73,7 +73,7 @@
static void ds1743_unlock(struct dsrtc_softc *, u_char);
/* device and attach structures */
-CFATTACH_DECL(ds1743rtc, sizeof(struct dsrtc_softc),
+CFATTACH_DECL_NEW(ds1743rtc, sizeof(struct dsrtc_softc),
dsrtcmatch, dsrtcattach, NULL, NULL);
/*
@@ -86,7 +86,7 @@
#define DS_SCRATCH_ADDR 0x1FF7
static int
-dsrtcmatch(struct device *parent, struct cfdata *cf, void *aux)
+dsrtcmatch(device_t parent, cfdata_t cf, void *aux)
{
struct pbus_attach_args *paa = aux;
int retval = !ds1743found;
@@ -131,13 +131,14 @@
*/
static void
-dsrtcattach(struct device *parent, struct device *self, void *aux)
+dsrtcattach(device_t parent, device_t self, void *aux)
{
- struct dsrtc_softc *sc = (struct dsrtc_softc *)self;
+ struct dsrtc_softc *sc = device_private(self);
struct pbus_attach_args *paa = aux;
ds1743found = 1;
+ sc->sc_dev = self;
sc->sc_iot = paa->pb_bt;
if (bus_space_map(sc->sc_iot, paa->pb_addr, DS_SIZE, 0, &sc->sc_ioh)) {
printf(": can't map i/o space\n");
@@ -149,19 +150,20 @@
printf(": lithium cell is dead, RTC unreliable");
printf("\n");
+ sc->sc_todr.todr_gettime_ymdhms = dsrtc_read;
+ sc->sc_todr.todr_settime_ymdhms = dsrtc_write;
+ sc->sc_todr.cookie = sc;
+
#ifdef DEBUG
{
- rtc_t rtc;
- dsrtc_read(sc, &rtc);
- printf("RTC: %d/%d/%02d%02d %d:%02d:%02d\n",
- rtc.rtc_mon, rtc.rtc_day, rtc.rtc_cen, rtc.rtc_year,
- rtc.rtc_hour, rtc.rtc_min, rtc.rtc_sec);
+ struct clock_ymdhms dt;
+ dsrtc_read(&sc->sc_todr, &dt);
+ printf("RTC: %d/%d/%04d %d:%02d:%02d\n",
+ dt.dt_mon, dt.dt_day, dt.dt_year,
+ dt.dt_hour, dt.dt_min, dt.dt_sec);
}
#endif
- sc->sc_todr.todr_gettime_ymdhms = dsrtc_read;
- sc->sc_todr.todr_settime_ymdhms = dsrtc_write;
- sc->sc_todr.cookie = sc;
todr_attach(&sc->sc_todr);
}
Home |
Main Index |
Thread Index |
Old Index