diff options
Diffstat (limited to 'sys/dev/powermac_nvram/powermac_nvram.c')
-rw-r--r-- | sys/dev/powermac_nvram/powermac_nvram.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/sys/dev/powermac_nvram/powermac_nvram.c b/sys/dev/powermac_nvram/powermac_nvram.c index f6e930b98c00..22174f9e04be 100644 --- a/sys/dev/powermac_nvram/powermac_nvram.c +++ b/sys/dev/powermac_nvram/powermac_nvram.c @@ -89,10 +89,6 @@ DRIVER_MODULE(powermac_nvram, nexus, powermac_nvram_driver, powermac_nvram_devcl * 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, int flags, int fmt, struct thread *td) 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; |