This source file includes following definitions.
- owid_match
- owid_attach
- owid_detach
- owid_activate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include <sys/param.h>
24 #include <sys/systm.h>
25 #include <sys/device.h>
26 #include <sys/kernel.h>
27 #include <sys/proc.h>
28 #include <sys/sensors.h>
29
30 #include <dev/onewire/onewiredevs.h>
31 #include <dev/onewire/onewirereg.h>
32 #include <dev/onewire/onewirevar.h>
33
34 struct owid_softc {
35 struct device sc_dev;
36
37 void * sc_onewire;
38 u_int64_t sc_rom;
39
40 struct ksensor sc_sensor;
41 struct ksensordev sc_sensordev;
42
43 int sc_dying;
44 };
45
46 int owid_match(struct device *, void *, void *);
47 void owid_attach(struct device *, struct device *, void *);
48 int owid_detach(struct device *, int);
49 int owid_activate(struct device *, enum devact);
50
51 struct cfattach owid_ca = {
52 sizeof(struct owid_softc),
53 owid_match,
54 owid_attach,
55 owid_detach,
56 owid_activate
57 };
58
59 struct cfdriver owid_cd = {
60 NULL, "owid", DV_DULL
61 };
62
63 static const struct onewire_matchfam owid_fams[] = {
64 { ONEWIRE_FAMILY_DS1990 }
65 };
66
67 int
68 owid_match(struct device *parent, void *match, void *aux)
69 {
70 return (onewire_matchbyfam(aux, owid_fams,
71 sizeof(owid_fams) /sizeof(owid_fams[0])));
72 }
73
74 void
75 owid_attach(struct device *parent, struct device *self, void *aux)
76 {
77 struct owid_softc *sc = (struct owid_softc *)self;
78 struct onewire_attach_args *oa = aux;
79
80 sc->sc_onewire = oa->oa_onewire;
81 sc->sc_rom = oa->oa_rom;
82
83
84 strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname,
85 sizeof(sc->sc_sensordev.xname));
86 sc->sc_sensor.type = SENSOR_INTEGER;
87 sc->sc_sensor.value = ONEWIRE_ROM_SN(sc->sc_rom);
88 sensor_attach(&sc->sc_sensordev, &sc->sc_sensor);
89 sensordev_install(&sc->sc_sensordev);
90
91 printf("\n");
92 }
93
94 int
95 owid_detach(struct device *self, int flags)
96 {
97 struct owid_softc *sc = (struct owid_softc *)self;
98
99 sensordev_deinstall(&sc->sc_sensordev);
100
101 return (0);
102 }
103
104 int
105 owid_activate(struct device *self, enum devact act)
106 {
107 struct owid_softc *sc = (struct owid_softc *)self;
108
109 switch (act) {
110 case DVACT_ACTIVATE:
111 break;
112 case DVACT_DEACTIVATE:
113 sc->sc_dying = 1;
114 break;
115 }
116
117 return (0);
118 }