summaryrefslogtreecommitdiffstats
path: root/sys/dev/ppbus/pcfclock.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/pcfclock.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/pcfclock.c')
-rw-r--r--sys/dev/ppbus/pcfclock.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/sys/dev/ppbus/pcfclock.c b/sys/dev/ppbus/pcfclock.c
index 926a723..a52ff82 100644
--- a/sys/dev/ppbus/pcfclock.c
+++ b/sys/dev/ppbus/pcfclock.c
@@ -25,10 +25,6 @@
*
*/
-#include "pcfclock.h"
-
-#if NPCFCLOCK > 0
-
#include "opt_pcfclock.h"
#include <sys/param.h>
@@ -68,23 +64,6 @@ struct pcfclock_data {
static devclass_t pcfclock_devclass;
-static int pcfclock_probe(device_t);
-static int pcfclock_attach(device_t);
-
-static device_method_t pcfclock_methods[] = {
- /* device interface */
- DEVMETHOD(device_probe, pcfclock_probe),
- DEVMETHOD(device_attach, pcfclock_attach),
-
- { 0, 0 }
-};
-
-static driver_t pcfclock_driver = {
- PCFCLOCK_NAME,
- pcfclock_methods,
- sizeof(struct pcfclock_data),
-};
-
static d_open_t pcfclock_open;
static d_close_t pcfclock_close;
static d_read_t pcfclock_read;
@@ -144,17 +123,20 @@ static struct cdevsw pcfclock_cdevsw = {
#define PCFCLOCK_CMD_TIME 0 /* send current time */
#define PCFCLOCK_CMD_COPY 7 /* copy received signal to PC */
+static void
+pcfclock_identify(driver_t *driver, device_t parent)
+{
+
+ BUS_ADD_CHILD(parent, 0, PCFCLOCK_NAME, 0);
+}
+
static int
pcfclock_probe(device_t dev)
{
struct pcfclock_data *sc;
- static int once;
device_set_desc(dev, "PCF-1.0");
- if (!once++)
- cdevsw_add(&pcfclock_cdevsw);
-
sc = DEVTOSOFTC(dev);
bzero(sc, sizeof(struct pcfclock_data));
@@ -343,6 +325,19 @@ pcfclock_read(dev_t dev, struct uio *uio, int ioflag)
return (error);
}
-DRIVER_MODULE(pcfclock, ppbus, pcfclock_driver, pcfclock_devclass, 0, 0);
+static device_method_t pcfclock_methods[] = {
+ /* device interface */
+ DEVMETHOD(device_identify, pcfclock_identify),
+ DEVMETHOD(device_probe, pcfclock_probe),
+ DEVMETHOD(device_attach, pcfclock_attach),
-#endif /* NPCFCLOCK */
+ { 0, 0 }
+};
+
+static driver_t pcfclock_driver = {
+ PCFCLOCK_NAME,
+ pcfclock_methods,
+ sizeof(struct pcfclock_data),
+};
+
+DRIVER_MODULE(pcfclock, ppbus, pcfclock_driver, pcfclock_devclass, 0, 0);
OpenPOWER on IntegriCloud