summaryrefslogtreecommitdiffstats
path: root/sys/dev/ppbus/pps.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2000-01-23 14:41:04 +0000
committerpeter <peter@FreeBSD.org>2000-01-23 14:41:04 +0000
commit6ac7d76dbc27d76a75c9e1e17b1a864b92bbc1d2 (patch)
treef9eb56779017fee672a5ce875e027c1b5d840cef /sys/dev/ppbus/pps.c
parent805920b490e525fff0027806088b75378b97b685 (diff)
downloadFreeBSD-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.c41
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);
OpenPOWER on IntegriCloud