Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/atari Split device_t/softc. Compile test only.



details:   https://anonhg.NetBSD.org/src/rev/9963447baf93
branches:  trunk
changeset: 765918:9963447baf93
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Fri Jun 10 09:27:51 2011 +0000

description:
Split device_t/softc. Compile test only.

diffstat:

 sys/arch/atari/dev/hdfd.c        |  100 ++++++++++++++++++++------------------
 sys/arch/atari/isa/isa_machdep.c |   32 ++++++-----
 sys/arch/atari/vme/et4000.c      |   22 ++++---
 3 files changed, 81 insertions(+), 73 deletions(-)

diffs (truncated from 481 to 300 lines):

diff -r 76559778d090 -r 9963447baf93 sys/arch/atari/dev/hdfd.c
--- a/sys/arch/atari/dev/hdfd.c Fri Jun 10 04:45:41 2011 +0000
+++ b/sys/arch/atari/dev/hdfd.c Fri Jun 10 09:27:51 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hdfd.c,v 1.73 2010/04/13 11:31:11 tsutsui Exp $        */
+/*     $NetBSD: hdfd.c,v 1.74 2011/06/10 09:27:51 tsutsui Exp $        */
 
 /*-
  * Copyright (c) 1996 Leo Weppelman
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdfd.c,v 1.73 2010/04/13 11:31:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdfd.c,v 1.74 2011/06/10 09:27:51 tsutsui Exp $");
 
 #include "opt_ddb.h"
 
@@ -188,7 +188,7 @@
 
 /* software state, per controller */
 struct fdc_softc {
-       struct device   sc_dev;         /* boilerplate */
+       device_t        sc_dev;         /* boilerplate */
 
        struct callout sc_timo_ch;      /* timeout callout */
        struct callout sc_intr_ch;      /* pseudo-intr callout */
@@ -202,11 +202,11 @@
 };
 
 /* controller driver configuration */
-int    fdcprobe(struct device *, struct cfdata *, void *);
+int    fdcprobe(device_t, cfdata_t, void *);
 int    fdprint(void *, const char *);
-void   fdcattach(struct device *, struct device *, void *);
+void   fdcattach(device_t, device_t, void *);
 
