Use si_drv1 instead of dev2unit() in powermac_nvram.

Reviewed by:	nwhitehorn
This commit is contained in:
Ed Schouten 2009-04-14 13:18:39 +00:00
parent b7d9e67c45
commit 9078597210
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=191058

View file

@ -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;