diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2013-01-20 11:58:47 -0500 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2013-01-24 16:48:04 -0500 |
commit | 6543becf26fff612cdadeed7250ccc8d49f67f27 (patch) | |
tree | bcba277bb0c03a81aae46965f3ddc76e582b51f1 /scripts/mod/file2alias.c | |
parent | a49f0d1ea3ec94fc7cf33a7c36a16343b74bd565 (diff) |
mod/file2alias: make modalias generation safe for cross compiling
Use the target compiler to compute the offsets for the fields of the
device_id structures, so that it won't be broken by different alignments
between the host and target ABIs.
This also fixes missing endian corrections for some modaliases.
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/mod/file2alias.c')
-rw-r--r-- | scripts/mod/file2alias.c | 674 |
1 files changed, 366 insertions, 308 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index df4fc23dd836..771ac17f635d 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -11,6 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include "modpost.h" | 13 | #include "modpost.h" |
14 | #include "devicetable-offsets.h" | ||
14 | 15 | ||
15 | /* We use the ELF typedefs for kernel_ulong_t but bite the bullet and | 16 | /* We use the ELF typedefs for kernel_ulong_t but bite the bullet and |
16 | * use either stdint.h or inttypes.h for the rest. */ | 17 | * use either stdint.h or inttypes.h for the rest. */ |
@@ -84,13 +85,25 @@ extern struct devtable *__start___devtable[], *__stop___devtable[]; | |||
84 | # define __used __attribute__((__used__)) | 85 | # define __used __attribute__((__used__)) |
85 | #endif | 86 | #endif |
86 | 87 | ||
88 | /* Define a variable f that holds the value of field f of struct devid | ||
89 | * based at address m. | ||
90 | */ | ||
91 | #define DEF_FIELD(m, devid, f) \ | ||
92 | typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f)) | ||
93 | /* Define a variable f that holds the address of field f of struct devid | ||
94 | * based at address m. Due to the way typeof works, for a field of type | ||
95 | * T[N] the variable has type T(*)[N], _not_ T*. | ||
96 | */ | ||
97 | #define DEF_FIELD_ADDR(m, devid, f) \ | ||
98 | typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f) | ||
99 | |||
87 | /* Add a table entry. We test function type matches while we're here. */ | 100 | /* Add a table entry. We test function type matches while we're here. */ |
88 | #define ADD_TO_DEVTABLE(device_id, type, function) \ | 101 | #define ADD_TO_DEVTABLE(device_id, type, function) \ |
89 | static struct devtable __cat(devtable,__LINE__) = { \ | 102 | static struct devtable __cat(devtable,__LINE__) = { \ |
90 | device_id + 0*sizeof((function)((const char *)NULL, \ | 103 | device_id + 0*sizeof((function)((const char *)NULL, \ |
91 | (type *)NULL, \ | 104 | (void *)NULL, \ |
92 | (char *)NULL)), \ | 105 | (char *)NULL)), \ |
93 | sizeof(type), (function) }; \ | 106 | SIZE_##type, (function) }; \ |
94 | static struct devtable *SECTION(__devtable) __used \ | 107 | static struct devtable *SECTION(__devtable) __used \ |
95 | __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) | 108 | __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) |
96 | 109 | ||
@@ -116,7 +129,6 @@ static inline void add_wildcard(char *str) | |||
116 | strcat(str + len, "*"); | 129 | strcat(str + len, "*"); |
117 | } | 130 | } |
118 | 131 | ||
119 | unsigned int cross_build = 0; | ||
120 | /** | 132 | /** |
121 | * Check that sizeof(device_id type) are consistent with size of section | 133 | * Check that sizeof(device_id type) are consistent with size of section |
122 | * in .o file. If in-consistent then userspace and kernel does not agree | 134 | * in .o file. If in-consistent then userspace and kernel does not agree |
@@ -131,8 +143,6 @@ static void device_id_check(const char *modname, const char *device_id, | |||
131 | int i; | 143 | int i; |
132 | 144 | ||
133 | if (size % id_size || size < id_size) { | 145 | if (size % id_size || size < id_size) { |
134 | if (cross_build != 0) | ||
135 | return; | ||
136 | fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " | 146 | fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " |
137 | "of the size of section __mod_%s_device_table=%lu.\n" | 147 | "of the size of section __mod_%s_device_table=%lu.\n" |
138 | "Fix definition of struct %s_device_id " | 148 | "Fix definition of struct %s_device_id " |
@@ -157,17 +167,29 @@ static void device_id_check(const char *modname, const char *device_id, | |||
157 | 167 | ||
158 | /* USB is special because the bcdDevice can be matched against a numeric range */ | 168 | /* USB is special because the bcdDevice can be matched against a numeric range */ |
159 | /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */ | 169 | /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */ |
160 | static void do_usb_entry(struct usb_device_id *id, | 170 | static void do_usb_entry(void *symval, |
161 | unsigned int bcdDevice_initial, int bcdDevice_initial_digits, | 171 | unsigned int bcdDevice_initial, int bcdDevice_initial_digits, |
162 | unsigned char range_lo, unsigned char range_hi, | 172 | unsigned char range_lo, unsigned char range_hi, |
163 | unsigned char max, struct module *mod) | 173 | unsigned char max, struct module *mod) |
164 | { | 174 | { |
165 | char alias[500]; | 175 | char alias[500]; |
176 | DEF_FIELD(symval, usb_device_id, match_flags); | ||
177 | DEF_FIELD(symval, usb_device_id, idVendor); | ||
178 | DEF_FIELD(symval, usb_device_id, idProduct); | ||
179 | DEF_FIELD(symval, usb_device_id, bcdDevice_lo); | ||
180 | DEF_FIELD(symval, usb_device_id, bDeviceClass); | ||
181 | DEF_FIELD(symval, usb_device_id, bDeviceSubClass); | ||
182 | DEF_FIELD(symval, usb_device_id, bDeviceProtocol); | ||
183 | DEF_FIELD(symval, usb_device_id, bInterfaceClass); | ||
184 | DEF_FIELD(symval, usb_device_id, bInterfaceSubClass); | ||
185 | DEF_FIELD(symval, usb_device_id, bInterfaceProtocol); | ||
186 | DEF_FIELD(symval, usb_device_id, bInterfaceNumber); | ||
187 | |||
166 | strcpy(alias, "usb:"); | 188 | strcpy(alias, "usb:"); |
167 | ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR, | 189 | ADD(alias, "v", match_flags&USB_DEVICE_ID_MATCH_VENDOR, |
168 | id->idVendor); | 190 | idVendor); |
169 | ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT, | 191 | ADD(alias, "p", match_flags&USB_DEVICE_ID_MATCH_PRODUCT, |
170 | id->idProduct); | 192 | idProduct); |
171 | 193 | ||
172 | strcat(alias, "d"); | 194 | strcat(alias, "d"); |
173 | if (bcdDevice_initial_digits) | 195 | if (bcdDevice_initial_digits) |
@@ -190,29 +212,23 @@ static void do_usb_entry(struct usb_device_id *id, | |||
190 | range_lo); | 212 | range_lo); |
191 | } | 213 | } |
192 | } | 214 | } |
193 | if (bcdDevice_initial_digits < (sizeof(id->bcdDevice_lo) * 2 - 1)) | 215 | if (bcdDevice_initial_digits < (sizeof(bcdDevice_lo) * 2 - 1)) |
194 | strcat(alias, "*"); | 216 | strcat(alias, "*"); |
195 | 217 | ||
196 | ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS, | 218 | ADD(alias, "dc", match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS, |
197 | id->bDeviceClass); | 219 | bDeviceClass); |
198 | ADD(alias, "dsc", | 220 | ADD(alias, "dsc", match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS, |
199 | id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS, | 221 | bDeviceSubClass); |
200 | id->bDeviceSubClass); | 222 | ADD(alias, "dp", match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL, |
201 | ADD(alias, "dp", | 223 | bDeviceProtocol); |
202 | id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL, | 224 | ADD(alias, "ic", match_flags&USB_DEVICE_ID_MATCH_INT_CLASS, |
203 | id->bDeviceProtocol); | 225 | bInterfaceClass); |
204 | ADD(alias, "ic", | 226 | ADD(alias, "isc", match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS, |
205 | id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS, | 227 | bInterfaceSubClass); |
206 | id->bInterfaceClass); | 228 | ADD(alias, "ip", match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, |
207 | ADD(alias, "isc", | 229 | bInterfaceProtocol); |
208 | id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS, | 230 | ADD(alias, "in", match_flags&USB_DEVICE_ID_MATCH_INT_NUMBER, |
209 | id->bInterfaceSubClass); | 231 | bInterfaceNumber); |
210 | ADD(alias, "ip", | ||
211 | id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, | ||
212 | id->bInterfaceProtocol); | ||
213 | ADD(alias, "in", | ||
214 | id->match_flags&USB_DEVICE_ID_MATCH_INT_NUMBER, | ||
215 | id->bInterfaceNumber); | ||
216 | 232 | ||
217 | add_wildcard(alias); | 233 | add_wildcard(alias); |
218 | buf_printf(&mod->dev_table_buf, | 234 | buf_printf(&mod->dev_table_buf, |
@@ -258,24 +274,28 @@ static unsigned int incbcd(unsigned int *bcd, | |||
258 | return init; | 274 | return init; |
259 | } | 275 | } |
260 | 276 | ||
261 | static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod) | 277 | static void do_usb_entry_multi(void *symval, struct module *mod) |
262 | { | 278 | { |
263 | unsigned int devlo, devhi; | 279 | unsigned int devlo, devhi; |
264 | unsigned char chi, clo, max; | 280 | unsigned char chi, clo, max; |
265 | int ndigits; | 281 | int ndigits; |
266 | 282 | ||
267 | id->match_flags = TO_NATIVE(id->match_flags); | 283 | DEF_FIELD(symval, usb_device_id, match_flags); |
268 | id->idVendor = TO_NATIVE(id->idVendor); | 284 | DEF_FIELD(symval, usb_device_id, idVendor); |
269 | id->idProduct = TO_NATIVE(id->idProduct); | 285 | DEF_FIELD(symval, usb_device_id, idProduct); |
286 | DEF_FIELD(symval, usb_device_id, bcdDevice_lo); | ||
287 | DEF_FIELD(symval, usb_device_id, bcdDevice_hi); | ||
288 | DEF_FIELD(symval, usb_device_id, bDeviceClass); | ||
289 | DEF_FIELD(symval, usb_device_id, bInterfaceClass); | ||
270 | 290 | ||
271 | devlo = id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO ? | 291 | devlo = match_flags & USB_DEVICE_ID_MATCH_DEV_LO ? |
272 | TO_NATIVE(id->bcdDevice_lo) : 0x0U; | 292 | bcdDevice_lo : 0x0U; |
273 | devhi = id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI ? | 293 | devhi = match_flags & USB_DEVICE_ID_MATCH_DEV_HI ? |
274 | TO_NATIVE(id->bcdDevice_hi) : ~0x0U; | 294 | bcdDevice_hi : ~0x0U; |
275 | 295 | ||
276 | /* Figure out if this entry is in bcd or hex format */ | 296 | /* Figure out if this entry is in bcd or hex format */ |
277 | max = 0x9; /* Default to decimal format */ | 297 | max = 0x9; /* Default to decimal format */ |
278 | for (ndigits = 0 ; ndigits < sizeof(id->bcdDevice_lo) * 2 ; ndigits++) { | 298 | for (ndigits = 0 ; ndigits < sizeof(bcdDevice_lo) * 2 ; ndigits++) { |
279 | clo = (devlo >> (ndigits << 2)) & 0xf; | 299 | clo = (devlo >> (ndigits << 2)) & 0xf; |
280 | chi = ((devhi > 0x9999 ? 0x9999 : devhi) >> (ndigits << 2)) & 0xf; | 300 | chi = ((devhi > 0x9999 ? 0x9999 : devhi) >> (ndigits << 2)) & 0xf; |
281 | if (clo > max || chi > max) { | 301 | if (clo > max || chi > max) { |
@@ -288,11 +308,11 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod) | |||
288 | * Some modules (visor) have empty slots as placeholder for | 308 | * Some modules (visor) have empty slots as placeholder for |
289 | * run-time specification that results in catch-all alias | 309 | * run-time specification that results in catch-all alias |
290 | */ | 310 | */ |
291 | if (!(id->idVendor | id->idProduct | id->bDeviceClass | id->bInterfaceClass)) | 311 | if (!(idVendor | idProduct | bDeviceClass | bInterfaceClass)) |
292 | return; | 312 | return; |
293 | 313 | ||
294 | /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */ | 314 | /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */ |
295 | for (ndigits = sizeof(id->bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) { | 315 | for (ndigits = sizeof(bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) { |
296 | clo = devlo & 0xf; | 316 | clo = devlo & 0xf; |
297 | chi = devhi & 0xf; | 317 | chi = devhi & 0xf; |
298 | if (chi > max) /* If we are in bcd mode, truncate if necessary */ | 318 | if (chi > max) /* If we are in bcd mode, truncate if necessary */ |
@@ -301,20 +321,20 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod) | |||
301 | devhi >>= 4; | 321 | devhi >>= 4; |
302 | 322 | ||
303 | if (devlo == devhi || !ndigits) { | 323 | if (devlo == devhi || !ndigits) { |
304 | do_usb_entry(id, devlo, ndigits, clo, chi, max, mod); | 324 | do_usb_entry(symval, devlo, ndigits, clo, chi, max, mod); |
305 | break; | 325 | break; |
306 | } | 326 | } |
307 | 327 | ||
308 | if (clo > 0x0) | 328 | if (clo > 0x0) |
309 | do_usb_entry(id, | 329 | do_usb_entry(symval, |
310 | incbcd(&devlo, 1, max, | 330 | incbcd(&devlo, 1, max, |
311 | sizeof(id->bcdDevice_lo) * 2), | 331 | sizeof(bcdDevice_lo) * 2), |
312 | ndigits, clo, max, max, mod); | 332 | ndigits, clo, max, max, mod); |
313 | 333 | ||
314 | if (chi < max) | 334 | if (chi < max) |
315 | do_usb_entry(id, | 335 | do_usb_entry(symval, |
316 | incbcd(&devhi, -1, max, | 336 | incbcd(&devhi, -1, max, |
317 | sizeof(id->bcdDevice_lo) * 2), | 337 | sizeof(bcdDevice_lo) * 2), |
318 | ndigits, 0x0, chi, max, mod); | 338 | ndigits, 0x0, chi, max, mod); |
319 | } | 339 | } |
320 | } | 340 | } |
@@ -323,7 +343,7 @@ static void do_usb_table(void *symval, unsigned long size, | |||
323 | struct module *mod) | 343 | struct module *mod) |
324 | { | 344 | { |
325 | unsigned int i; | 345 | unsigned int i; |
326 | const unsigned long id_size = sizeof(struct usb_device_id); | 346 | const unsigned long id_size = SIZE_usb_device_id; |
327 | 347 | ||
328 | device_id_check(mod->name, "usb", size, id_size, symval); | 348 | device_id_check(mod->name, "usb", size, id_size, symval); |
329 | 349 | ||
@@ -336,81 +356,81 @@ static void do_usb_table(void *symval, unsigned long size, | |||
336 | 356 | ||
337 | /* Looks like: hid:bNvNpN */ | 357 | /* Looks like: hid:bNvNpN */ |
338 | static int do_hid_entry(const char *filename, | 358 | static int do_hid_entry(const char *filename, |
339 | struct hid_device_id *id, char *alias) | 359 | void *symval, char *alias) |
340 | { | 360 | { |
341 | id->bus = TO_NATIVE(id->bus); | 361 | DEF_FIELD(symval, hid_device_id, bus); |
342 | id->group = TO_NATIVE(id->group); | 362 | DEF_FIELD(symval, hid_device_id, group); |
343 | id->vendor = TO_NATIVE(id->vendor); | 363 | DEF_FIELD(symval, hid_device_id, vendor); |
344 | id->product = TO_NATIVE(id->product); | 364 | DEF_FIELD(symval, hid_device_id, product); |
345 | 365 | ||
346 | sprintf(alias, "hid:"); | 366 | sprintf(alias, "hid:"); |
347 | ADD(alias, "b", id->bus != HID_BUS_ANY, id->bus); | 367 | ADD(alias, "b", bus != HID_BUS_ANY, bus); |
348 | ADD(alias, "g", id->group != HID_GROUP_ANY, id->group); | 368 | ADD(alias, "g", group != HID_GROUP_ANY, group); |
349 | ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor); | 369 | ADD(alias, "v", vendor != HID_ANY_ID, vendor); |
350 | ADD(alias, "p", id->product != HID_ANY_ID, id->product); | 370 | ADD(alias, "p", product != HID_ANY_ID, product); |
351 | 371 | ||
352 | return 1; | 372 | return 1; |
353 | } | 373 | } |
354 | ADD_TO_DEVTABLE("hid", struct hid_device_id, do_hid_entry); | 374 | ADD_TO_DEVTABLE("hid", hid_device_id, do_hid_entry); |
355 | 375 | ||
356 | /* Looks like: ieee1394:venNmoNspNverN */ | 376 | /* Looks like: ieee1394:venNmoNspNverN */ |
357 | static int do_ieee1394_entry(const char *filename, | 377 | static int do_ieee1394_entry(const char *filename, |
358 | struct ieee1394_device_id *id, char *alias) | 378 | void *symval, char *alias) |
359 | { | 379 | { |
360 | id->match_flags = TO_NATIVE(id->match_flags); | 380 | DEF_FIELD(symval, ieee1394_device_id, match_flags); |
361 | id->vendor_id = TO_NATIVE(id->vendor_id); | 381 | DEF_FIELD(symval, ieee1394_device_id, vendor_id); |
362 | id->model_id = TO_NATIVE(id->model_id); | 382 | DEF_FIELD(symval, ieee1394_device_id, model_id); |
363 | id->specifier_id = TO_NATIVE(id->specifier_id); | 383 | DEF_FIELD(symval, ieee1394_device_id, specifier_id); |
364 | id->version = TO_NATIVE(id->version); | 384 | DEF_FIELD(symval, ieee1394_device_id, version); |
365 | 385 | ||
366 | strcpy(alias, "ieee1394:"); | 386 | strcpy(alias, "ieee1394:"); |
367 | ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID, | 387 | ADD(alias, "ven", match_flags & IEEE1394_MATCH_VENDOR_ID, |
368 | id->vendor_id); | 388 | vendor_id); |
369 | ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID, | 389 | ADD(alias, "mo", match_flags & IEEE1394_MATCH_MODEL_ID, |
370 | id->model_id); | 390 | model_id); |
371 | ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID, | 391 | ADD(alias, "sp", match_flags & IEEE1394_MATCH_SPECIFIER_ID, |
372 | id->specifier_id); | 392 | specifier_id); |
373 | ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION, | 393 | ADD(alias, "ver", match_flags & IEEE1394_MATCH_VERSION, |
374 | id->version); | 394 | version); |
375 | 395 | ||
376 | add_wildcard(alias); | 396 | add_wildcard(alias); |
377 | return 1; | 397 | return 1; |
378 | } | 398 | } |
379 | ADD_TO_DEVTABLE("ieee1394", struct ieee1394_device_id, do_ieee1394_entry); | 399 | ADD_TO_DEVTABLE("ieee1394", ieee1394_device_id, do_ieee1394_entry); |
380 | 400 | ||
381 | /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ | 401 | /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ |
382 | static int do_pci_entry(const char *filename, | 402 | static int do_pci_entry(const char *filename, |
383 | struct pci_device_id *id, char *alias) | 403 | void *symval, char *alias) |
384 | { | 404 | { |
385 | /* Class field can be divided into these three. */ | 405 | /* Class field can be divided into these three. */ |
386 | unsigned char baseclass, subclass, interface, | 406 | unsigned char baseclass, subclass, interface, |
387 | baseclass_mask, subclass_mask, interface_mask; | 407 | baseclass_mask, subclass_mask, interface_mask; |
388 | 408 | ||
389 | id->vendor = TO_NATIVE(id->vendor); | 409 | DEF_FIELD(symval, pci_device_id, vendor); |
390 | id->device = TO_NATIVE(id->device); | 410 | DEF_FIELD(symval, pci_device_id, device); |
391 | id->subvendor = TO_NATIVE(id->subvendor); | 411 | DEF_FIELD(symval, pci_device_id, subvendor); |
392 | id->subdevice = TO_NATIVE(id->subdevice); | 412 | DEF_FIELD(symval, pci_device_id, subdevice); |
393 | id->class = TO_NATIVE(id->class); | 413 | DEF_FIELD(symval, pci_device_id, class); |
394 | id->class_mask = TO_NATIVE(id->class_mask); | 414 | DEF_FIELD(symval, pci_device_id, class_mask); |
395 | 415 | ||
396 | strcpy(alias, "pci:"); | 416 | strcpy(alias, "pci:"); |
397 | ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor); | 417 | ADD(alias, "v", vendor != PCI_ANY_ID, vendor); |
398 | ADD(alias, "d", id->device != PCI_ANY_ID, id->device); | 418 | ADD(alias, "d", device != PCI_ANY_ID, device); |
399 | ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor); | 419 | ADD(alias, "sv", subvendor != PCI_ANY_ID, subvendor); |
400 | ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice); | 420 | ADD(alias, "sd", subdevice != PCI_ANY_ID, subdevice); |
401 | 421 | ||
402 | baseclass = (id->class) >> 16; | 422 | baseclass = (class) >> 16; |
403 | baseclass_mask = (id->class_mask) >> 16; | 423 | baseclass_mask = (class_mask) >> 16; |
404 | subclass = (id->class) >> 8; | 424 | subclass = (class) >> 8; |
405 | subclass_mask = (id->class_mask) >> 8; | 425 | subclass_mask = (class_mask) >> 8; |
406 | interface = id->class; | 426 | interface = class; |
407 | interface_mask = id->class_mask; | 427 | interface_mask = class_mask; |
408 | 428 | ||
409 | if ((baseclass_mask != 0 && baseclass_mask != 0xFF) | 429 | if ((baseclass_mask != 0 && baseclass_mask != 0xFF) |
410 | || (subclass_mask != 0 && subclass_mask != 0xFF) | 430 | || (subclass_mask != 0 && subclass_mask != 0xFF) |
411 | || (interface_mask != 0 && interface_mask != 0xFF)) { | 431 | || (interface_mask != 0 && interface_mask != 0xFF)) { |
412 | warn("Can't handle masks in %s:%04X\n", | 432 | warn("Can't handle masks in %s:%04X\n", |
413 | filename, id->class_mask); | 433 | filename, class_mask); |
414 | return 0; | 434 | return 0; |
415 | } | 435 | } |
416 | 436 | ||
@@ -420,101 +440,105 @@ static int do_pci_entry(const char *filename, | |||
420 | add_wildcard(alias); | 440 | add_wildcard(alias); |
421 | return 1; | 441 | return 1; |
422 | } | 442 | } |
423 | ADD_TO_DEVTABLE("pci", struct pci_device_id, do_pci_entry); | 443 | ADD_TO_DEVTABLE("pci", pci_device_id, do_pci_entry); |
424 | 444 | ||
425 | /* looks like: "ccw:tNmNdtNdmN" */ | 445 | /* looks like: "ccw:tNmNdtNdmN" */ |
426 | static int do_ccw_entry(const char *filename, | 446 | static int do_ccw_entry(const char *filename, |
427 | struct ccw_device_id *id, char *alias) | 447 | void *symval, char *alias) |
428 | { | 448 | { |
429 | id->match_flags = TO_NATIVE(id->match_flags); | 449 | DEF_FIELD(symval, ccw_device_id, match_flags); |
430 | id->cu_type = TO_NATIVE(id->cu_type); | 450 | DEF_FIELD(symval, ccw_device_id, cu_type); |
431 | id->cu_model = TO_NATIVE(id->cu_model); | 451 | DEF_FIELD(symval, ccw_device_id, cu_model); |
432 | id->dev_type = TO_NATIVE(id->dev_type); | 452 | DEF_FIELD(symval, ccw_device_id, dev_type); |
433 | id->dev_model = TO_NATIVE(id->dev_model); | 453 | DEF_FIELD(symval, ccw_device_id, dev_model); |
434 | 454 | ||
435 | strcpy(alias, "ccw:"); | 455 | strcpy(alias, "ccw:"); |
436 | ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE, | 456 | ADD(alias, "t", match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE, |
437 | id->cu_type); | 457 | cu_type); |
438 | ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL, | 458 | ADD(alias, "m", match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL, |
439 | id->cu_model); | 459 | cu_model); |
440 | ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE, | 460 | ADD(alias, "dt", match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE, |
441 | id->dev_type); | 461 | dev_type); |
442 | ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, | 462 | ADD(alias, "dm", match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, |
443 | id->dev_model); | 463 | dev_model); |
444 | add_wildcard(alias); | 464 | add_wildcard(alias); |
445 | return 1; | 465 | return 1; |
446 | } | 466 | } |
447 | ADD_TO_DEVTABLE("ccw", struct ccw_device_id, do_ccw_entry); | 467 | ADD_TO_DEVTABLE("ccw", ccw_device_id, do_ccw_entry); |
448 | 468 | ||
449 | /* looks like: "ap:tN" */ | 469 | /* looks like: "ap:tN" */ |
450 | static int do_ap_entry(const char *filename, | 470 | static int do_ap_entry(const char *filename, |
451 | struct ap_device_id *id, char *alias) | 471 | void *symval, char *alias) |
452 | { | 472 | { |
453 | sprintf(alias, "ap:t%02X*", id->dev_type); | 473 | DEF_FIELD(symval, ap_device_id, dev_type); |
474 | |||
475 | sprintf(alias, "ap:t%02X*", dev_type); | ||
454 | return 1; | 476 | return 1; |
455 | } | 477 | } |
456 | ADD_TO_DEVTABLE("ap", struct ap_device_id, do_ap_entry); | 478 | ADD_TO_DEVTABLE("ap", ap_device_id, do_ap_entry); |
457 | 479 | ||
458 | /* looks like: "css:tN" */ | 480 | /* looks like: "css:tN" */ |
459 | static int do_css_entry(const char *filename, | 481 | static int do_css_entry(const char *filename, |
460 | struct css_device_id *id, char *alias) | 482 | void *symval, char *alias) |
461 | { | 483 | { |
462 | sprintf(alias, "css:t%01X", id->type); | 484 | DEF_FIELD(symval, css_device_id, type); |
485 | |||
486 | sprintf(alias, "css:t%01X", type); | ||
463 | return 1; | 487 | return 1; |
464 | } | 488 | } |
465 | ADD_TO_DEVTABLE("css", struct css_device_id, do_css_entry); | 489 | ADD_TO_DEVTABLE("css", css_device_id, do_css_entry); |
466 | 490 | ||
467 | /* Looks like: "serio:tyNprNidNexN" */ | 491 | /* Looks like: "serio:tyNprNidNexN" */ |
468 | static int do_serio_entry(const char *filename, | 492 | static int do_serio_entry(const char *filename, |
469 | struct serio_device_id *id, char *alias) | 493 | void *symval, char *alias) |
470 | { | 494 | { |
471 | id->type = TO_NATIVE(id->type); | 495 | DEF_FIELD(symval, serio_device_id, type); |
472 | id->proto = TO_NATIVE(id->proto); | 496 | DEF_FIELD(symval, serio_device_id, proto); |
473 | id->id = TO_NATIVE(id->id); | 497 | DEF_FIELD(symval, serio_device_id, id); |
474 | id->extra = TO_NATIVE(id->extra); | 498 | DEF_FIELD(symval, serio_device_id, extra); |
475 | 499 | ||
476 | strcpy(alias, "serio:"); | 500 | strcpy(alias, "serio:"); |
477 | ADD(alias, "ty", id->type != SERIO_ANY, id->type); | 501 | ADD(alias, "ty", type != SERIO_ANY, type); |
478 | ADD(alias, "pr", id->proto != SERIO_ANY, id->proto); | 502 | ADD(alias, "pr", proto != SERIO_ANY, proto); |
479 | ADD(alias, "id", id->id != SERIO_ANY, id->id); | 503 | ADD(alias, "id", id != SERIO_ANY, id); |
480 | ADD(alias, "ex", id->extra != SERIO_ANY, id->extra); | 504 | ADD(alias, "ex", extra != SERIO_ANY, extra); |
481 | 505 | ||
482 | add_wildcard(alias); | 506 | add_wildcard(alias); |
483 | return 1; | 507 | return 1; |
484 | } | 508 | } |
485 | ADD_TO_DEVTABLE("serio", struct serio_device_id, do_serio_entry); | 509 | ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry); |
486 | 510 | ||
487 | /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ | 511 | /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ |
488 | static int do_acpi_entry(const char *filename, | 512 | static int do_acpi_entry(const char *filename, |
489 | struct acpi_device_id *id, char *alias) | 513 | void *symval, char *alias) |
490 | { | 514 | { |
491 | sprintf(alias, "acpi*:%s:*", id->id); | 515 | DEF_FIELD_ADDR(symval, acpi_device_id, id); |
516 | sprintf(alias, "acpi*:%s:*", *id); | ||
492 | return 1; | 517 | return 1; |
493 | } | 518 | } |
494 | ADD_TO_DEVTABLE("acpi", struct acpi_device_id, do_acpi_entry); | 519 | ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry); |
495 | 520 | ||
496 | /* looks like: "pnp:dD" */ | 521 | /* looks like: "pnp:dD" */ |
497 | static void do_pnp_device_entry(void *symval, unsigned long size, | 522 | static void do_pnp_device_entry(void *symval, unsigned long size, |
498 | struct module *mod) | 523 | struct module *mod) |
499 | { | 524 | { |
500 | const unsigned long id_size = sizeof(struct pnp_device_id); | 525 | const unsigned long id_size = SIZE_pnp_device_id; |
501 | const unsigned int count = (size / id_size)-1; | 526 | const unsigned int count = (size / id_size)-1; |
502 | const struct pnp_device_id *devs = symval; | ||
503 | unsigned int i; | 527 | unsigned int i; |
504 | 528 | ||
505 | device_id_check(mod->name, "pnp", size, id_size, symval); | 529 | device_id_check(mod->name, "pnp", size, id_size, symval); |
506 | 530 | ||
507 | for (i = 0; i < count; i++) { | 531 | for (i = 0; i < count; i++) { |
508 | const char *id = (char *)devs[i].id; | 532 | DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id); |
509 | char acpi_id[sizeof(devs[0].id)]; | 533 | char acpi_id[sizeof(*id)]; |
510 | int j; | 534 | int j; |
511 | 535 | ||
512 | buf_printf(&mod->dev_table_buf, | 536 | buf_printf(&mod->dev_table_buf, |
513 | "MODULE_ALIAS(\"pnp:d%s*\");\n", id); | 537 | "MODULE_ALIAS(\"pnp:d%s*\");\n", *id); |
514 | 538 | ||
515 | /* fix broken pnp bus lowercasing */ | 539 | /* fix broken pnp bus lowercasing */ |
516 | for (j = 0; j < sizeof(acpi_id); j++) | 540 | for (j = 0; j < sizeof(acpi_id); j++) |
517 | acpi_id[j] = toupper(id[j]); | 541 | acpi_id[j] = toupper((*id)[j]); |
518 | buf_printf(&mod->dev_table_buf, | 542 | buf_printf(&mod->dev_table_buf, |
519 | "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); | 543 | "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); |
520 | } | 544 | } |
@@ -524,19 +548,18 @@ static void do_pnp_device_entry(void *symval, unsigned long size, | |||
524 | static void do_pnp_card_entries(void *symval, unsigned long size, | 548 | static void do_pnp_card_entries(void *symval, unsigned long size, |
525 | struct module *mod) | 549 | struct module *mod) |
526 | { | 550 | { |
527 | const unsigned long id_size = sizeof(struct pnp_card_device_id); | 551 | const unsigned long id_size = SIZE_pnp_card_device_id; |
528 | const unsigned int count = (size / id_size)-1; | 552 | const unsigned int count = (size / id_size)-1; |
529 | const struct pnp_card_device_id *cards = symval; | ||
530 | unsigned int i; | 553 | unsigned int i; |
531 | 554 | ||
532 | device_id_check(mod->name, "pnp", size, id_size, symval); | 555 | device_id_check(mod->name, "pnp", size, id_size, symval); |
533 | 556 | ||
534 | for (i = 0; i < count; i++) { | 557 | for (i = 0; i < count; i++) { |
535 | unsigned int j; | 558 | unsigned int j; |
536 | const struct pnp_card_device_id *card = &cards[i]; | 559 | DEF_FIELD_ADDR(symval + i*id_size, pnp_card_device_id, devs); |
537 | 560 | ||
538 | for (j = 0; j < PNP_MAX_DEVICES; j++) { | 561 | for (j = 0; j < PNP_MAX_DEVICES; j++) { |
539 | const char *id = (char *)card->devs[j].id; | 562 | const char *id = (char *)(*devs)[j].id; |
540 | int i2, j2; | 563 | int i2, j2; |
541 | int dup = 0; | 564 | int dup = 0; |
542 | 565 | ||
@@ -545,10 +568,10 @@ static void do_pnp_card_entries(void *symval, unsigned long size, | |||
545 | 568 | ||
546 | /* find duplicate, already added value */ | 569 | /* find duplicate, already added value */ |
547 | for (i2 = 0; i2 < i && !dup; i2++) { | 570 | for (i2 = 0; i2 < i && !dup; i2++) { |
548 | const struct pnp_card_device_id *card2 = &cards[i2]; | 571 | DEF_FIELD_ADDR(symval + i2*id_size, pnp_card_device_id, devs); |
549 | 572 | ||
550 | for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { | 573 | for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { |
551 | const char *id2 = (char *)card2->devs[j2].id; | 574 | const char *id2 = (char *)(*devs)[j2].id; |
552 | 575 | ||
553 | if (!id2[0]) | 576 | if (!id2[0]) |
554 | break; | 577 | break; |
@@ -562,7 +585,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size, | |||
562 | 585 | ||
563 | /* add an individual alias for every device entry */ | 586 | /* add an individual alias for every device entry */ |
564 | if (!dup) { | 587 | if (!dup) { |
565 | char acpi_id[sizeof(card->devs[0].id)]; | 588 | char acpi_id[PNP_ID_LEN]; |
566 | int k; | 589 | int k; |
567 | 590 | ||
568 | buf_printf(&mod->dev_table_buf, | 591 | buf_printf(&mod->dev_table_buf, |
@@ -580,54 +603,58 @@ static void do_pnp_card_entries(void *symval, unsigned long size, | |||
580 | 603 | ||
581 | /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */ | 604 | /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */ |
582 | static int do_pcmcia_entry(const char *filename, | 605 | static int do_pcmcia_entry(const char *filename, |
583 | struct pcmcia_device_id *id, char *alias) | 606 | void *symval, char *alias) |
584 | { | 607 | { |
585 | unsigned int i; | 608 | unsigned int i; |
586 | 609 | DEF_FIELD(symval, pcmcia_device_id, match_flags); | |
587 | id->match_flags = TO_NATIVE(id->match_flags); | 610 | DEF_FIELD(symval, pcmcia_device_id, manf_id); |
588 | id->manf_id = TO_NATIVE(id->manf_id); | 611 | DEF_FIELD(symval, pcmcia_device_id, card_id); |
589 | id->card_id = TO_NATIVE(id->card_id); | 612 | DEF_FIELD(symval, pcmcia_device_id, func_id); |
590 | id->func_id = TO_NATIVE(id->func_id); | 613 | DEF_FIELD(symval, pcmcia_device_id, function); |
591 | id->function = TO_NATIVE(id->function); | 614 | DEF_FIELD(symval, pcmcia_device_id, device_no); |
592 | id->device_no = TO_NATIVE(id->device_no); | 615 | DEF_FIELD_ADDR(symval, pcmcia_device_id, prod_id_hash); |
593 | 616 | ||
594 | for (i=0; i<4; i++) { | 617 | for (i=0; i<4; i++) { |
595 | id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]); | 618 | (*prod_id_hash)[i] = TO_NATIVE((*prod_id_hash)[i]); |
596 | } | 619 | } |
597 | 620 | ||
598 | strcpy(alias, "pcmcia:"); | 621 | strcpy(alias, "pcmcia:"); |
599 | ADD(alias, "m", id->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID, | 622 | ADD(alias, "m", match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID, |
600 | id->manf_id); | 623 | manf_id); |
601 | ADD(alias, "c", id->match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID, | 624 | ADD(alias, "c", match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID, |
602 | id->card_id); | 625 | card_id); |
603 | ADD(alias, "f", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID, | 626 | ADD(alias, "f", match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID, |
604 | id->func_id); | 627 | func_id); |
605 | ADD(alias, "fn", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION, | 628 | ADD(alias, "fn", match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION, |
606 | id->function); | 629 | function); |
607 | ADD(alias, "pfn", id->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO, | 630 | ADD(alias, "pfn", match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO, |
608 | id->device_no); | 631 | device_no); |
609 | ADD(alias, "pa", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, id->prod_id_hash[0]); | 632 | ADD(alias, "pa", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, (*prod_id_hash)[0]); |
610 | ADD(alias, "pb", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, id->prod_id_hash[1]); | 633 | ADD(alias, "pb", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, (*prod_id_hash)[1]); |
611 | ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]); | 634 | ADD(alias, "pc", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, (*prod_id_hash)[2]); |
612 | ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]); | 635 | ADD(alias, "pd", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, (*prod_id_hash)[3]); |
613 | 636 | ||
614 | add_wildcard(alias); | 637 | add_wildcard(alias); |
615 | return 1; | 638 | return 1; |
616 | } | 639 | } |
617 | ADD_TO_DEVTABLE("pcmcia", struct pcmcia_device_id, do_pcmcia_entry); | 640 | ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); |
618 | 641 | ||
619 | static int do_of_entry (const char *filename, struct of_device_id *of, char *alias) | 642 | static int do_of_entry (const char *filename, void *symval, char *alias) |
620 | { | 643 | { |
621 | int len; | 644 | int len; |
622 | char *tmp; | 645 | char *tmp; |
646 | DEF_FIELD_ADDR(symval, of_device_id, name); | ||
647 | DEF_FIELD_ADDR(symval, of_device_id, type); | ||
648 | DEF_FIELD_ADDR(symval, of_device_id, compatible); | ||
649 | |||
623 | len = sprintf (alias, "of:N%sT%s", | 650 | len = sprintf (alias, "of:N%sT%s", |
624 | of->name[0] ? of->name : "*", | 651 | (*name)[0] ? *name : "*", |
625 | of->type[0] ? of->type : "*"); | 652 | (*type)[0] ? *type : "*"); |
626 | 653 | ||
627 | if (of->compatible[0]) | 654 | if (compatible[0]) |
628 | sprintf (&alias[len], "%sC%s", | 655 | sprintf (&alias[len], "%sC%s", |
629 | of->type[0] ? "*" : "", | 656 | (*type)[0] ? "*" : "", |
630 | of->compatible); | 657 | *compatible); |
631 | 658 | ||
632 | /* Replace all whitespace with underscores */ | 659 | /* Replace all whitespace with underscores */ |
633 | for (tmp = alias; tmp && *tmp; tmp++) | 660 | for (tmp = alias; tmp && *tmp; tmp++) |
@@ -637,15 +664,17 @@ static int do_of_entry (const char *filename, struct of_device_id *of, char *ali | |||
637 | add_wildcard(alias); | 664 | add_wildcard(alias); |
638 | return 1; | 665 | return 1; |
639 | } | 666 | } |
640 | ADD_TO_DEVTABLE("of", struct of_device_id, do_of_entry); | 667 | ADD_TO_DEVTABLE("of", of_device_id, do_of_entry); |
641 | 668 | ||
642 | static int do_vio_entry(const char *filename, struct vio_device_id *vio, | 669 | static int do_vio_entry(const char *filename, void *symval, |
643 | char *alias) | 670 | char *alias) |
644 | { | 671 | { |
645 | char *tmp; | 672 | char *tmp; |
673 | DEF_FIELD_ADDR(symval, vio_device_id, type); | ||
674 | DEF_FIELD_ADDR(symval, vio_device_id, compat); | ||
646 | 675 | ||
647 | sprintf(alias, "vio:T%sS%s", vio->type[0] ? vio->type : "*", | 676 | sprintf(alias, "vio:T%sS%s", (*type)[0] ? *type : "*", |
648 | vio->compat[0] ? vio->compat : "*"); | 677 | (*compat)[0] ? *compat : "*"); |
649 | 678 | ||
650 | /* Replace all whitespace with underscores */ | 679 | /* Replace all whitespace with underscores */ |
651 | for (tmp = alias; tmp && *tmp; tmp++) | 680 | for (tmp = alias; tmp && *tmp; tmp++) |
@@ -655,7 +684,7 @@ static int do_vio_entry(const char *filename, struct vio_device_id *vio, | |||
655 | add_wildcard(alias); | 684 | add_wildcard(alias); |
656 | return 1; | 685 | return 1; |
657 | } | 686 | } |
658 | ADD_TO_DEVTABLE("vio", struct vio_device_id, do_vio_entry); | 687 | ADD_TO_DEVTABLE("vio", vio_device_id, do_vio_entry); |
659 | 688 | ||
660 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 689 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
661 | 690 | ||
@@ -664,154 +693,172 @@ static void do_input(char *alias, | |||
664 | { | 693 | { |
665 | unsigned int i; | 694 | unsigned int i; |
666 | 695 | ||
696 | for (i = min / BITS_PER_LONG; i < max / BITS_PER_LONG + 1; i++) | ||
697 | arr[i] = TO_NATIVE(arr[i]); | ||
667 | for (i = min; i < max; i++) | 698 | for (i = min; i < max; i++) |
668 | if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG))) | 699 | if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG))) |
669 | sprintf(alias + strlen(alias), "%X,*", i); | 700 | sprintf(alias + strlen(alias), "%X,*", i); |
670 | } | 701 | } |
671 | 702 | ||
672 | /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */ | 703 | /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */ |
673 | static int do_input_entry(const char *filename, struct input_device_id *id, | 704 | static int do_input_entry(const char *filename, void *symval, |
674 | char *alias) | 705 | char *alias) |
675 | { | 706 | { |
707 | DEF_FIELD(symval, input_device_id, flags); | ||
708 | DEF_FIELD(symval, input_device_id, bustype); | ||
709 | DEF_FIELD(symval, input_device_id, vendor); | ||
710 | DEF_FIELD(symval, input_device_id, product); | ||
711 | DEF_FIELD(symval, input_device_id, version); | ||
712 | DEF_FIELD_ADDR(symval, input_device_id, evbit); | ||
713 | DEF_FIELD_ADDR(symval, input_device_id, keybit); | ||
714 | DEF_FIELD_ADDR(symval, input_device_id, relbit); | ||
715 | DEF_FIELD_ADDR(symval, input_device_id, absbit); | ||
716 | DEF_FIELD_ADDR(symval, input_device_id, mscbit); | ||
717 | DEF_FIELD_ADDR(symval, input_device_id, ledbit); | ||
718 | DEF_FIELD_ADDR(symval, input_device_id, sndbit); | ||
719 | DEF_FIELD_ADDR(symval, input_device_id, ffbit); | ||
720 | DEF_FIELD_ADDR(symval, input_device_id, swbit); | ||
721 | |||
676 | sprintf(alias, "input:"); | 722 | sprintf(alias, "input:"); |
677 | 723 | ||
678 | ADD(alias, "b", id->flags & INPUT_DEVICE_ID_MATCH_BUS, id->bustype); | 724 | ADD(alias, "b", flags & INPUT_DEVICE_ID_MATCH_BUS, bustype); |
679 | ADD(alias, "v", id->flags & INPUT_DEVICE_ID_MATCH_VENDOR, id->vendor); | 725 | ADD(alias, "v", flags & INPUT_DEVICE_ID_MATCH_VENDOR, vendor); |
680 | ADD(alias, "p", id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT, id->product); | 726 | ADD(alias, "p", flags & INPUT_DEVICE_ID_MATCH_PRODUCT, product); |
681 | ADD(alias, "e", id->flags & INPUT_DEVICE_ID_MATCH_VERSION, id->version); | 727 | ADD(alias, "e", flags & INPUT_DEVICE_ID_MATCH_VERSION, version); |
682 | 728 | ||
683 | sprintf(alias + strlen(alias), "-e*"); | 729 | sprintf(alias + strlen(alias), "-e*"); |
684 | if (id->flags & INPUT_DEVICE_ID_MATCH_EVBIT) | 730 | if (flags & INPUT_DEVICE_ID_MATCH_EVBIT) |
685 | do_input(alias, id->evbit, 0, INPUT_DEVICE_ID_EV_MAX); | 731 | do_input(alias, *evbit, 0, INPUT_DEVICE_ID_EV_MAX); |
686 | sprintf(alias + strlen(alias), "k*"); | 732 | sprintf(alias + strlen(alias), "k*"); |
687 | if (id->flags & INPUT_DEVICE_ID_MATCH_KEYBIT) | 733 | if (flags & INPUT_DEVICE_ID_MATCH_KEYBIT) |
688 | do_input(alias, id->keybit, | 734 | do_input(alias, *keybit, |
689 | INPUT_DEVICE_ID_KEY_MIN_INTERESTING, | 735 | INPUT_DEVICE_ID_KEY_MIN_INTERESTING, |
690 | INPUT_DEVICE_ID_KEY_MAX); | 736 | INPUT_DEVICE_ID_KEY_MAX); |
691 | sprintf(alias + strlen(alias), "r*"); | 737 | sprintf(alias + strlen(alias), "r*"); |
692 | if (id->flags & INPUT_DEVICE_ID_MATCH_RELBIT) | 738 | if (flags & INPUT_DEVICE_ID_MATCH_RELBIT) |
693 | do_input(alias, id->relbit, 0, INPUT_DEVICE_ID_REL_MAX); | 739 | do_input(alias, *relbit, 0, INPUT_DEVICE_ID_REL_MAX); |
694 | sprintf(alias + strlen(alias), "a*"); | 740 | sprintf(alias + strlen(alias), "a*"); |
695 | if (id->flags & INPUT_DEVICE_ID_MATCH_ABSBIT) | 741 | if (flags & INPUT_DEVICE_ID_MATCH_ABSBIT) |
696 | do_input(alias, id->absbit, 0, INPUT_DEVICE_ID_ABS_MAX); | 742 | do_input(alias, *absbit, 0, INPUT_DEVICE_ID_ABS_MAX); |
697 | sprintf(alias + strlen(alias), "m*"); | 743 | sprintf(alias + strlen(alias), "m*"); |
698 | if (id->flags & INPUT_DEVICE_ID_MATCH_MSCIT) | 744 | if (flags & INPUT_DEVICE_ID_MATCH_MSCIT) |
699 | do_input(alias, id->mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); | 745 | do_input(alias, *mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); |
700 | sprintf(alias + strlen(alias), "l*"); | 746 | sprintf(alias + strlen(alias), "l*"); |
701 | if (id->flags & INPUT_DEVICE_ID_MATCH_LEDBIT) | 747 | if (flags & INPUT_DEVICE_ID_MATCH_LEDBIT) |
702 | do_input(alias, id->ledbit, 0, INPUT_DEVICE_ID_LED_MAX); | 748 | do_input(alias, *ledbit, 0, INPUT_DEVICE_ID_LED_MAX); |
703 | sprintf(alias + strlen(alias), "s*"); | 749 | sprintf(alias + strlen(alias), "s*"); |
704 | if (id->flags & INPUT_DEVICE_ID_MATCH_SNDBIT) | 750 | if (flags & INPUT_DEVICE_ID_MATCH_SNDBIT) |
705 | do_input(alias, id->sndbit, 0, INPUT_DEVICE_ID_SND_MAX); | 751 | do_input(alias, *sndbit, 0, INPUT_DEVICE_ID_SND_MAX); |
706 | sprintf(alias + strlen(alias), "f*"); | 752 | sprintf(alias + strlen(alias), "f*"); |
707 | if (id->flags & INPUT_DEVICE_ID_MATCH_FFBIT) | 753 | if (flags & INPUT_DEVICE_ID_MATCH_FFBIT) |
708 | do_input(alias, id->ffbit, 0, INPUT_DEVICE_ID_FF_MAX); | 754 | do_input(alias, *ffbit, 0, INPUT_DEVICE_ID_FF_MAX); |
709 | sprintf(alias + strlen(alias), "w*"); | 755 | sprintf(alias + strlen(alias), "w*"); |
710 | if (id->flags & INPUT_DEVICE_ID_MATCH_SWBIT) | 756 | if (flags & INPUT_DEVICE_ID_MATCH_SWBIT) |
711 | do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); | 757 | do_input(alias, *swbit, 0, INPUT_DEVICE_ID_SW_MAX); |
712 | return 1; | 758 | return 1; |
713 | } | 759 | } |
714 | ADD_TO_DEVTABLE("input", struct input_device_id, do_input_entry); | 760 | ADD_TO_DEVTABLE("input", input_device_id, do_input_entry); |
715 | 761 | ||
716 | static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, | 762 | static int do_eisa_entry(const char *filename, void *symval, |
717 | char *alias) | 763 | char *alias) |
718 | { | 764 | { |
719 | if (eisa->sig[0]) | 765 | DEF_FIELD_ADDR(symval, eisa_device_id, sig); |
720 | sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig); | 766 | if (sig[0]) |
767 | sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", *sig); | ||
721 | else | 768 | else |
722 | strcat(alias, "*"); | 769 | strcat(alias, "*"); |
723 | return 1; | 770 | return 1; |
724 | } | 771 | } |
725 | ADD_TO_DEVTABLE("eisa", struct eisa_device_id, do_eisa_entry); | 772 | ADD_TO_DEVTABLE("eisa", eisa_device_id, do_eisa_entry); |
726 | 773 | ||
727 | /* Looks like: parisc:tNhvNrevNsvN */ | 774 | /* Looks like: parisc:tNhvNrevNsvN */ |
728 | static int do_parisc_entry(const char *filename, struct parisc_device_id *id, | 775 | static int do_parisc_entry(const char *filename, void *symval, |
729 | char *alias) | 776 | char *alias) |
730 | { | 777 | { |
731 | id->hw_type = TO_NATIVE(id->hw_type); | 778 | DEF_FIELD(symval, parisc_device_id, hw_type); |
732 | id->hversion = TO_NATIVE(id->hversion); | 779 | DEF_FIELD(symval, parisc_device_id, hversion); |
733 | id->hversion_rev = TO_NATIVE(id->hversion_rev); | 780 | DEF_FIELD(symval, parisc_device_id, hversion_rev); |
734 | id->sversion = TO_NATIVE(id->sversion); | 781 | DEF_FIELD(symval, parisc_device_id, sversion); |
735 | 782 | ||
736 | strcpy(alias, "parisc:"); | 783 | strcpy(alias, "parisc:"); |
737 | ADD(alias, "t", id->hw_type != PA_HWTYPE_ANY_ID, id->hw_type); | 784 | ADD(alias, "t", hw_type != PA_HWTYPE_ANY_ID, hw_type); |
738 | ADD(alias, "hv", id->hversion != PA_HVERSION_ANY_ID, id->hversion); | 785 | ADD(alias, "hv", hversion != PA_HVERSION_ANY_ID, hversion); |
739 | ADD(alias, "rev", id->hversion_rev != PA_HVERSION_REV_ANY_ID, id->hversion_rev); | 786 | ADD(alias, "rev", hversion_rev != PA_HVERSION_REV_ANY_ID, hversion_rev); |
740 | ADD(alias, "sv", id->sversion != PA_SVERSION_ANY_ID, id->sversion); | 787 | ADD(alias, "sv", sversion != PA_SVERSION_ANY_ID, sversion); |
741 | 788 | ||
742 | add_wildcard(alias); | 789 | add_wildcard(alias); |
743 | return 1; | 790 | return 1; |
744 | } | 791 | } |
745 | ADD_TO_DEVTABLE("parisc", struct parisc_device_id, do_parisc_entry); | 792 | ADD_TO_DEVTABLE("parisc", parisc_device_id, do_parisc_entry); |
746 | 793 | ||
747 | /* Looks like: sdio:cNvNdN. */ | 794 | /* Looks like: sdio:cNvNdN. */ |
748 | static int do_sdio_entry(const char *filename, | 795 | static int do_sdio_entry(const char *filename, |
749 | struct sdio_device_id *id, char *alias) | 796 | void *symval, char *alias) |
750 | { | 797 | { |
751 | id->class = TO_NATIVE(id->class); | 798 | DEF_FIELD(symval, sdio_device_id, class); |
752 | id->vendor = TO_NATIVE(id->vendor); | 799 | DEF_FIELD(symval, sdio_device_id, vendor); |
753 | id->device = TO_NATIVE(id->device); | 800 | DEF_FIELD(symval, sdio_device_id, device); |
754 | 801 | ||
755 | strcpy(alias, "sdio:"); | 802 | strcpy(alias, "sdio:"); |
756 | ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class); | 803 | ADD(alias, "c", class != (__u8)SDIO_ANY_ID, class); |
757 | ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor); | 804 | ADD(alias, "v", vendor != (__u16)SDIO_ANY_ID, vendor); |
758 | ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device); | 805 | ADD(alias, "d", device != (__u16)SDIO_ANY_ID, device); |
759 | add_wildcard(alias); | 806 | add_wildcard(alias); |
760 | return 1; | 807 | return 1; |
761 | } | 808 | } |
762 | ADD_TO_DEVTABLE("sdio", struct sdio_device_id, do_sdio_entry); | 809 | ADD_TO_DEVTABLE("sdio", sdio_device_id, do_sdio_entry); |
763 | 810 | ||
764 | /* Looks like: ssb:vNidNrevN. */ | 811 | /* Looks like: ssb:vNidNrevN. */ |
765 | static int do_ssb_entry(const char *filename, | 812 | static int do_ssb_entry(const char *filename, |
766 | struct ssb_device_id *id, char *alias) | 813 | void *symval, char *alias) |
767 | { | 814 | { |
768 | id->vendor = TO_NATIVE(id->vendor); | 815 | DEF_FIELD(symval, ssb_device_id, vendor); |
769 | id->coreid = TO_NATIVE(id->coreid); | 816 | DEF_FIELD(symval, ssb_device_id, coreid); |
770 | id->revision = TO_NATIVE(id->revision); | 817 | DEF_FIELD(symval, ssb_device_id, revision); |
771 | 818 | ||
772 | strcpy(alias, "ssb:"); | 819 | strcpy(alias, "ssb:"); |
773 | ADD(alias, "v", id->vendor != SSB_ANY_VENDOR, id->vendor); | 820 | ADD(alias, "v", vendor != SSB_ANY_VENDOR, vendor); |
774 | ADD(alias, "id", id->coreid != SSB_ANY_ID, id->coreid); | 821 | ADD(alias, "id", coreid != SSB_ANY_ID, coreid); |
775 | ADD(alias, "rev", id->revision != SSB_ANY_REV, id->revision); | 822 | ADD(alias, "rev", revision != SSB_ANY_REV, revision); |
776 | add_wildcard(alias); | 823 | add_wildcard(alias); |
777 | return 1; | 824 | return 1; |
778 | } | 825 | } |
779 | ADD_TO_DEVTABLE("ssb", struct ssb_device_id, do_ssb_entry); | 826 | ADD_TO_DEVTABLE("ssb", ssb_device_id, do_ssb_entry); |
780 | 827 | ||
781 | /* Looks like: bcma:mNidNrevNclN. */ | 828 | /* Looks like: bcma:mNidNrevNclN. */ |
782 | static int do_bcma_entry(const char *filename, | 829 | static int do_bcma_entry(const char *filename, |
783 | struct bcma_device_id *id, char *alias) | 830 | void *symval, char *alias) |
784 | { | 831 | { |
785 | id->manuf = TO_NATIVE(id->manuf); | 832 | DEF_FIELD(symval, bcma_device_id, manuf); |
786 | id->id = TO_NATIVE(id->id); | 833 | DEF_FIELD(symval, bcma_device_id, id); |
787 | id->rev = TO_NATIVE(id->rev); | 834 | DEF_FIELD(symval, bcma_device_id, rev); |
788 | id->class = TO_NATIVE(id->class); | 835 | DEF_FIELD(symval, bcma_device_id, class); |
789 | 836 | ||
790 | strcpy(alias, "bcma:"); | 837 | strcpy(alias, "bcma:"); |
791 | ADD(alias, "m", id->manuf != BCMA_ANY_MANUF, id->manuf); | 838 | ADD(alias, "m", manuf != BCMA_ANY_MANUF, manuf); |
792 | ADD(alias, "id", id->id != BCMA_ANY_ID, id->id); | 839 | ADD(alias, "id", id != BCMA_ANY_ID, id); |
793 | ADD(alias, "rev", id->rev != BCMA_ANY_REV, id->rev); | 840 | ADD(alias, "rev", rev != BCMA_ANY_REV, rev); |
794 | ADD(alias, "cl", id->class != BCMA_ANY_CLASS, id->class); | 841 | ADD(alias, "cl", class != BCMA_ANY_CLASS, class); |
795 | add_wildcard(alias); | 842 | add_wildcard(alias); |
796 | return 1; | 843 | return 1; |
797 | } | 844 | } |
798 | ADD_TO_DEVTABLE("bcma", struct bcma_device_id, do_bcma_entry); | 845 | ADD_TO_DEVTABLE("bcma", bcma_device_id, do_bcma_entry); |
799 | 846 | ||
800 | /* Looks like: virtio:dNvN */ | 847 | /* Looks like: virtio:dNvN */ |
801 | static int do_virtio_entry(const char *filename, struct virtio_device_id *id, | 848 | static int do_virtio_entry(const char *filename, void *symval, |
802 | char *alias) | 849 | char *alias) |
803 | { | 850 | { |
804 | id->device = TO_NATIVE(id->device); | 851 | DEF_FIELD(symval, virtio_device_id, device); |
805 | id->vendor = TO_NATIVE(id->vendor); | 852 | DEF_FIELD(symval, virtio_device_id, vendor); |
806 | 853 | ||
807 | strcpy(alias, "virtio:"); | 854 | strcpy(alias, "virtio:"); |
808 | ADD(alias, "d", id->device != VIRTIO_DEV_ANY_ID, id->device); | 855 | ADD(alias, "d", device != VIRTIO_DEV_ANY_ID, device); |
809 | ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor); | 856 | ADD(alias, "v", vendor != VIRTIO_DEV_ANY_ID, vendor); |
810 | 857 | ||
811 | add_wildcard(alias); | 858 | add_wildcard(alias); |
812 | return 1; | 859 | return 1; |
813 | } | 860 | } |
814 | ADD_TO_DEVTABLE("virtio", struct virtio_device_id, do_virtio_entry); | 861 | ADD_TO_DEVTABLE("virtio", virtio_device_id, do_virtio_entry); |
815 | 862 | ||
816 | /* | 863 | /* |
817 | * Looks like: vmbus:guid | 864 | * Looks like: vmbus:guid |
@@ -819,41 +866,44 @@ ADD_TO_DEVTABLE("virtio", struct virtio_device_id, do_virtio_entry); | |||
819 | * in the name. | 866 | * in the name. |
820 | */ | 867 | */ |
821 | 868 | ||
822 | static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id, | 869 | static int do_vmbus_entry(const char *filename, void *symval, |
823 | char *alias) | 870 | char *alias) |
824 | { | 871 | { |
825 | int i; | 872 | int i; |
826 | char guid_name[((sizeof(id->guid) + 1)) * 2]; | 873 | DEF_FIELD_ADDR(symval, hv_vmbus_device_id, guid); |
874 | char guid_name[(sizeof(*guid) + 1) * 2]; | ||
827 | 875 | ||
828 | for (i = 0; i < (sizeof(id->guid) * 2); i += 2) | 876 | for (i = 0; i < (sizeof(*guid) * 2); i += 2) |
829 | sprintf(&guid_name[i], "%02x", id->guid[i/2]); | 877 | sprintf(&guid_name[i], "%02x", TO_NATIVE((*guid)[i/2])); |
830 | 878 | ||
831 | strcpy(alias, "vmbus:"); | 879 | strcpy(alias, "vmbus:"); |
832 | strcat(alias, guid_name); | 880 | strcat(alias, guid_name); |
833 | 881 | ||
834 | return 1; | 882 | return 1; |
835 | } | 883 | } |
836 | ADD_TO_DEVTABLE("vmbus", struct hv_vmbus_device_id, do_vmbus_entry); | 884 | ADD_TO_DEVTABLE("vmbus", hv_vmbus_device_id, do_vmbus_entry); |
837 | 885 | ||
838 | /* Looks like: i2c:S */ | 886 | /* Looks like: i2c:S */ |
839 | static int do_i2c_entry(const char *filename, struct i2c_device_id *id, | 887 | static int do_i2c_entry(const char *filename, void *symval, |
840 | char *alias) | 888 | char *alias) |
841 | { | 889 | { |
842 | sprintf(alias, I2C_MODULE_PREFIX "%s", id->name); | 890 | DEF_FIELD_ADDR(symval, i2c_device_id, name); |
891 | sprintf(alias, I2C_MODULE_PREFIX "%s", *name); | ||
843 | 892 | ||
844 | return 1; | 893 | return 1; |
845 | } | 894 | } |
846 | ADD_TO_DEVTABLE("i2c", struct i2c_device_id, do_i2c_entry); | 895 | ADD_TO_DEVTABLE("i2c", i2c_device_id, do_i2c_entry); |
847 | 896 | ||
848 | /* Looks like: spi:S */ | 897 | /* Looks like: spi:S */ |
849 | static int do_spi_entry(const char *filename, struct spi_device_id *id, | 898 | static int do_spi_entry(const char *filename, void *symval, |
850 | char *alias) | 899 | char *alias) |
851 | { | 900 | { |
852 | sprintf(alias, SPI_MODULE_PREFIX "%s", id->name); | 901 | DEF_FIELD_ADDR(symval, spi_device_id, name); |
902 | sprintf(alias, SPI_MODULE_PREFIX "%s", *name); | ||
853 | 903 | ||
854 | return 1; | 904 | return 1; |
855 | } | 905 | } |
856 | ADD_TO_DEVTABLE("spi", struct spi_device_id, do_spi_entry); | 906 | ADD_TO_DEVTABLE("spi", spi_device_id, do_spi_entry); |
857 | 907 | ||
858 | static const struct dmifield { | 908 | static const struct dmifield { |
859 | const char *prefix; | 909 | const char *prefix; |
@@ -885,21 +935,21 @@ static void dmi_ascii_filter(char *d, const char *s) | |||
885 | } | 935 | } |
886 | 936 | ||
887 | 937 | ||
888 | static int do_dmi_entry(const char *filename, struct dmi_system_id *id, | 938 | static int do_dmi_entry(const char *filename, void *symval, |
889 | char *alias) | 939 | char *alias) |
890 | { | 940 | { |
891 | int i, j; | 941 | int i, j; |
892 | 942 | DEF_FIELD_ADDR(symval, dmi_system_id, matches); | |
893 | sprintf(alias, "dmi*"); | 943 | sprintf(alias, "dmi*"); |
894 | 944 | ||
895 | for (i = 0; i < ARRAY_SIZE(dmi_fields); i++) { | 945 | for (i = 0; i < ARRAY_SIZE(dmi_fields); i++) { |
896 | for (j = 0; j < 4; j++) { | 946 | for (j = 0; j < 4; j++) { |
897 | if (id->matches[j].slot && | 947 | if ((*matches)[j].slot && |
898 | id->matches[j].slot == dmi_fields[i].field) { | 948 | (*matches)[j].slot == dmi_fields[i].field) { |
899 | sprintf(alias + strlen(alias), ":%s*", | 949 | sprintf(alias + strlen(alias), ":%s*", |
900 | dmi_fields[i].prefix); | 950 | dmi_fields[i].prefix); |
901 | dmi_ascii_filter(alias + strlen(alias), | 951 | dmi_ascii_filter(alias + strlen(alias), |
902 | id->matches[j].substr); | 952 | (*matches)[j].substr); |
903 | strcat(alias, "*"); | 953 | strcat(alias, "*"); |
904 | } | 954 | } |
905 | } | 955 | } |
@@ -908,27 +958,30 @@ static int do_dmi_entry(const char *filename, struct dmi_system_id *id, | |||
908 | strcat(alias, ":"); | 958 | strcat(alias, ":"); |
909 | return 1; | 959 | return 1; |
910 | } | 960 | } |
911 | ADD_TO_DEVTABLE("dmi", struct dmi_system_id, do_dmi_entry); | 961 | ADD_TO_DEVTABLE("dmi", dmi_system_id, do_dmi_entry); |
912 | 962 | ||
913 | static int do_platform_entry(const char *filename, | 963 | static int do_platform_entry(const char *filename, |
914 | struct platform_device_id *id, char *alias) | 964 | void *symval, char *alias) |
915 | { | 965 | { |
916 | sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name); | 966 | DEF_FIELD_ADDR(symval, platform_device_id, name); |
967 | sprintf(alias, PLATFORM_MODULE_PREFIX "%s", *name); | ||
917 | return 1; | 968 | return 1; |
918 | } | 969 | } |
919 | ADD_TO_DEVTABLE("platform", struct platform_device_id, do_platform_entry); | 970 | ADD_TO_DEVTABLE("platform", platform_device_id, do_platform_entry); |
920 | 971 | ||
921 | static int do_mdio_entry(const char *filename, | 972 | static int do_mdio_entry(const char *filename, |
922 | struct mdio_device_id *id, char *alias) | 973 | void *symval, char *alias) |
923 | { | 974 | { |
924 | int i; | 975 | int i; |
976 | DEF_FIELD(symval, mdio_device_id, phy_id); | ||
977 | DEF_FIELD(symval, mdio_device_id, phy_id_mask); | ||
925 | 978 | ||
926 | alias += sprintf(alias, MDIO_MODULE_PREFIX); | 979 | alias += sprintf(alias, MDIO_MODULE_PREFIX); |
927 | 980 | ||
928 | for (i = 0; i < 32; i++) { | 981 | for (i = 0; i < 32; i++) { |
929 | if (!((id->phy_id_mask >> (31-i)) & 1)) | 982 | if (!((phy_id_mask >> (31-i)) & 1)) |
930 | *(alias++) = '?'; | 983 | *(alias++) = '?'; |
931 | else if ((id->phy_id >> (31-i)) & 1) | 984 | else if ((phy_id >> (31-i)) & 1) |
932 | *(alias++) = '1'; | 985 | *(alias++) = '1'; |
933 | else | 986 | else |
934 | *(alias++) = '0'; | 987 | *(alias++) = '0'; |
@@ -939,47 +992,50 @@ static int do_mdio_entry(const char *filename, | |||
939 | 992 | ||
940 | return 1; | 993 | return 1; |
941 | } | 994 | } |
942 | ADD_TO_DEVTABLE("mdio", struct mdio_device_id, do_mdio_entry); | 995 | ADD_TO_DEVTABLE("mdio", mdio_device_id, do_mdio_entry); |
943 | 996 | ||
944 | /* Looks like: zorro:iN. */ | 997 | /* Looks like: zorro:iN. */ |
945 | static int do_zorro_entry(const char *filename, struct zorro_device_id *id, | 998 | static int do_zorro_entry(const char *filename, void *symval, |
946 | char *alias) | 999 | char *alias) |
947 | { | 1000 | { |
948 | id->id = TO_NATIVE(id->id); | 1001 | DEF_FIELD(symval, zorro_device_id, id); |
949 | strcpy(alias, "zorro:"); | 1002 | strcpy(alias, "zorro:"); |
950 | ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id); | 1003 | ADD(alias, "i", id != ZORRO_WILDCARD, id); |
951 | return 1; | 1004 | return 1; |
952 | } | 1005 | } |
953 | ADD_TO_DEVTABLE("zorro", struct zorro_device_id, do_zorro_entry); | 1006 | ADD_TO_DEVTABLE("zorro", zorro_device_id, do_zorro_entry); |
954 | 1007 | ||
955 | /* looks like: "pnp:dD" */ | 1008 | /* looks like: "pnp:dD" */ |
956 | static int do_isapnp_entry(const char *filename, | 1009 | static int do_isapnp_entry(const char *filename, |
957 | struct isapnp_device_id *id, char *alias) | 1010 | void *symval, char *alias) |
958 | { | 1011 | { |
1012 | DEF_FIELD(symval, isapnp_device_id, vendor); | ||
1013 | DEF_FIELD(symval, isapnp_device_id, function); | ||
959 | sprintf(alias, "pnp:d%c%c%c%x%x%x%x*", | 1014 | sprintf(alias, "pnp:d%c%c%c%x%x%x%x*", |
960 | 'A' + ((id->vendor >> 2) & 0x3f) - 1, | 1015 | 'A' + ((vendor >> 2) & 0x3f) - 1, |
961 | 'A' + (((id->vendor & 3) << 3) | ((id->vendor >> 13) & 7)) - 1, | 1016 | 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, |
962 | 'A' + ((id->vendor >> 8) & 0x1f) - 1, | 1017 | 'A' + ((vendor >> 8) & 0x1f) - 1, |
963 | (id->function >> 4) & 0x0f, id->function & 0x0f, | 1018 | (function >> 4) & 0x0f, function & 0x0f, |
964 | (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f); | 1019 | (function >> 12) & 0x0f, (function >> 8) & 0x0f); |
965 | return 1; | 1020 | return 1; |
966 | } | 1021 | } |
967 | ADD_TO_DEVTABLE("isapnp", struct isapnp_device_id, do_isapnp_entry); | 1022 | ADD_TO_DEVTABLE("isapnp", isapnp_device_id, do_isapnp_entry); |
968 | 1023 | ||
969 | /* Looks like: "ipack:fNvNdN". */ | 1024 | /* Looks like: "ipack:fNvNdN". */ |
970 | static int do_ipack_entry(const char *filename, | 1025 | static int do_ipack_entry(const char *filename, |
971 | struct ipack_device_id *id, char *alias) | 1026 | void *symval, char *alias) |
972 | { | 1027 | { |
973 | id->vendor = TO_NATIVE(id->vendor); | 1028 | DEF_FIELD(symval, ipack_device_id, format); |
974 | id->device = TO_NATIVE(id->device); | 1029 | DEF_FIELD(symval, ipack_device_id, vendor); |
1030 | DEF_FIELD(symval, ipack_device_id, device); | ||
975 | strcpy(alias, "ipack:"); | 1031 | strcpy(alias, "ipack:"); |
976 | ADD(alias, "f", id->format != IPACK_ANY_FORMAT, id->format); | 1032 | ADD(alias, "f", format != IPACK_ANY_FORMAT, format); |
977 | ADD(alias, "v", id->vendor != IPACK_ANY_ID, id->vendor); | 1033 | ADD(alias, "v", vendor != IPACK_ANY_ID, vendor); |
978 | ADD(alias, "d", id->device != IPACK_ANY_ID, id->device); | 1034 | ADD(alias, "d", device != IPACK_ANY_ID, device); |
979 | add_wildcard(alias); | 1035 | add_wildcard(alias); |
980 | return 1; | 1036 | return 1; |
981 | } | 1037 | } |
982 | ADD_TO_DEVTABLE("ipack", struct ipack_device_id, do_ipack_entry); | 1038 | ADD_TO_DEVTABLE("ipack", ipack_device_id, do_ipack_entry); |
983 | 1039 | ||
984 | /* | 1040 | /* |
985 | * Append a match expression for a single masked hex digit. | 1041 | * Append a match expression for a single masked hex digit. |
@@ -1030,25 +1086,27 @@ static void append_nibble_mask(char **outp, | |||
1030 | * a ? or [] pattern matching exactly one digit. | 1086 | * a ? or [] pattern matching exactly one digit. |
1031 | */ | 1087 | */ |
1032 | static int do_amba_entry(const char *filename, | 1088 | static int do_amba_entry(const char *filename, |
1033 | struct amba_id *id, char *alias) | 1089 | void *symval, char *alias) |
1034 | { | 1090 | { |
1035 | unsigned int digit; | 1091 | unsigned int digit; |
1036 | char *p = alias; | 1092 | char *p = alias; |
1093 | DEF_FIELD(symval, amba_id, id); | ||
1094 | DEF_FIELD(symval, amba_id, mask); | ||
1037 | 1095 | ||
1038 | if ((id->id & id->mask) != id->id) | 1096 | if ((id & mask) != id) |
1039 | fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: " | 1097 | fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: " |
1040 | "id=0x%08X, mask=0x%08X. Please fix this driver.\n", | 1098 | "id=0x%08X, mask=0x%08X. Please fix this driver.\n", |
1041 | filename, id->id, id->mask); | 1099 | filename, id, mask); |
1042 | 1100 | ||
1043 | p += sprintf(alias, "amba:d"); | 1101 | p += sprintf(alias, "amba:d"); |
1044 | for (digit = 0; digit < 8; digit++) | 1102 | for (digit = 0; digit < 8; digit++) |
1045 | append_nibble_mask(&p, | 1103 | append_nibble_mask(&p, |
1046 | (id->id >> (4 * (7 - digit))) & 0xf, | 1104 | (id >> (4 * (7 - digit))) & 0xf, |
1047 | (id->mask >> (4 * (7 - digit))) & 0xf); | 1105 | (mask >> (4 * (7 - digit))) & 0xf); |
1048 | 1106 | ||
1049 | return 1; | 1107 | return 1; |
1050 | } | 1108 | } |
1051 | ADD_TO_DEVTABLE("amba", struct amba_id, do_amba_entry); | 1109 | ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry); |
1052 | 1110 | ||
1053 | /* LOOKS like x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:*,FEAT,* | 1111 | /* LOOKS like x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:*,FEAT,* |
1054 | * All fields are numbers. It would be nicer to use strings for vendor | 1112 | * All fields are numbers. It would be nicer to use strings for vendor |
@@ -1056,24 +1114,24 @@ ADD_TO_DEVTABLE("amba", struct amba_id, do_amba_entry); | |||
1056 | * complicated. | 1114 | * complicated. |
1057 | */ | 1115 | */ |
1058 | 1116 | ||
1059 | static int do_x86cpu_entry(const char *filename, struct x86_cpu_id *id, | 1117 | static int do_x86cpu_entry(const char *filename, void *symval, |
1060 | char *alias) | 1118 | char *alias) |
1061 | { | 1119 | { |
1062 | id->feature = TO_NATIVE(id->feature); | 1120 | DEF_FIELD(symval, x86_cpu_id, feature); |
1063 | id->family = TO_NATIVE(id->family); | 1121 | DEF_FIELD(symval, x86_cpu_id, family); |
1064 | id->model = TO_NATIVE(id->model); | 1122 | DEF_FIELD(symval, x86_cpu_id, model); |
1065 | id->vendor = TO_NATIVE(id->vendor); | 1123 | DEF_FIELD(symval, x86_cpu_id, vendor); |
1066 | 1124 | ||
1067 | strcpy(alias, "x86cpu:"); | 1125 | strcpy(alias, "x86cpu:"); |
1068 | ADD(alias, "vendor:", id->vendor != X86_VENDOR_ANY, id->vendor); | 1126 | ADD(alias, "vendor:", vendor != X86_VENDOR_ANY, vendor); |
1069 | ADD(alias, ":family:", id->family != X86_FAMILY_ANY, id->family); | 1127 | ADD(alias, ":family:", family != X86_FAMILY_ANY, family); |
1070 | ADD(alias, ":model:", id->model != X86_MODEL_ANY, id->model); | 1128 | ADD(alias, ":model:", model != X86_MODEL_ANY, model); |
1071 | strcat(alias, ":feature:*"); | 1129 | strcat(alias, ":feature:*"); |
1072 | if (id->feature != X86_FEATURE_ANY) | 1130 | if (feature != X86_FEATURE_ANY) |
1073 | sprintf(alias + strlen(alias), "%04X*", id->feature); | 1131 | sprintf(alias + strlen(alias), "%04X*", feature); |
1074 | return 1; | 1132 | return 1; |
1075 | } | 1133 | } |
1076 | ADD_TO_DEVTABLE("x86cpu", struct x86_cpu_id, do_x86cpu_entry); | 1134 | ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); |
1077 | 1135 | ||
1078 | /* Does namelen bytes of name exactly match the symbol? */ | 1136 | /* Does namelen bytes of name exactly match the symbol? */ |
1079 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) | 1137 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) |