Author: ed
Date: Tue Apr 14 13:18:39 2009
New Revision: 191058
URL: http://svn.freebsd.org/changeset/base/191058

Log:
  Use si_drv1 instead of dev2unit() in powermac_nvram.
  
  Reviewed by:  nwhitehorn

Modified:
  head/sys/dev/powermac_nvram/powermac_nvram.c

Modified: head/sys/dev/powermac_nvram/powermac_nvram.c
==============================================================================
--- head/sys/dev/powermac_nvram/powermac_nvram.c        Tue Apr 14 13:11:34 
2009        (r191057)
+++ head/sys/dev/powermac_nvram/powermac_nvram.c        Tue Apr 14 13:18:39 
2009        (r191058)
@@ -89,10 +89,6 @@ DRIVER_MODULE(powermac_nvram, nexus, pow
  * Cdev methods.
  */
 
-#define        NVRAM_UNIT(dev)         dev2unit(dev)
-#define        NVRAM_SOFTC(unit)       ((struct powermac_nvram_softc *) \
-     devclass_get_softc(powermac_nvram_devclass, unit))
-
 static d_open_t        powermac_nvram_open;
 static d_close_t       powermac_nvram_close;
 static d_read_t        powermac_nvram_read;
@@ -169,6 +165,7 @@ powermac_nvram_attach(device_t dev)
 
        sc->sc_cdev = make_dev(&powermac_nvram_cdevsw, 0, 0, 0, 0600,
            "powermac_nvram");
+       sc->sc_cdev->si_drv1 = sc;
 
        return 0;
 }
@@ -192,9 +189,8 @@ powermac_nvram_detach(device_t dev)
 static int
 powermac_nvram_open(struct cdev *dev, int flags, int fmt, struct thread *td)
 {
-       struct powermac_nvram_softc *sc;
+       struct powermac_nvram_softc *sc = dev->si_drv1;
 
-       sc = NVRAM_SOFTC(NVRAM_UNIT(dev));
        if (sc->sc_isopen)
                return EBUSY;
        sc->sc_isopen = 1;
@@ -205,12 +201,10 @@ powermac_nvram_open(struct cdev *dev, in
 static int
 powermac_nvram_close(struct cdev *dev, int fflag, int devtype, struct thread 
*td)
 {
-       struct powermac_nvram_softc *sc;
+       struct powermac_nvram_softc *sc = dev->si_drv1;
        struct core99_header *header;
        vm_offset_t bank;
 
-       sc = NVRAM_SOFTC(NVRAM_UNIT(dev));
-
        if (sc->sc_wpos != sizeof(sc->sc_data)) {
                /* Short write, restore in-memory copy */
                bcopy((void *)sc->sc_bank, (void *)sc->sc_data, NVRAM_SIZE);
@@ -246,9 +240,7 @@ static int
 powermac_nvram_read(struct cdev *dev, struct uio *uio, int ioflag)
 {
        int rv, amnt, data_available;
-       struct powermac_nvram_softc *sc;
-
-       sc = NVRAM_SOFTC(NVRAM_UNIT(dev));
+       struct powermac_nvram_softc *sc = dev->si_drv1;
 
        rv = 0;
        while (uio->uio_resid > 0) {
@@ -271,9 +263,7 @@ static int
 powermac_nvram_write(struct cdev *dev, struct uio *uio, int ioflag)
 {
        int rv, amnt, data_available;
-       struct powermac_nvram_softc *sc;
-
-       sc = NVRAM_SOFTC(NVRAM_UNIT(dev));
+       struct powermac_nvram_softc *sc = dev->si_drv1;
 
        if (sc->sc_wpos >= sizeof(sc->sc_data))
                return EINVAL;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to