aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/powermac_nvram/powermac_nvram.c
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-04-14 13:18:39 +0000
committerEd Schouten <ed@FreeBSD.org>2009-04-14 13:18:39 +0000
commit907859721048646fe50d114391a2bbe5a664d97d (patch)
tree7c3878326b6346fd179513a4fca967e8a47e9a24 /sys/dev/powermac_nvram/powermac_nvram.c
parentb7d9e67c451bef449bbeadda218c690fef81baa6 (diff)
downloadsrc-907859721048646fe50d114391a2bbe5a664d97d.tar.gz
src-907859721048646fe50d114391a2bbe5a664d97d.zip
Use si_drv1 instead of dev2unit() in powermac_nvram.
Reviewed by: nwhitehorn
Notes
Notes: svn path=/head/; revision=191058
Diffstat (limited to 'sys/dev/powermac_nvram/powermac_nvram.c')
-rw-r--r--sys/dev/powermac_nvram/powermac_nvram.c20
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;