Make mse(4) use si_drv1, instead of using unit numbers.
Discussed with: imp
This commit is contained in:
parent
6fae832ad7
commit
2034e6a11f
@ -111,8 +111,7 @@ static struct cdevsw mse_cdevsw = {
|
|||||||
static void mseintr(void *);
|
static void mseintr(void *);
|
||||||
static timeout_t msetimeout;
|
static timeout_t msetimeout;
|
||||||
|
|
||||||
#define MSE_UNIT(dev) (dev2unit(dev) >> 1)
|
#define MSE_NBLOCKIO(dev) dev2unit(dev)
|
||||||
#define MSE_NBLOCKIO(dev) (dev2unit(dev) & 0x1)
|
|
||||||
|
|
||||||
#define MSEPRI (PZERO + 3)
|
#define MSEPRI (PZERO + 3)
|
||||||
|
|
||||||
@ -143,10 +142,10 @@ mse_common_attach(device_t dev)
|
|||||||
sc->mode.accelfactor = (flags & MSE_CONFIG_ACCEL) >> 4;
|
sc->mode.accelfactor = (flags & MSE_CONFIG_ACCEL) >> 4;
|
||||||
callout_handle_init(&sc->sc_callout);
|
callout_handle_init(&sc->sc_callout);
|
||||||
|
|
||||||
sc->sc_dev = make_dev(&mse_cdevsw, unit << 1, 0, 0, 0600,
|
sc->sc_dev = make_dev(&mse_cdevsw, 0, 0, 0, 0600, "mse%d", unit);
|
||||||
"mse%d", unit);
|
sc->sc_dev->si_drv1 = sc;
|
||||||
sc->sc_ndev = make_dev(&mse_cdevsw, (unit<<1)+1, 0, 0, 0600,
|
sc->sc_ndev = make_dev(&mse_cdevsw, 1, 0, 0, 0600, "nmse%d", unit);
|
||||||
"nmse%d", unit);
|
sc->sc_ndev->si_drv1 = sc;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,12 +155,9 @@ mse_common_attach(device_t dev)
|
|||||||
static int
|
static int
|
||||||
mseopen(struct cdev *dev, int flags, int fmt, struct thread *td)
|
mseopen(struct cdev *dev, int flags, int fmt, struct thread *td)
|
||||||
{
|
{
|
||||||
mse_softc_t *sc;
|
mse_softc_t *sc = dev->si_drv1;
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev));
|
|
||||||
if (sc == NULL)
|
|
||||||
return (ENXIO);
|
|
||||||
if (sc->sc_mousetype == MSE_NONE)
|
if (sc->sc_mousetype == MSE_NONE)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
if (sc->sc_flags & MSESC_OPEN)
|
if (sc->sc_flags & MSESC_OPEN)
|
||||||
@ -192,7 +188,7 @@ mseopen(struct cdev *dev, int flags, int fmt, struct thread *td)
|
|||||||
static int
|
static int
|
||||||
mseclose(struct cdev *dev, int flags, int fmt, struct thread *td)
|
mseclose(struct cdev *dev, int flags, int fmt, struct thread *td)
|
||||||
{
|
{
|
||||||
mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev));
|
mse_softc_t *sc = dev->si_drv1;
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
untimeout(msetimeout, dev, sc->sc_callout);
|
untimeout(msetimeout, dev, sc->sc_callout);
|
||||||
@ -212,7 +208,7 @@ mseclose(struct cdev *dev, int flags, int fmt, struct thread *td)
|
|||||||
static int
|
static int
|
||||||
mseread(struct cdev *dev, struct uio *uio, int ioflag)
|
mseread(struct cdev *dev, struct uio *uio, int ioflag)
|
||||||
{
|
{
|
||||||
mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev));
|
mse_softc_t *sc = dev->si_drv1;
|
||||||
int xfer, s, error;
|
int xfer, s, error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -276,7 +272,7 @@ mseread(struct cdev *dev, struct uio *uio, int ioflag)
|
|||||||
static int
|
static int
|
||||||
mseioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
mseioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||||
{
|
{
|
||||||
mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev));
|
mse_softc_t *sc = dev->si_drv1;
|
||||||
mousestatus_t status;
|
mousestatus_t status;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int s;
|
int s;
|
||||||
@ -388,7 +384,7 @@ mseioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td
|
|||||||
static int
|
static int
|
||||||
msepoll(struct cdev *dev, int events, struct thread *td)
|
msepoll(struct cdev *dev, int events, struct thread *td)
|
||||||
{
|
{
|
||||||
mse_softc_t *sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev));
|
mse_softc_t *sc = dev->si_drv1;
|
||||||
int s;
|
int s;
|
||||||
int revents = 0;
|
int revents = 0;
|
||||||
|
|
||||||
@ -420,10 +416,10 @@ msetimeout(void *arg)
|
|||||||
mse_softc_t *sc;
|
mse_softc_t *sc;
|
||||||
|
|
||||||
dev = (struct cdev *)arg;
|
dev = (struct cdev *)arg;
|
||||||
sc = devclass_get_softc(mse_devclass, MSE_UNIT(dev));
|
sc = dev->si_drv1;
|
||||||
if (sc->sc_watchdog) {
|
if (sc->sc_watchdog) {
|
||||||
if (bootverbose)
|
if (bootverbose)
|
||||||
printf("mse%d: lost interrupt?\n", MSE_UNIT(dev));
|
printf("%s: lost interrupt?\n", devtoname(dev));
|
||||||
mseintr(sc);
|
mseintr(sc);
|
||||||
}
|
}
|
||||||
sc->sc_watchdog = TRUE;
|
sc->sc_watchdog = TRUE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user