Use acpi_compatible_match().diff -r1.51 -r1.52 src/sys/dev/acpi/acpi_acad.c
(thorpej)
--- src/sys/dev/acpi/acpi_acad.c 2015/04/23 23:23:00 1.51
+++ src/sys/dev/acpi/acpi_acad.c 2021/01/29 15:20:13 1.52
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi_acad.c,v 1.51 2015/04/23 23:23:00 pgoyette Exp $ */ | 1 | /* $NetBSD: acpi_acad.c,v 1.52 2021/01/29 15:20:13 thorpej Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright 2001 Wasabi Systems, Inc. | 4 | * Copyright 2001 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -30,80 +30,77 @@ | @@ -30,80 +30,77 @@ | |||
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | 35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | /* | 38 | /* | |
39 | * ACPI AC Adapter driver. | 39 | * ACPI AC Adapter driver. | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: acpi_acad.c,v 1.51 2015/04/23 23:23:00 pgoyette Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: acpi_acad.c,v 1.52 2021/01/29 15:20:13 thorpej Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/device.h> | 46 | #include <sys/device.h> | |
47 | #include <sys/module.h> | 47 | #include <sys/module.h> | |
48 | #include <sys/systm.h> | 48 | #include <sys/systm.h> | |
49 | 49 | |||
50 | #include <dev/acpi/acpireg.h> | 50 | #include <dev/acpi/acpireg.h> | |
51 | #include <dev/acpi/acpivar.h> | 51 | #include <dev/acpi/acpivar.h> | |
52 | 52 | |||
53 | #define _COMPONENT ACPI_ACAD_COMPONENT | 53 | #define _COMPONENT ACPI_ACAD_COMPONENT | |
54 | ACPI_MODULE_NAME ("acpi_acad") | 54 | ACPI_MODULE_NAME ("acpi_acad") | |
55 | 55 | |||
56 | #define ACPI_NOTIFY_ACAD 0x80 | 56 | #define ACPI_NOTIFY_ACAD 0x80 | |
57 | #define ACPI_NOTIFY_ACAD_2 0x81 /* XXX. */ | 57 | #define ACPI_NOTIFY_ACAD_2 0x81 /* XXX. */ | |
58 | 58 | |||
59 | struct acpiacad_softc { | 59 | struct acpiacad_softc { | |
60 | struct acpi_devnode *sc_node; | 60 | struct acpi_devnode *sc_node; | |
61 | struct sysmon_envsys *sc_sme; | 61 | struct sysmon_envsys *sc_sme; | |
62 | struct sysmon_pswitch sc_smpsw; | 62 | struct sysmon_pswitch sc_smpsw; | |
63 | envsys_data_t sc_sensor; | 63 | envsys_data_t sc_sensor; | |
64 | int sc_status; | 64 | int sc_status; | |
65 | }; | 65 | }; | |
66 | 66 | |||
67 | static const char * const acad_hid[] = { | 67 | static const struct device_compatible_entry compat_data[] = { | |
68 | "ACPI0003", | 68 | { .compat = "ACPI0003" }, | |
69 | NULL | 69 | DEVICE_COMPAT_EOL | |
70 | }; | 70 | }; | |
71 | 71 | |||
72 | static int acpiacad_match(device_t, cfdata_t, void *); | 72 | static int acpiacad_match(device_t, cfdata_t, void *); | |
73 | static void acpiacad_attach(device_t, device_t, void *); | 73 | static void acpiacad_attach(device_t, device_t, void *); | |
74 | static int acpiacad_detach(device_t, int); | 74 | static int acpiacad_detach(device_t, int); | |
75 | static bool acpiacad_resume(device_t, const pmf_qual_t *); | 75 | static bool acpiacad_resume(device_t, const pmf_qual_t *); | |
76 | static void acpiacad_get_status(void *); | 76 | static void acpiacad_get_status(void *); | |
77 | static void acpiacad_notify_handler(ACPI_HANDLE, uint32_t, void *); | 77 | static void acpiacad_notify_handler(ACPI_HANDLE, uint32_t, void *); | |
78 | static void acpiacad_init_envsys(device_t); | 78 | static void acpiacad_init_envsys(device_t); | |
79 | 79 | |||
80 | CFATTACH_DECL_NEW(acpiacad, sizeof(struct acpiacad_softc), | 80 | CFATTACH_DECL_NEW(acpiacad, sizeof(struct acpiacad_softc), | |
81 | acpiacad_match, acpiacad_attach, acpiacad_detach, NULL); | 81 | acpiacad_match, acpiacad_attach, acpiacad_detach, NULL); | |
82 | 82 | |||
83 | /* | 83 | /* | |
84 | * acpiacad_match: | 84 | * acpiacad_match: | |
85 | * | 85 | * | |
86 | * Autoconfiguration `match' routine. | 86 | * Autoconfiguration `match' routine. | |
87 | */ | 87 | */ | |
88 | static int | 88 | static int | |
89 | acpiacad_match(device_t parent, cfdata_t match, void *aux) | 89 | acpiacad_match(device_t parent, cfdata_t match, void *aux) | |
90 | { | 90 | { | |
91 | struct acpi_attach_args *aa = aux; | 91 | struct acpi_attach_args *aa = aux; | |
92 | 92 | |||
93 | if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE) | 93 | return acpi_compatible_match(aa, compat_data); | |
94 | return 0; | |||
95 | ||||
96 | return acpi_match_hid(aa->aa_node->ad_devinfo, acad_hid); | |||
97 | } | 94 | } | |
98 | 95 | |||
99 | /* | 96 | /* | |
100 | * acpiacad_attach: | 97 | * acpiacad_attach: | |
101 | * | 98 | * | |
102 | * Autoconfiguration `attach' routine. | 99 | * Autoconfiguration `attach' routine. | |
103 | */ | 100 | */ | |
104 | static void | 101 | static void | |
105 | acpiacad_attach(device_t parent, device_t self, void *aux) | 102 | acpiacad_attach(device_t parent, device_t self, void *aux) | |
106 | { | 103 | { | |
107 | struct acpiacad_softc *sc = device_private(self); | 104 | struct acpiacad_softc *sc = device_private(self); | |
108 | struct acpi_attach_args *aa = aux; | 105 | struct acpi_attach_args *aa = aux; | |
109 | 106 |
--- src/sys/dev/acpi/acpi_bat.c 2018/08/10 17:11:56 1.116
+++ src/sys/dev/acpi/acpi_bat.c 2021/01/29 15:20:13 1.117
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: acpi_bat.c,v 1.116 2018/08/10 17:11:56 riastradh Exp $ */ | 1 | /* $NetBSD: acpi_bat.c,v 1.117 2021/01/29 15:20:13 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum of By Noon Software, Inc. | 8 | * by Charles M. Hannum of By Noon Software, Inc. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -65,27 +65,27 @@ | @@ -65,27 +65,27 @@ | |||
65 | /* | 65 | /* | |
66 | * ACPI Battery Driver. | 66 | * ACPI Battery Driver. | |
67 | * | 67 | * | |
68 | * ACPI defines two different battery device interfaces: "Control | 68 | * ACPI defines two different battery device interfaces: "Control | |
69 | * Method" batteries, in which AML methods are defined in order to get | 69 | * Method" batteries, in which AML methods are defined in order to get | |
70 | * battery status and set battery alarm thresholds, and a "Smart | 70 | * battery status and set battery alarm thresholds, and a "Smart | |
71 | * Battery" device, which is an SMbus device accessed through the ACPI | 71 | * Battery" device, which is an SMbus device accessed through the ACPI | |
72 | * Embedded Controller device. | 72 | * Embedded Controller device. | |
73 | * | 73 | * | |
74 | * This driver is for the "Control Method"-style battery only. | 74 | * This driver is for the "Control Method"-style battery only. | |
75 | */ | 75 | */ | |
76 | 76 | |||
77 | #include <sys/cdefs.h> | 77 | #include <sys/cdefs.h> | |
78 | __KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.116 2018/08/10 17:11:56 riastradh Exp $"); | 78 | __KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.117 2021/01/29 15:20:13 thorpej Exp $"); | |
79 | 79 | |||
80 | #include <sys/param.h> | 80 | #include <sys/param.h> | |
81 | #include <sys/condvar.h> | 81 | #include <sys/condvar.h> | |
82 | #include <sys/device.h> | 82 | #include <sys/device.h> | |
83 | #include <sys/kernel.h> | 83 | #include <sys/kernel.h> | |
84 | #include <sys/kmem.h> | 84 | #include <sys/kmem.h> | |
85 | #include <sys/module.h> | 85 | #include <sys/module.h> | |
86 | #include <sys/mutex.h> | 86 | #include <sys/mutex.h> | |
87 | #include <sys/systm.h> | 87 | #include <sys/systm.h> | |
88 | 88 | |||
89 | #include <dev/acpi/acpireg.h> | 89 | #include <dev/acpi/acpireg.h> | |
90 | #include <dev/acpi/acpivar.h> | 90 | #include <dev/acpi/acpivar.h> | |
91 | 91 | |||
@@ -149,29 +149,29 @@ struct acpibat_softc { | @@ -149,29 +149,29 @@ struct acpibat_softc { | |||
149 | struct acpi_devnode *sc_node; | 149 | struct acpi_devnode *sc_node; | |
150 | struct sysmon_envsys *sc_sme; | 150 | struct sysmon_envsys *sc_sme; | |
151 | struct timeval sc_last; | 151 | struct timeval sc_last; | |
152 | envsys_data_t *sc_sensor; | 152 | envsys_data_t *sc_sensor; | |
153 | kmutex_t sc_mutex; | 153 | kmutex_t sc_mutex; | |
154 | kcondvar_t sc_condvar; | 154 | kcondvar_t sc_condvar; | |
155 | int32_t sc_dcapacity; | 155 | int32_t sc_dcapacity; | |
156 | int32_t sc_dvoltage; | 156 | int32_t sc_dvoltage; | |
157 | int32_t sc_lcapacity; | 157 | int32_t sc_lcapacity; | |
158 | int32_t sc_wcapacity; | 158 | int32_t sc_wcapacity; | |
159 | int sc_present; | 159 | int sc_present; | |
160 | }; | 160 | }; | |
161 | 161 | |||
162 | static const char * const bat_hid[] = { | 162 | static const struct device_compatible_entry compat_data[] = { | |
163 | "PNP0C0A", | 163 | { .compat = "PNP0C0A" }, | |
164 | NULL | 164 | DEVICE_COMPAT_EOL | |
165 | }; | 165 | }; | |
166 | 166 | |||
167 | #define ACPIBAT_PWRUNIT_MA 0x00000001 /* mA not mW */ | 167 | #define ACPIBAT_PWRUNIT_MA 0x00000001 /* mA not mW */ | |
168 | #define ACPIBAT_ST_DISCHARGING 0x00000001 /* battery is discharging */ | 168 | #define ACPIBAT_ST_DISCHARGING 0x00000001 /* battery is discharging */ | |
169 | #define ACPIBAT_ST_CHARGING 0x00000002 /* battery is charging */ | 169 | #define ACPIBAT_ST_CHARGING 0x00000002 /* battery is charging */ | |
170 | #define ACPIBAT_ST_CRITICAL 0x00000004 /* battery is critical */ | 170 | #define ACPIBAT_ST_CRITICAL 0x00000004 /* battery is critical */ | |
171 | 171 | |||
172 | /* | 172 | /* | |
173 | * A value used when _BST or _BIF is temporarily unknown. | 173 | * A value used when _BST or _BIF is temporarily unknown. | |
174 | */ | 174 | */ | |
175 | #define ACPIBAT_VAL_UNKNOWN 0xFFFFFFFF | 175 | #define ACPIBAT_VAL_UNKNOWN 0xFFFFFFFF | |
176 | 176 | |||
177 | #define ACPIBAT_VAL_ISVALID(x) \ | 177 | #define ACPIBAT_VAL_ISVALID(x) \ | |
@@ -197,30 +197,27 @@ static void acpibat_get_limits(struc | @@ -197,30 +197,27 @@ static void acpibat_get_limits(struc | |||
197 | CFATTACH_DECL_NEW(acpibat, sizeof(struct acpibat_softc), | 197 | CFATTACH_DECL_NEW(acpibat, sizeof(struct acpibat_softc), | |
198 | acpibat_match, acpibat_attach, acpibat_detach, NULL); | 198 | acpibat_match, acpibat_attach, acpibat_detach, NULL); | |
199 | 199 | |||
200 | /* | 200 | /* | |
201 | * acpibat_match: | 201 | * acpibat_match: | |
202 | * | 202 | * | |
203 | * Autoconfiguration `match' routine. | 203 | * Autoconfiguration `match' routine. | |
204 | */ | 204 | */ | |
205 | static int | 205 | static int | |
206 | acpibat_match(device_t parent, cfdata_t match, void *aux) | 206 | acpibat_match(device_t parent, cfdata_t match, void *aux) | |
207 | { | 207 | { | |
208 | struct acpi_attach_args *aa = aux; | 208 | struct acpi_attach_args *aa = aux; | |
209 | 209 | |||
210 | if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE) | 210 | return acpi_compatible_match(aa, compat_data); | |
211 | return 0; | |||
212 | ||||
213 | return acpi_match_hid(aa->aa_node->ad_devinfo, bat_hid); | |||
214 | } | 211 | } | |
215 | 212 | |||
216 | /* | 213 | /* | |
217 | * acpibat_attach: | 214 | * acpibat_attach: | |
218 | * | 215 | * | |
219 | * Autoconfiguration `attach' routine. | 216 | * Autoconfiguration `attach' routine. | |
220 | */ | 217 | */ | |
221 | static void | 218 | static void | |
222 | acpibat_attach(device_t parent, device_t self, void *aux) | 219 | acpibat_attach(device_t parent, device_t self, void *aux) | |
223 | { | 220 | { | |
224 | struct acpibat_softc *sc = device_private(self); | 221 | struct acpibat_softc *sc = device_private(self); | |
225 | struct acpi_attach_args *aa = aux; | 222 | struct acpi_attach_args *aa = aux; | |
226 | ACPI_HANDLE tmp; | 223 | ACPI_HANDLE tmp; |