| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ofw_subr.c,v 1.50 2021/01/25 19:59:49 mrg Exp $ */ | | 1 | /* $NetBSD: ofw_subr.c,v 1.51 2021/01/26 14:09:11 thorpej Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 1998 | | 4 | * Copyright 1998 |
5 | * Digital Equipment Corporation. All rights reserved. | | 5 | * Digital Equipment Corporation. All rights reserved. |
6 | * | | 6 | * |
7 | * This software is furnished under license and may be used and | | 7 | * This software is furnished under license and may be used and |
8 | * copied only in accordance with the following terms and conditions. | | 8 | * copied only in accordance with the following terms and conditions. |
9 | * Subject to these conditions, you may download, copy, install, | | 9 | * Subject to these conditions, you may download, copy, install, |
10 | * use, modify and distribute this software in source and/or binary | | 10 | * use, modify and distribute this software in source and/or binary |
11 | * form. No title or ownership is transferred hereby. | | 11 | * form. No title or ownership is transferred hereby. |
12 | * | | 12 | * |
13 | * 1) Any source code used, modified or distributed must reproduce | | 13 | * 1) Any source code used, modified or distributed must reproduce |
14 | * and retain this copyright notice and list of conditions as | | 14 | * and retain this copyright notice and list of conditions as |
| @@ -24,27 +24,27 @@ | | | @@ -24,27 +24,27 @@ |
24 | * 3) This software is provided "AS-IS" and any express or implied | | 24 | * 3) This software is provided "AS-IS" and any express or implied |
25 | * warranties, including but not limited to, any implied warranties | | 25 | * warranties, including but not limited to, any implied warranties |
26 | * of merchantability, fitness for a particular purpose, or | | 26 | * of merchantability, fitness for a particular purpose, or |
27 | * non-infringement are disclaimed. In no event shall DIGITAL be | | 27 | * non-infringement are disclaimed. In no event shall DIGITAL be |
28 | * liable for any damages whatsoever, and in particular, DIGITAL | | 28 | * liable for any damages whatsoever, and in particular, DIGITAL |
29 | * shall not be liable for special, indirect, consequential, or | | 29 | * shall not be liable for special, indirect, consequential, or |
30 | * incidental damages or damages for lost profits, loss of | | 30 | * incidental damages or damages for lost profits, loss of |
31 | * revenue or loss of use, whether such damages arise in contract, | | 31 | * revenue or loss of use, whether such damages arise in contract, |
32 | * negligence, tort, under statute, in equity, at law or otherwise, | | 32 | * negligence, tort, under statute, in equity, at law or otherwise, |
33 | * even if advised of the possibility of such damage. | | 33 | * even if advised of the possibility of such damage. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | __KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.50 2021/01/25 19:59:49 mrg Exp $"); | | 37 | __KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.51 2021/01/26 14:09:11 thorpej Exp $"); |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/device.h> | | 40 | #include <sys/device.h> |
41 | #include <sys/kmem.h> | | 41 | #include <sys/kmem.h> |
42 | #include <sys/systm.h> | | 42 | #include <sys/systm.h> |
43 | #include <dev/ofw/openfirm.h> | | 43 | #include <dev/ofw/openfirm.h> |
44 | #include <dev/i2c/i2cvar.h> | | 44 | #include <dev/i2c/i2cvar.h> |
45 | | | 45 | |
46 | #define OFW_MAX_STACK_BUF_SIZE 256 | | 46 | #define OFW_MAX_STACK_BUF_SIZE 256 |
47 | #define OFW_PATH_BUF_SIZE 512 | | 47 | #define OFW_PATH_BUF_SIZE 512 |
48 | | | 48 | |
49 | /* | | 49 | /* |
50 | * int of_decode_int(p) | | 50 | * int of_decode_int(p) |
| @@ -151,28 +151,31 @@ of_compatible(int phandle, const char * | | | @@ -151,28 +151,31 @@ of_compatible(int phandle, const char * |
151 | * | | 151 | * |
152 | * Side Effects: | | 152 | * Side Effects: |
153 | * None. | | 153 | * None. |
154 | */ | | 154 | */ |
155 | int | | 155 | int |
156 | of_match_compatible(int phandle, const char * const *strings) | | 156 | of_match_compatible(int phandle, const char * const *strings) |
157 | { | | 157 | { |
158 | return of_compatible(phandle, strings) + 1; | | 158 | return of_compatible(phandle, strings) + 1; |
159 | } | | 159 | } |
160 | | | 160 | |
161 | /* | | 161 | /* |
162 | * int of_match_compat_data(phandle, compat_data) | | 162 | * int of_match_compat_data(phandle, compat_data) |
163 | * | | 163 | * |
164 | * This routine searches an array of compat_data structures for a | | 164 | * This routine searches an array of device_compatible_entry structures |
165 | * matching "compatible" entry matching the supplied OFW node. | | 165 | * for a matching "compatible" entry matching the supplied OFW node, |
| | | 166 | * and returns a weighted match value corresponding to which string |
| | | 167 | * from the "compatible" property was matched, which more weight given |
| | | 168 | * to the first string than the last. |
166 | * | | 169 | * |
167 | * It should be used when determining whether a driver can drive | | 170 | * It should be used when determining whether a driver can drive |
168 | * a particular device. | | 171 | * a particular device. |
169 | * | | 172 | * |
170 | * Arguments: | | 173 | * Arguments: |
171 | * phandle OFW phandle of device to be checked for | | 174 | * phandle OFW phandle of device to be checked for |
172 | * compatibility. | | 175 | * compatibility. |
173 | * compat_data Array of possible compat entry strings and | | 176 | * compat_data Array of possible compat entry strings and |
174 | * associated metadata. The last entry in the | | 177 | * associated metadata. The last entry in the |
175 | * list should have a "compat" of NULL to terminate | | 178 | * list should have a "compat" of NULL to terminate |
176 | * the list. | | 179 | * the list. |
177 | * | | 180 | * |
178 | * Return Value: | | 181 | * Return Value: |
| @@ -202,28 +205,28 @@ of_match_compat_data(int phandle, | | | @@ -202,28 +205,28 @@ of_match_compat_data(int phandle, |
202 | } | | 205 | } |
203 | | | 206 | |
204 | match = device_compatible_match_strlist(prop, proplen, compat_data); | | 207 | match = device_compatible_match_strlist(prop, proplen, compat_data); |
205 | | | 208 | |
206 | out: | | 209 | out: |
207 | kmem_tmpbuf_free(prop, proplen, propbuf); | | 210 | kmem_tmpbuf_free(prop, proplen, propbuf); |
208 | return match; | | 211 | return match; |
209 | } | | 212 | } |
210 | | | 213 | |
211 | /* | | 214 | /* |
212 | * const struct device_compatible_entry *of_search_compatible(phandle, | | 215 | * const struct device_compatible_entry *of_search_compatible(phandle, |
213 | * compat_data) | | 216 | * compat_data) |
214 | * | | 217 | * |
215 | * This routine searches an array of compat_data structures for a | | 218 | * This routine searches an array of device_compatible_entry structures |
216 | * matching "compatible" entry matching the supplied OFW node. | | 219 | * for a "compatible" entry matching the supplied OFW node. |
217 | * | | 220 | * |
218 | * Arguments: | | 221 | * Arguments: |
219 | * phandle OFW phandle of device to be checked for | | 222 | * phandle OFW phandle of device to be checked for |
220 | * compatibility. | | 223 | * compatibility. |
221 | * compat_data Array of possible compat entry strings and | | 224 | * compat_data Array of possible compat entry strings and |
222 | * associated metadata. The last entry in the | | 225 | * associated metadata. The last entry in the |
223 | * list should have a "compat" of NULL to terminate | | 226 | * list should have a "compat" of NULL to terminate |
224 | * the list. | | 227 | * the list. |
225 | * | | 228 | * |
226 | * Return Value: | | 229 | * Return Value: |
227 | * The first matching compat_data entry in the array. If no matches | | 230 | * The first matching compat_data entry in the array. If no matches |
228 | * are found, NULL is returned. | | 231 | * are found, NULL is returned. |
229 | * | | 232 | * |