This source file includes following definitions.
- bthub_match
- bthub_attach
- bthub_detach
- bthubopen
- bthubclose
- bthubioctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <sys/param.h>
20 #include <sys/systm.h>
21 #include <sys/conf.h>
22 #include <sys/device.h>
23 #include <sys/ioctl.h>
24 #include <sys/vnode.h>
25
26 #include <netbt/bluetooth.h>
27
28 struct bthub_softc {
29 struct device sc_dev;
30 int sc_open;
31 };
32
33 int bthub_match(struct device *, void *, void *);
34 void bthub_attach(struct device *, struct device *, void *);
35 int bthub_detach(struct device *, int);
36
37 struct cfattach bthub_ca = {
38 sizeof(struct bthub_softc), bthub_match, bthub_attach, bthub_detach
39 };
40
41 struct cfdriver bthub_cd = {
42 NULL, "bthub", DV_DULL
43 };
44
45 int
46 bthub_match(struct device *parent, void *match, void *aux)
47 {
48 return (1);
49 }
50
51 void
52 bthub_attach(struct device *parent, struct device *self, void *aux)
53 {
54 bdaddr_t *addr = aux;
55 struct bthub_softc *sc = (struct bthub_softc *)self;
56
57 sc->sc_open = 0;
58
59 printf(" %02x:%02x:%02x:%02x:%02x:%02x\n",
60 addr->b[5], addr->b[4], addr->b[3],
61 addr->b[2], addr->b[1], addr->b[0]);
62 }
63
64 int
65 bthub_detach(struct device *self, int flags)
66 {
67 int maj, mn;
68
69
70 for (maj = 0; maj < nchrdev; maj++)
71 if (cdevsw[maj].d_open == bthubopen)
72 break;
73
74
75 mn = self->dv_unit;
76 vdevgone(maj, mn, mn, VCHR);
77
78 return (0);
79 }
80
81 int
82 bthubopen(dev_t dev, int flag, int mode, struct proc *p)
83 {
84 struct device *dv;
85 struct bthub_softc *sc;
86
87 dv = device_lookup(&bthub_cd, minor(dev));
88 if (dv == NULL)
89 return (ENXIO);
90
91 sc = (struct bthub_softc *)dv;
92 if (sc->sc_open) {
93 device_unref(dv);
94 return (EBUSY);
95 }
96
97 sc->sc_open = 1;
98 device_unref(dv);
99
100 return (0);
101 }
102
103 int
104 bthubclose(dev_t dev, int flag, int mode, struct proc *p)
105 {
106 struct device *dv;
107 struct bthub_softc *sc;
108
109 dv = device_lookup(&bthub_cd, minor(dev));
110 sc = (struct bthub_softc *)dv;
111 sc->sc_open = 0;
112 device_unref(dv);
113
114 return (0);
115 }
116
117 int
118 bthubioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
119 {
120 return (ENOTTY);
121 }
122