-CFATTACH_DECL(fdc, sizeof(struct fdc_softc),
+CFATTACH_DECL_NEW(fdc, sizeof(struct fdc_softc),
     fdcprobe, fdcattach, NULL, NULL);
 
 /*
@@ -246,7 +246,7 @@
 
 /* software state, per disk (with up to 4 disks per ctlr) */
 struct fd_softc {
-       struct device   sc_dev;
+       device_t        sc_dev;
        struct disk     sc_dk;
 
        struct fd_type  *sc_deftype;    /* default type descriptor */
@@ -279,10 +279,10 @@
 };
 
 /* floppy driver configuration */
-int    fdprobe(struct device *, struct cfdata *, void *);
-void   fdattach(struct device *, struct device *, void *);
+int    fdprobe(device_t, cfdata_t, void *);
+void   fdattach(device_t, device_t, void *);
 
-CFATTACH_DECL(hdfd, sizeof(struct fd_softc),
+CFATTACH_DECL_NEW(hdfd, sizeof(struct fd_softc),
     fdprobe, fdattach, NULL, NULL);
 
 const struct bdevsw fd_bdevsw = {
@@ -298,29 +298,28 @@
 
 struct dkdriver fddkdriver = { fdstrategy };
 
-void   fd_set_motor(struct fdc_softc *fdc, int reset);
-void   fd_motor_off(void *arg);
-void   fd_motor_on(void *arg);
-int    fdcresult(struct fdc_softc *fdc);
-int    out_fdc(u_char x);
+void   fd_set_motor(struct fdc_softc *, int);
+void   fd_motor_off(void *);
+void   fd_motor_on(void *);
+int    fdcresult(struct fdc_softc *);
+int    out_fdc(u_char);
 void   fdc_ctrl_intr(struct clockframe);
-void   fdcstart(struct fdc_softc *fdc);
-void   fdcstatus(struct device *dv, int n, const char *s);
-void   fdctimeout(void *arg);
-void   fdcpseudointr(void *arg);
+void   fdcstart(struct fdc_softc *);
+void   fdcstatus(device_t, int, const char *);
+void   fdctimeout(void *);
+void   fdcpseudointr(void *);
 int    fdcintr(void *);
-void   fdcretry(struct fdc_softc *fdc);
-void   fdfinish(struct fd_softc *fd, struct buf *bp);
+void   fdcretry(struct fdc_softc *);
+void   fdfinish(struct fd_softc *, struct buf *);
 int    fdformat(dev_t, struct ne7_fd_formb *, struct proc *);
 
 static void    fdgetdisklabel(struct fd_softc *, dev_t);
-static void    fdgetdefaultlabel(struct fd_softc *, struct disklabel *,
-                   int);
+static void    fdgetdefaultlabel(struct fd_softc *, struct disklabel *, int);
 
 inline struct fd_type *fd_dev_to_type(struct fd_softc *, dev_t);
 
 int
-fdcprobe(struct device *parent, struct cfdata *cfp, void *aux)
+fdcprobe(device_t parent, cfdata_t cf, void *aux)
 {
        static int      fdc_matched = 0;
        bus_space_tag_t mb_tag;
@@ -395,14 +394,15 @@
 }
 
 void
-fdcattach(struct device *parent, struct device *self, void *aux)
+fdcattach(device_t parent, device_t self, void *aux)
 {
-       struct fdc_softc        *fdc = (void *)self;
+       struct fdc_softc        *fdc = device_private(self);
        struct fdc_attach_args  fa;
        int                     has_fifo;
 
        has_fifo = 0;
 
+       fdc->sc_dev = self;
        fdc->sc_state = DEVIDLE;
        TAILQ_INIT(&fdc->sc_drives);
 
@@ -450,22 +450,22 @@
 }
 
 int
-fdprobe(struct device *parent, struct cfdata *cfp, void *aux)
+fdprobe(device_t parent, cfdata_t cf, void *aux)
 {
-       struct fdc_softc        *fdc = (void *)parent;
+       struct fdc_softc        *fdc = device_private(parent);
        struct fdc_attach_args  *fa = aux;
        int                     drive = fa->fa_drive;
        int                     n;
 
-       if (cfp->cf_loc[FDCCF_UNIT] != FDCCF_UNIT_DEFAULT &&
-           cfp->cf_loc[FDCCF_UNIT] != drive)
+       if (cf->cf_loc[FDCCF_UNIT] != FDCCF_UNIT_DEFAULT &&
+           cf->cf_loc[FDCCF_UNIT] != drive)
                return 0;
        /*
         * XXX
         * This is to work around some odd interactions between this driver
         * and SMC Ethernet cards.
         */
-       if (cfp->cf_loc[FDCCF_UNIT] == FDCCF_UNIT_DEFAULT && drive >= 2)
+       if (cf->cf_loc[FDCCF_UNIT] == FDCCF_UNIT_DEFAULT && drive >= 2)
                return 0;
 
        /* select drive and turn on motor */
@@ -503,14 +503,15 @@
  * Controller is working, and drive responded.  Attach it.
  */
 void
-fdattach(struct device *parent, struct device *self, void *aux)
+fdattach(device_t parent, device_t self, void *aux)
 {
-       struct fdc_softc        *fdc  = (void *)parent;
-       struct fd_softc         *fd   = (void *)self;
+       struct fdc_softc        *fdc  = device_private(parent);
+       struct fd_softc         *fd   = device_private(self);
        struct fdc_attach_args  *fa   = aux;
        struct fd_type          *type = fa->fa_deftype;
        int                     drive = fa->fa_drive;
 
+       fd->sc_dev = self;
        callout_init(&fd->sc_motoron_ch, 0);
        callout_init(&fd->sc_motoroff_ch, 0);
 
@@ -531,7 +532,7 @@
        /*
         * Initialize and attach the disk structure.
         */
-       disk_init(&fd->sc_dk, fd->sc_dev.dv_xname, &fddkdriver);
+       disk_init(&fd->sc_dk, device_xname(self), &fddkdriver);
        disk_attach(&fd->sc_dk);
 
        /* Needed to power off if the motor is on when we halt. */
@@ -635,7 +636,9 @@
                fdstart(fd);
 #ifdef DIAGNOSTIC
        else {
-               struct fdc_softc *fdc = (void *) device_parent(&fd->sc_dev);
+               struct fdc_softc *fdc;
+
+               fdc = device_private(device_parent(fd->sc_dev));
                if (fdc->sc_state == DEVIDLE) {
                        printf("fdstrategy: controller inactive\n");
                        fdcstart(fdc);
@@ -654,7 +657,7 @@
 void
 fdstart(struct fd_softc *fd)
 {
-       struct fdc_softc *fdc = (void *) device_parent(&fd->sc_dev);
+       struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
        int active = fdc->sc_drives.tqh_first != 0;
 
        /* Link into controller queue. */
@@ -669,7 +672,7 @@
 void
 fdfinish(struct fd_softc *fd, struct buf *bp)
 {
-       struct fdc_softc *fdc = (void *) device_parent(&fd->sc_dev);
+       struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
 
        /*
         * Move this drive to the end of the queue to give others a `fair'
@@ -732,11 +735,12 @@
 fd_motor_off(void *arg)
 {
        struct fd_softc *fd = arg;
+       struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
        int s;
 
        s = splbio();
        fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
-       fd_set_motor((struct fdc_softc *) device_parent(&fd->sc_dev), 0);
+       fd_set_motor(fdc, 0);
        splx(s);
 }
 
@@ -744,7 +748,7 @@
 fd_motor_on(void *arg)
 {
        struct fd_softc *fd = arg;
-       struct fdc_softc *fdc = (void *) device_parent(&fd->sc_dev);
+       struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
        int s;
 
        s = splbio();
@@ -858,9 +862,9 @@
 }
 
 void
-fdcstatus(struct device *dv, int n, const char *s)
+fdcstatus(device_t self, int n, const char *s)
 {
-       struct fdc_softc *fdc = (void *) device_parent(dv);
+       struct fdc_softc *fdc = device_private(device_parent(self));
        char bits[64];
 
        if (n == 0) {
@@ -869,7 +873,7 @@
                n = 2;
        }
 
-       printf("%s: %s", dv->dv_xname, s);
+       printf("%s: %s", device_xname(self), s);
 
        switch (n) {
        case 0:
@@ -898,7 +902,7 @@
        int s;
 
        s = splbio();
-       fdcstatus(&fd->sc_dev, 0, "timeout");
+       fdcstatus(fd->sc_dev, 0, "timeout");
 
        if (bufq_peek(fd->sc_q) != NULL)
                fdc->sc_state++;
@@ -1105,7 +1109,7 @@
                if (fdcresult(fdc) != 2 || (st0 & 0xf8) != 0x20 ||
                    cyl != bp->b_cylinder * fd->sc_type->step) {
 #ifdef FD_DEBUG
-                       fdcstatus(&fd->sc_dev, 2, "seek failed");
+                       fdcstatus(fd->sc_dev, 2, "seek failed");
 #endif
                        fdcretry(fdc);
                        goto loop;
@@ -1136,7 +1140,7 @@
                                goto loop;
                        }
 #ifdef FD_DEBUG
-                       fdcstatus(&fd->sc_dev, 7, bp->b_flags & B_READ ?
+                       fdcstatus(fd->sc_dev, 7, bp->b_flags & B_READ ?
                            "read failed" : "write failed");
                        printf("blkno %qd nblks %d\n",
                            fd->sc_blkno, fd->sc_nblks);
@@ -1199,7 +1203,7 @@
                out_fdc(NE7CMD_SENSEI);
                if (fdcresult(fdc) != 2 || (st0 & 0xf8) != 0x20 || cyl != 0) {
 #ifdef FD_DEBUG
-                       fdcstatus(&fd->sc_dev, 2, "recalibrate failed");
+                       fdcstatus(fd->sc_dev, 2, "recalibrate failed");
 #endif
                        fdcretry(fdc);
                        goto loop;
@@ -1213,7 +1217,7 @@
                goto doseek;
 
        default:
-               fdcstatus(&fd->sc_dev, 0, "stray interrupt");
+               fdcstatus(fd->sc_dev, 0, "stray interrupt");
                return 1;
        }
 #ifdef DIAGNOSTIC



Home | Main Index | Thread Index | Old Index