diff options
author | peter <peter@FreeBSD.org> | 2000-01-23 14:41:04 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2000-01-23 14:41:04 +0000 |
commit | 6ac7d76dbc27d76a75c9e1e17b1a864b92bbc1d2 (patch) | |
tree | f9eb56779017fee672a5ce875e027c1b5d840cef /sys/dev/ppbus/pps.c | |
parent | 805920b490e525fff0027806088b75378b97b685 (diff) | |
download | FreeBSD-src-6ac7d76dbc27d76a75c9e1e17b1a864b92bbc1d2.zip FreeBSD-src-6ac7d76dbc27d76a75c9e1e17b1a864b92bbc1d2.tar.gz |
Some newbus-inspired tidy-ups. Use device_identify() rather than scanning
the resource table to locate children. The 'at ppbus?' can go again.
Remove a few #if Nxxx > 0' type things, config arranges this for us.
Move the newbus method glue next to the DRIVER_MODULE() stuff so we
don't need extra prototypes.
Don't set device descriptions until after the possibility of the probe
returning an error.
Remove all cdevsw_add() calls, all the drivers that did this also use
make_dev() correctly, so it's not required.
A couple of other minor nits.
Diffstat (limited to 'sys/dev/ppbus/pps.c')
-rw-r--r-- | sys/dev/ppbus/pps.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/sys/dev/ppbus/pps.c b/sys/dev/ppbus/pps.c index 9a540dc..e4b6866 100644 --- a/sys/dev/ppbus/pps.c +++ b/sys/dev/ppbus/pps.c @@ -43,8 +43,6 @@ struct pps_data { void *intr_cookie; /* interrupt registration cookie */ }; -static int ppsprobe(device_t dev); -static int ppsattach(device_t dev); static void ppsintr(void *arg); #define DEVTOSOFTC(dev) \ @@ -56,20 +54,6 @@ static void ppsintr(void *arg); static devclass_t pps_devclass; -static device_method_t pps_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ppsprobe), - DEVMETHOD(device_attach, ppsattach), - - { 0, 0 } -}; - -static driver_t pps_driver = { - PPS_NAME, - pps_methods, - sizeof(struct pps_data), -}; - static d_open_t ppsopen; static d_close_t ppsclose; static d_ioctl_t ppsioctl; @@ -92,17 +76,20 @@ static struct cdevsw pps_cdevsw = { /* bmaj */ -1 }; +static void +ppsidentify(driver_t *driver, device_t parent) +{ + + BUS_ADD_CHILD(parent, 0, PPS_NAME, 0); +} + static int ppsprobe(device_t ppsdev) { struct pps_data *sc; - static int once; dev_t dev; int unit; - if (!once++) - cdevsw_add(&pps_cdevsw); - sc = DEVTOSOFTC(ppsdev); bzero(sc, sizeof(struct pps_data)); @@ -216,4 +203,18 @@ ppsioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) return (pps_ioctl(cmd, data, &sc->pps)); } +static device_method_t pps_methods[] = { + /* device interface */ + DEVMETHOD(device_identify, ppsidentify), + DEVMETHOD(device_probe, ppsprobe), + DEVMETHOD(device_attach, ppsattach), + + { 0, 0 } +}; + +static driver_t pps_driver = { + PPS_NAME, + pps_methods, + sizeof(struct pps_data), +}; DRIVER_MODULE(pps, ppbus, pps_driver, pps_devclass, 0, 0); |