| @@ -11,6 +11,7 @@ · 10 unmodified lines |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | #include "modpost.h" |
| 14 | +#include "devicetable-offsets.h" |
| 14 | 15 | |
| 15 | 16 | /* We use the ELF typedefs for kernel_ulong_t but bite the bullet and |
| 16 | 17 | * use either stdint.h or inttypes.h for the rest. */ |
| @@ -84,13 +85,25 @@ extern struct devtable *__start___devtable[], *__stop___devtable[]; · 67 unmodified lines |
| 84 | 85 | # define __used __attribute__((__used__)) |
| 85 | 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 | 100 | /* Add a table entry. We test function type matches while we're here. */ |
| 88 | 101 | #define ADD_TO_DEVTABLE(device_id, type, function) \ |
| 89 | 102 | static struct devtable __cat(devtable,__LINE__) = { \ |
| 90 | 103 | device_id + 0*sizeof((function)((const char *)NULL, \ |
| 91 | | − (type *)NULL, \ |
| 104 | + (void *)NULL, \ |
| 92 | 105 | (char *)NULL)), \ |
| 93 | | − sizeof(type), (function) }; \ |
| 106 | + SIZE_##type, (function) }; \ |
| 94 | 107 | static struct devtable *SECTION(__devtable) __used \ |
| 95 | 108 | __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) |
| 96 | 109 | |
| @@ -116,7 +129,6 @@ static inline void add_wildcard(char *str) · 19 unmodified lines |
| 116 | 129 | strcat(str + len, "*"); |
| 117 | 130 | } |
| 118 | 131 | |
| 119 | | −unsigned int cross_build = 0; |
| 120 | 132 | /** |
| 121 | 133 | * Check that sizeof(device_id type) are consistent with size of section |
| 122 | 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, · 8 unmodified lines |
| 131 | 143 | int i; |
| 132 | 144 | |
| 133 | 145 | if (size % id_size || size < id_size) { |
| 134 | | − if (cross_build != 0) |
| 135 | | − return; |
| 136 | 146 | fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " |
| 137 | 147 | "of the size of section __mod_%s_device_table=%lu.\n" |
| 138 | 148 | "Fix definition of struct %s_device_id " |
| @@ -157,17 +167,29 @@ static void device_id_check(const char *modname, const char *device_id, · 18 unmodified lines |
| 157 | 167 | |
| 158 | 168 | /* USB is special because the bcdDevice can be matched against a numeric range */ |
| 159 | 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 | 171 | unsigned int bcdDevice_initial, int bcdDevice_initial_digits, |
| 162 | 172 | unsigned char range_lo, unsigned char range_hi, |
| 163 | 173 | unsigned char max, struct module *mod) |
| 164 | 174 | { |
| 165 | 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 | 188 | strcpy(alias, "usb:"); |
| 167 | | − ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR, |
| 168 | | − id->idVendor); |
| 169 | | − ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT, |
| 170 | | − id->idProduct); |
| 189 | + ADD(alias, "v", match_flags&USB_DEVICE_ID_MATCH_VENDOR, |
| 190 | + idVendor); |
| 191 | + ADD(alias, "p", match_flags&USB_DEVICE_ID_MATCH_PRODUCT, |
| 192 | + idProduct); |
| 171 | 193 | |
| 172 | 194 | strcat(alias, "d"); |
| 173 | 195 | if (bcdDevice_initial_digits) |
| @@ -190,29 +212,23 @@ static void do_usb_entry(struct usb_device_id *id, · 16 unmodified lines |
| 190 | 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 | 216 | strcat(alias, "*"); |
| 195 | 217 | |
| 196 | | − ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS, |
| 197 | | − id->bDeviceClass); |
| 198 | | − ADD(alias, "dsc", |
| 199 | | − id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS, |
| 200 | | − id->bDeviceSubClass); |
| 201 | | − ADD(alias, "dp", |
| 202 | | − id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL, |
| 203 | | − id->bDeviceProtocol); |
| 204 | | − ADD(alias, "ic", |
| 205 | | − id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS, |
| 206 | | − id->bInterfaceClass); |
| 207 | | − ADD(alias, "isc", |
| 208 | | − id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS, |
| 209 | | − id->bInterfaceSubClass); |
| 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); |
| 218 | + ADD(alias, "dc", match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS, |
| 219 | + bDeviceClass); |
| 220 | + ADD(alias, "dsc", match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS, |
| 221 | + bDeviceSubClass); |
| 222 | + ADD(alias, "dp", match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL, |
| 223 | + bDeviceProtocol); |
| 224 | + ADD(alias, "ic", match_flags&USB_DEVICE_ID_MATCH_INT_CLASS, |
| 225 | + bInterfaceClass); |
| 226 | + ADD(alias, "isc", match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS, |
| 227 | + bInterfaceSubClass); |
| 228 | + ADD(alias, "ip", match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, |
| 229 | + bInterfaceProtocol); |
| 230 | + ADD(alias, "in", match_flags&USB_DEVICE_ID_MATCH_INT_NUMBER, |
| 231 | + bInterfaceNumber); |
| 216 | 232 | |
| 217 | 233 | add_wildcard(alias); |
| 218 | 234 | buf_printf(&mod->dev_table_buf, |
| @@ -258,24 +274,28 @@ static unsigned int incbcd(unsigned int *bcd, · 39 unmodified lines |
| 258 | 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 | 279 | unsigned int devlo, devhi; |
| 264 | 280 | unsigned char chi, clo, max; |
| 265 | 281 | int ndigits; |
| 266 | 282 | |
| 267 | | − id->match_flags = TO_NATIVE(id->match_flags); |
| 268 | | − id->idVendor = TO_NATIVE(id->idVendor); |
| 269 | | − id->idProduct = TO_NATIVE(id->idProduct); |
| 283 | + DEF_FIELD(symval, usb_device_id, match_flags); |
| 284 | + DEF_FIELD(symval, usb_device_id, idVendor); |
| 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 ? |
| 272 | | − TO_NATIVE(id->bcdDevice_lo) : 0x0U; |
| 273 | | − devhi = id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI ? |
| 274 | | − TO_NATIVE(id->bcdDevice_hi) : ~0x0U; |
| 291 | + devlo = match_flags & USB_DEVICE_ID_MATCH_DEV_LO ? |
| 292 | + bcdDevice_lo : 0x0U; |
| 293 | + devhi = match_flags & USB_DEVICE_ID_MATCH_DEV_HI ? |
| 294 | + bcdDevice_hi : ~0x0U; |
| 275 | 295 | |
| 276 | 296 | /* Figure out if this entry is in bcd or hex format */ |
| 277 | 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 | 299 | clo = (devlo >> (ndigits << 2)) & 0xf; |
| 280 | 300 | chi = ((devhi > 0x9999 ? 0x9999 : devhi) >> (ndigits << 2)) & 0xf; |
| 281 | 301 | if (clo > max || chi > max) { |
| @@ -288,11 +308,11 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod) · 6 unmodified lines |
| 288 | 308 | * Some modules (visor) have empty slots as placeholder for |
| 289 | 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 | 312 | return; |
| 293 | 313 | |
| 294 | 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 | 316 | clo = devlo & 0xf; |
| 297 | 317 | chi = devhi & 0xf; |
| 298 | 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) · 2 unmodified lines |
| 301 | 321 | devhi >>= 4; |
| 302 | 322 | |
| 303 | 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 | 325 | break; |
| 306 | 326 | } |
| 307 | 327 | |
| 308 | 328 | if (clo > 0x0) |
| 309 | | − do_usb_entry(id, |
| 329 | + do_usb_entry(symval, |
| 310 | 330 | incbcd(&devlo, 1, max, |
| 311 | | − sizeof(id->bcdDevice_lo) * 2), |
| 331 | + sizeof(bcdDevice_lo) * 2), |
| 312 | 332 | ndigits, clo, max, max, mod); |
| 313 | 333 | |
| 314 | 334 | if (chi < max) |
| 315 | | − do_usb_entry(id, |
| 335 | + do_usb_entry(symval, |
| 316 | 336 | incbcd(&devhi, -1, max, |
| 317 | | − sizeof(id->bcdDevice_lo) * 2), |
| 337 | + sizeof(bcdDevice_lo) * 2), |
| 318 | 338 | ndigits, 0x0, chi, max, mod); |
| 319 | 339 | } |
| 320 | 340 | } |
| @@ -323,7 +343,7 @@ static void do_usb_table(void *symval, unsigned long size, · 2 unmodified lines |
| 323 | 343 | struct module *mod) |
| 324 | 344 | { |
| 325 | 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 | 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, · 6 unmodified lines |
| 336 | 356 | |
| 337 | 357 | /* Looks like: hid:bNvNpN */ |
| 338 | 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); |
| 342 | | − id->group = TO_NATIVE(id->group); |
| 343 | | − id->vendor = TO_NATIVE(id->vendor); |
| 344 | | − id->product = TO_NATIVE(id->product); |
| 361 | + DEF_FIELD(symval, hid_device_id, bus); |
| 362 | + DEF_FIELD(symval, hid_device_id, group); |
| 363 | + DEF_FIELD(symval, hid_device_id, vendor); |
| 364 | + DEF_FIELD(symval, hid_device_id, product); |
| 345 | 365 | |
| 346 | 366 | sprintf(alias, "hid:"); |
| 347 | | − ADD(alias, "b", id->bus != HID_BUS_ANY, id->bus); |
| 348 | | − ADD(alias, "g", id->group != HID_GROUP_ANY, id->group); |
| 349 | | − ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor); |
| 350 | | − ADD(alias, "p", id->product != HID_ANY_ID, id->product); |
| 367 | + ADD(alias, "b", bus != HID_BUS_ANY, bus); |
| 368 | + ADD(alias, "g", group != HID_GROUP_ANY, group); |
| 369 | + ADD(alias, "v", vendor != HID_ANY_ID, vendor); |
| 370 | + ADD(alias, "p", product != HID_ANY_ID, product); |
| 351 | 371 | |
| 352 | 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 | 376 | /* Looks like: ieee1394:venNmoNspNverN */ |
| 357 | 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); |
| 361 | | − id->vendor_id = TO_NATIVE(id->vendor_id); |
| 362 | | − id->model_id = TO_NATIVE(id->model_id); |
| 363 | | − id->specifier_id = TO_NATIVE(id->specifier_id); |
| 364 | | − id->version = TO_NATIVE(id->version); |
| 380 | + DEF_FIELD(symval, ieee1394_device_id, match_flags); |
| 381 | + DEF_FIELD(symval, ieee1394_device_id, vendor_id); |
| 382 | + DEF_FIELD(symval, ieee1394_device_id, model_id); |
| 383 | + DEF_FIELD(symval, ieee1394_device_id, specifier_id); |
| 384 | + DEF_FIELD(symval, ieee1394_device_id, version); |
| 365 | 385 | |
| 366 | 386 | strcpy(alias, "ieee1394:"); |
| 367 | | − ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID, |
| 368 | | − id->vendor_id); |
| 369 | | − ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID, |
| 370 | | − id->model_id); |
| 371 | | − ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID, |
| 372 | | − id->specifier_id); |
| 373 | | − ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION, |
| 374 | | − id->version); |
| 387 | + ADD(alias, "ven", match_flags & IEEE1394_MATCH_VENDOR_ID, |
| 388 | + vendor_id); |
| 389 | + ADD(alias, "mo", match_flags & IEEE1394_MATCH_MODEL_ID, |
| 390 | + model_id); |
| 391 | + ADD(alias, "sp", match_flags & IEEE1394_MATCH_SPECIFIER_ID, |
| 392 | + specifier_id); |
| 393 | + ADD(alias, "ver", match_flags & IEEE1394_MATCH_VERSION, |
| 394 | + version); |
| 375 | 395 | |
| 376 | 396 | add_wildcard(alias); |
| 377 | 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 | 401 | /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ |
| 382 | 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 | 405 | /* Class field can be divided into these three. */ |
| 386 | 406 | unsigned char baseclass, subclass, interface, |
| 387 | 407 | baseclass_mask, subclass_mask, interface_mask; |
| 388 | 408 | |
| 389 | | − id->vendor = TO_NATIVE(id->vendor); |
| 390 | | − id->device = TO_NATIVE(id->device); |
| 391 | | − id->subvendor = TO_NATIVE(id->subvendor); |
| 392 | | − id->subdevice = TO_NATIVE(id->subdevice); |
| 393 | | − id->class = TO_NATIVE(id->class); |
| 394 | | − id->class_mask = TO_NATIVE(id->class_mask); |
| 409 | + DEF_FIELD(symval, pci_device_id, vendor); |
| 410 | + DEF_FIELD(symval, pci_device_id, device); |
| 411 | + DEF_FIELD(symval, pci_device_id, subvendor); |
| 412 | + DEF_FIELD(symval, pci_device_id, subdevice); |
| 413 | + DEF_FIELD(symval, pci_device_id, class); |
| 414 | + DEF_FIELD(symval, pci_device_id, class_mask); |
| 395 | 415 | |
| 396 | 416 | strcpy(alias, "pci:"); |
| 397 | | − ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor); |
| 398 | | − ADD(alias, "d", id->device != PCI_ANY_ID, id->device); |
| 399 | | − ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor); |
| 400 | | − ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice); |
| 401 | | − |
| 402 | | − baseclass = (id->class) >> 16; |
| 403 | | − baseclass_mask = (id->class_mask) >> 16; |
| 404 | | − subclass = (id->class) >> 8; |
| 405 | | − subclass_mask = (id->class_mask) >> 8; |
| 406 | | − interface = id->class; |
| 407 | | − interface_mask = id->class_mask; |
| 417 | + ADD(alias, "v", vendor != PCI_ANY_ID, vendor); |
| 418 | + ADD(alias, "d", device != PCI_ANY_ID, device); |
| 419 | + ADD(alias, "sv", subvendor != PCI_ANY_ID, subvendor); |
| 420 | + ADD(alias, "sd", subdevice != PCI_ANY_ID, subdevice); |
| 421 | + |
| 422 | + baseclass = (class) >> 16; |
| 423 | + baseclass_mask = (class_mask) >> 16; |
| 424 | + subclass = (class) >> 8; |
| 425 | + subclass_mask = (class_mask) >> 8; |
| 426 | + interface = class; |
| 427 | + interface_mask = class_mask; |
| 408 | 428 | |
| 409 | 429 | if ((baseclass_mask != 0 && baseclass_mask != 0xFF) |
| 410 | 430 | || (subclass_mask != 0 && subclass_mask != 0xFF) |
| 411 | 431 | || (interface_mask != 0 && interface_mask != 0xFF)) { |
| 412 | 432 | warn("Can't handle masks in %s:%04X\n", |
| 413 | | − filename, id->class_mask); |
| 433 | + filename, class_mask); |
| 414 | 434 | return 0; |
| 415 | 435 | } |
| 416 | 436 | |
| @@ -420,101 +440,105 @@ static int do_pci_entry(const char *filename, · 3 unmodified lines |
| 420 | 440 | add_wildcard(alias); |
| 421 | 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 | 445 | /* looks like: "ccw:tNmNdtNdmN" */ |
| 426 | 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); |
| 430 | | − id->cu_type = TO_NATIVE(id->cu_type); |
| 431 | | − id->cu_model = TO_NATIVE(id->cu_model); |
| 432 | | − id->dev_type = TO_NATIVE(id->dev_type); |
| 433 | | − id->dev_model = TO_NATIVE(id->dev_model); |
| 449 | + DEF_FIELD(symval, ccw_device_id, match_flags); |
| 450 | + DEF_FIELD(symval, ccw_device_id, cu_type); |
| 451 | + DEF_FIELD(symval, ccw_device_id, cu_model); |
| 452 | + DEF_FIELD(symval, ccw_device_id, dev_type); |
| 453 | + DEF_FIELD(symval, ccw_device_id, dev_model); |
| 434 | 454 | |
| 435 | 455 | strcpy(alias, "ccw:"); |
| 436 | | − ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE, |
| 437 | | − id->cu_type); |
| 438 | | − ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL, |
| 439 | | − id->cu_model); |
| 440 | | − ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE, |
| 441 | | − id->dev_type); |
| 442 | | − ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, |
| 443 | | − id->dev_model); |
| 456 | + ADD(alias, "t", match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE, |
| 457 | + cu_type); |
| 458 | + ADD(alias, "m", match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL, |
| 459 | + cu_model); |
| 460 | + ADD(alias, "dt", match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE, |
| 461 | + dev_type); |
| 462 | + ADD(alias, "dm", match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL, |
| 463 | + dev_model); |
| 444 | 464 | add_wildcard(alias); |
| 445 | 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 | 469 | /* looks like: "ap:tN" */ |
| 450 | 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 | 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 | 480 | /* looks like: "css:tN" */ |
| 459 | 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 | 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 | 491 | /* Looks like: "serio:tyNprNidNexN" */ |
| 468 | 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); |
| 472 | | − id->proto = TO_NATIVE(id->proto); |
| 473 | | − id->id = TO_NATIVE(id->id); |
| 474 | | − id->extra = TO_NATIVE(id->extra); |
| 495 | + DEF_FIELD(symval, serio_device_id, type); |
| 496 | + DEF_FIELD(symval, serio_device_id, proto); |
| 497 | + DEF_FIELD(symval, serio_device_id, id); |
| 498 | + DEF_FIELD(symval, serio_device_id, extra); |
| 475 | 499 | |
| 476 | 500 | strcpy(alias, "serio:"); |
| 477 | | − ADD(alias, "ty", id->type != SERIO_ANY, id->type); |
| 478 | | − ADD(alias, "pr", id->proto != SERIO_ANY, id->proto); |
| 479 | | − ADD(alias, "id", id->id != SERIO_ANY, id->id); |
| 480 | | − ADD(alias, "ex", id->extra != SERIO_ANY, id->extra); |
| 501 | + ADD(alias, "ty", type != SERIO_ANY, type); |
| 502 | + ADD(alias, "pr", proto != SERIO_ANY, proto); |
| 503 | + ADD(alias, "id", id != SERIO_ANY, id); |
| 504 | + ADD(alias, "ex", extra != SERIO_ANY, extra); |
| 481 | 505 | |
| 482 | 506 | add_wildcard(alias); |
| 483 | 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 | 511 | /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ |
| 488 | 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 | 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 | 521 | /* looks like: "pnp:dD" */ |
| 497 | 522 | static void do_pnp_device_entry(void *symval, unsigned long size, |
| 498 | 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 | 526 | const unsigned int count = (size / id_size)-1; |
| 502 | | − const struct pnp_device_id *devs = symval; |
| 503 | 527 | unsigned int i; |
| 504 | 528 | |
| 505 | 529 | device_id_check(mod->name, "pnp", size, id_size, symval); |
| 506 | 530 | |
| 507 | 531 | for (i = 0; i < count; i++) { |
| 508 | | − const char *id = (char *)devs[i].id; |
| 509 | | − char acpi_id[sizeof(devs[0].id)]; |
| 532 | + DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id); |
| 533 | + char acpi_id[sizeof(*id)]; |
| 510 | 534 | int j; |
| 511 | 535 | |
| 512 | 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 | 539 | /* fix broken pnp bus lowercasing */ |
| 516 | 540 | for (j = 0; j < sizeof(acpi_id); j++) |
| 517 | | − acpi_id[j] = toupper(id[j]); |
| 541 | + acpi_id[j] = toupper((*id)[j]); |
| 518 | 542 | buf_printf(&mod->dev_table_buf, |
| 519 | 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, · 3 unmodified lines |
| 524 | 548 | static void do_pnp_card_entries(void *symval, unsigned long size, |
| 525 | 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 | 552 | const unsigned int count = (size / id_size)-1; |
| 529 | | − const struct pnp_card_device_id *cards = symval; |
| 530 | 553 | unsigned int i; |
| 531 | 554 | |
| 532 | 555 | device_id_check(mod->name, "pnp", size, id_size, symval); |
| 533 | 556 | |
| 534 | 557 | for (i = 0; i < count; i++) { |
| 535 | 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 | 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 | 563 | int i2, j2; |
| 541 | 564 | int dup = 0; |
| 542 | 565 | |
| @@ -545,10 +568,10 @@ static void do_pnp_card_entries(void *symval, unsigned long size, · 2 unmodified lines |
| 545 | 568 | |
| 546 | 569 | /* find duplicate, already added value */ |
| 547 | 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 | 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 | 576 | if (!id2[0]) |
| 554 | 577 | break; |
| @@ -562,7 +585,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size, · 7 unmodified lines |
| 562 | 585 | |
| 563 | 586 | /* add an individual alias for every device entry */ |
| 564 | 587 | if (!dup) { |
| 565 | | − char acpi_id[sizeof(card->devs[0].id)]; |
| 588 | + char acpi_id[PNP_ID_LEN]; |
| 566 | 589 | int k; |
| 567 | 590 | |
| 568 | 591 | buf_printf(&mod->dev_table_buf, |
| @@ -580,54 +603,58 @@ static void do_pnp_card_entries(void *symval, unsigned long size, · 11 unmodified lines |
| 580 | 603 | |
| 581 | 604 | /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */ |
| 582 | 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 | 608 | unsigned int i; |
| 586 | | − |
| 587 | | − id->match_flags = TO_NATIVE(id->match_flags); |
| 588 | | − id->manf_id = TO_NATIVE(id->manf_id); |
| 589 | | − id->card_id = TO_NATIVE(id->card_id); |
| 590 | | − id->func_id = TO_NATIVE(id->func_id); |
| 591 | | − id->function = TO_NATIVE(id->function); |
| 592 | | − id->device_no = TO_NATIVE(id->device_no); |
| 609 | + DEF_FIELD(symval, pcmcia_device_id, match_flags); |
| 610 | + DEF_FIELD(symval, pcmcia_device_id, manf_id); |
| 611 | + DEF_FIELD(symval, pcmcia_device_id, card_id); |
| 612 | + DEF_FIELD(symval, pcmcia_device_id, func_id); |
| 613 | + DEF_FIELD(symval, pcmcia_device_id, function); |
| 614 | + DEF_FIELD(symval, pcmcia_device_id, device_no); |
| 615 | + DEF_FIELD_ADDR(symval, pcmcia_device_id, prod_id_hash); |
| 593 | 616 | |
| 594 | 617 | for (i=0; i<4; i++) { |
| 595 | | − id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]); |
| 596 | | − } |
| 597 | | − |
| 598 | | − strcpy(alias, "pcmcia:"); |
| 599 | | − ADD(alias, "m", id->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID, |
| 600 | | − id->manf_id); |
| 601 | | − ADD(alias, "c", id->match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID, |
| 602 | | − id->card_id); |
| 603 | | − ADD(alias, "f", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID, |
| 604 | | − id->func_id); |
| 605 | | − ADD(alias, "fn", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION, |
| 606 | | − id->function); |
| 607 | | − ADD(alias, "pfn", id->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO, |
| 608 | | − id->device_no); |
| 609 | | − ADD(alias, "pa", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, id->prod_id_hash[0]); |
| 610 | | − ADD(alias, "pb", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, id->prod_id_hash[1]); |
| 611 | | − ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]); |
| 612 | | − ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]); |
| 618 | + (*prod_id_hash)[i] = TO_NATIVE((*prod_id_hash)[i]); |
| 619 | + } |
| 620 | + |
| 621 | + strcpy(alias, "pcmcia:"); |
| 622 | + ADD(alias, "m", match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID, |
| 623 | + manf_id); |
| 624 | + ADD(alias, "c", match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID, |
| 625 | + card_id); |
| 626 | + ADD(alias, "f", match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID, |
| 627 | + func_id); |
| 628 | + ADD(alias, "fn", match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION, |
| 629 | + function); |
| 630 | + ADD(alias, "pfn", match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO, |
| 631 | + device_no); |
| 632 | + ADD(alias, "pa", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, (*prod_id_hash)[0]); |
| 633 | + ADD(alias, "pb", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, (*prod_id_hash)[1]); |
| 634 | + ADD(alias, "pc", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, (*prod_id_hash)[2]); |
| 635 | + ADD(alias, "pd", match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, (*prod_id_hash)[3]); |
| 613 | 636 | |
| 614 | 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 | 644 | int len; |
| 622 | 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 | 650 | len = sprintf (alias, "of:N%sT%s", |
| 624 | | − of->name[0] ? of->name : "*", |
| 625 | | − of->type[0] ? of->type : "*"); |
| 651 | + (*name)[0] ? *name : "*", |
| 652 | + (*type)[0] ? *type : "*"); |
| 626 | 653 | |
| 627 | | − if (of->compatible[0]) |
| 654 | + if (compatible[0]) |
| 628 | 655 | sprintf (&alias[len], "%sC%s", |
| 629 | | − of->type[0] ? "*" : "", |
| 630 | | − of->compatible); |
| 656 | + (*type)[0] ? "*" : "", |
| 657 | + *compatible); |
| 631 | 658 | |
| 632 | 659 | /* Replace all whitespace with underscores */ |
| 633 | 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 · 3 unmodified lines |
| 637 | 664 | add_wildcard(alias); |
| 638 | 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 | 670 | char *alias) |
| 644 | 671 | { |
| 645 | 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 : "*", |
| 648 | | − vio->compat[0] ? vio->compat : "*"); |
| 676 | + sprintf(alias, "vio:T%sS%s", (*type)[0] ? *type : "*", |
| 677 | + (*compat)[0] ? *compat : "*"); |
| 649 | 678 | |
| 650 | 679 | /* Replace all whitespace with underscores */ |
| 651 | 680 | for (tmp = alias; tmp && *tmp; tmp++) |
| @@ -655,7 +684,7 @@ static int do_vio_entry(const char *filename, struct vio_device_id *vio, · 3 unmodified lines |
| 655 | 684 | add_wildcard(alias); |
| 656 | 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 | 689 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
| 661 | 690 | |
| @@ -664,154 +693,172 @@ static void do_input(char *alias, · 2 unmodified lines |
| 664 | 693 | { |
| 665 | 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 | 698 | for (i = min; i < max; i++) |
| 668 | 699 | if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG))) |
| 669 | 700 | sprintf(alias + strlen(alias), "%X,*", i); |
| 670 | 701 | } |
| 671 | 702 | |
| 672 | 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 | 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 | 722 | sprintf(alias, "input:"); |
| 677 | 723 | |
| 678 | | − ADD(alias, "b", id->flags & INPUT_DEVICE_ID_MATCH_BUS, id->bustype); |
| 679 | | − ADD(alias, "v", id->flags & INPUT_DEVICE_ID_MATCH_VENDOR, id->vendor); |
| 680 | | − ADD(alias, "p", id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT, id->product); |
| 681 | | − ADD(alias, "e", id->flags & INPUT_DEVICE_ID_MATCH_VERSION, id->version); |
| 724 | + ADD(alias, "b", flags & INPUT_DEVICE_ID_MATCH_BUS, bustype); |
| 725 | + ADD(alias, "v", flags & INPUT_DEVICE_ID_MATCH_VENDOR, vendor); |
| 726 | + ADD(alias, "p", flags & INPUT_DEVICE_ID_MATCH_PRODUCT, product); |
| 727 | + ADD(alias, "e", flags & INPUT_DEVICE_ID_MATCH_VERSION, version); |
| 682 | 728 | |
| 683 | 729 | sprintf(alias + strlen(alias), "-e*"); |
| 684 | | − if (id->flags & INPUT_DEVICE_ID_MATCH_EVBIT) |
| 685 | | − do_input(alias, id->evbit, 0, INPUT_DEVICE_ID_EV_MAX); |
| 730 | + if (flags & INPUT_DEVICE_ID_MATCH_EVBIT) |
| 731 | + do_input(alias, *evbit, 0, INPUT_DEVICE_ID_EV_MAX); |
| 686 | 732 | sprintf(alias + strlen(alias), "k*"); |
| 687 | | − if (id->flags & INPUT_DEVICE_ID_MATCH_KEYBIT) |
| 688 | | − do_input(alias, id->keybit, |
| 733 | + if (flags & INPUT_DEVICE_ID_MATCH_KEYBIT) |
| 734 | + do_input(alias, *keybit, |
| 689 | 735 | INPUT_DEVICE_ID_KEY_MIN_INTERESTING, |
| 690 | 736 | INPUT_DEVICE_ID_KEY_MAX); |
| 691 | 737 | sprintf(alias + strlen(alias), "r*"); |
| 692 | | − if (id->flags & INPUT_DEVICE_ID_MATCH_RELBIT) |
| 693 | | − do_input(alias, id->relbit, 0, INPUT_DEVICE_ID_REL_MAX); |
| 738 | + if (flags & INPUT_DEVICE_ID_MATCH_RELBIT) |
| 739 | + do_input(alias, *relbit, 0, INPUT_DEVICE_ID_REL_MAX); |
| 694 | 740 | sprintf(alias + strlen(alias), "a*"); |
| 695 | | − if (id->flags & INPUT_DEVICE_ID_MATCH_ABSBIT) |
| 696 | | − do_input(alias, id->absbit, 0, INPUT_DEVICE_ID_ABS_MAX); |
| 741 | + if (flags & INPUT_DEVICE_ID_MATCH_ABSBIT) |
| 742 | + do_input(alias, *absbit, 0, INPUT_DEVICE_ID_ABS_MAX); |
| 697 | 743 | sprintf(alias + strlen(alias), "m*"); |
| 698 | | − if (id->flags & INPUT_DEVICE_ID_MATCH_MSCIT) |
| 699 | | − do_input(alias, id->mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); |
| 744 | + if (flags & INPUT_DEVICE_ID_MATCH_MSCIT) |
| 745 | + do_input(alias, *mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); |
| 700 | 746 | sprintf(alias + strlen(alias), "l*"); |
| 701 | | − if (id->flags & INPUT_DEVICE_ID_MATCH_LEDBIT) |
| 702 | | − do_input(alias, id->ledbit, 0, INPUT_DEVICE_ID_LED_MAX); |
| 747 | + if (flags & INPUT_DEVICE_ID_MATCH_LEDBIT) |
| 748 | + do_input(alias, *ledbit, 0, INPUT_DEVICE_ID_LED_MAX); |
| 703 | 749 | sprintf(alias + strlen(alias), "s*"); |
| 704 | | − if (id->flags & INPUT_DEVICE_ID_MATCH_SNDBIT) |
| 705 | | − do_input(alias, id->sndbit, 0, INPUT_DEVICE_ID_SND_MAX); |
| 750 | + if (flags & INPUT_DEVICE_ID_MATCH_SNDBIT) |
| 751 | + do_input(alias, *sndbit, 0, INPUT_DEVICE_ID_SND_MAX); |
| 706 | 752 | sprintf(alias + strlen(alias), "f*"); |
| 707 | | − if (id->flags & INPUT_DEVICE_ID_MATCH_FFBIT) |
| 708 | | − do_input(alias, id->ffbit, 0, INPUT_DEVICE_ID_FF_MAX); |
| 753 | + if (flags & INPUT_DEVICE_ID_MATCH_FFBIT) |
| 754 | + do_input(alias, *ffbit, 0, INPUT_DEVICE_ID_FF_MAX); |
| 709 | 755 | sprintf(alias + strlen(alias), "w*"); |
| 710 | | − if (id->flags & INPUT_DEVICE_ID_MATCH_SWBIT) |
| 711 | | − do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); |
| 756 | + if (flags & INPUT_DEVICE_ID_MATCH_SWBIT) |
| 757 | + do_input(alias, *swbit, 0, INPUT_DEVICE_ID_SW_MAX); |
| 712 | 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 | 763 | char *alias) |
| 718 | 764 | { |
| 719 | | − if (eisa->sig[0]) |
| 720 | | − sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig); |
| 765 | + DEF_FIELD_ADDR(symval, eisa_device_id, sig); |
| 766 | + if (sig[0]) |
| 767 | + sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", *sig); |
| 721 | 768 | else |
| 722 | 769 | strcat(alias, "*"); |
| 723 | 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 | 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 | 776 | char *alias) |
| 730 | 777 | { |
| 731 | | − id->hw_type = TO_NATIVE(id->hw_type); |
| 732 | | − id->hversion = TO_NATIVE(id->hversion); |
| 733 | | − id->hversion_rev = TO_NATIVE(id->hversion_rev); |
| 734 | | − id->sversion = TO_NATIVE(id->sversion); |
| 778 | + DEF_FIELD(symval, parisc_device_id, hw_type); |
| 779 | + DEF_FIELD(symval, parisc_device_id, hversion); |
| 780 | + DEF_FIELD(symval, parisc_device_id, hversion_rev); |
| 781 | + DEF_FIELD(symval, parisc_device_id, sversion); |
| 735 | 782 | |
| 736 | 783 | strcpy(alias, "parisc:"); |
| 737 | | − ADD(alias, "t", id->hw_type != PA_HWTYPE_ANY_ID, id->hw_type); |
| 738 | | − ADD(alias, "hv", id->hversion != PA_HVERSION_ANY_ID, id->hversion); |
| 739 | | − ADD(alias, "rev", id->hversion_rev != PA_HVERSION_REV_ANY_ID, id->hversion_rev); |
| 740 | | − ADD(alias, "sv", id->sversion != PA_SVERSION_ANY_ID, id->sversion); |
| 784 | + ADD(alias, "t", hw_type != PA_HWTYPE_ANY_ID, hw_type); |
| 785 | + ADD(alias, "hv", hversion != PA_HVERSION_ANY_ID, hversion); |
| 786 | + ADD(alias, "rev", hversion_rev != PA_HVERSION_REV_ANY_ID, hversion_rev); |
| 787 | + ADD(alias, "sv", sversion != PA_SVERSION_ANY_ID, sversion); |
| 741 | 788 | |
| 742 | 789 | add_wildcard(alias); |
| 743 | 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 | 794 | /* Looks like: sdio:cNvNdN. */ |
| 748 | 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); |
| 752 | | − id->vendor = TO_NATIVE(id->vendor); |
| 753 | | − id->device = TO_NATIVE(id->device); |
| 798 | + DEF_FIELD(symval, sdio_device_id, class); |
| 799 | + DEF_FIELD(symval, sdio_device_id, vendor); |
| 800 | + DEF_FIELD(symval, sdio_device_id, device); |
| 754 | 801 | |
| 755 | 802 | strcpy(alias, "sdio:"); |
| 756 | | − ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class); |
| 757 | | − ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor); |
| 758 | | − ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device); |
| 803 | + ADD(alias, "c", class != (__u8)SDIO_ANY_ID, class); |
| 804 | + ADD(alias, "v", vendor != (__u16)SDIO_ANY_ID, vendor); |
| 805 | + ADD(alias, "d", device != (__u16)SDIO_ANY_ID, device); |
| 759 | 806 | add_wildcard(alias); |
| 760 | 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 | 811 | /* Looks like: ssb:vNidNrevN. */ |
| 765 | 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); |
| 769 | | − id->coreid = TO_NATIVE(id->coreid); |
| 770 | | − id->revision = TO_NATIVE(id->revision); |
| 815 | + DEF_FIELD(symval, ssb_device_id, vendor); |
| 816 | + DEF_FIELD(symval, ssb_device_id, coreid); |
| 817 | + DEF_FIELD(symval, ssb_device_id, revision); |
| 771 | 818 | |
| 772 | 819 | strcpy(alias, "ssb:"); |
| 773 | | − ADD(alias, "v", id->vendor != SSB_ANY_VENDOR, id->vendor); |
| 774 | | − ADD(alias, "id", id->coreid != SSB_ANY_ID, id->coreid); |
| 775 | | − ADD(alias, "rev", id->revision != SSB_ANY_REV, id->revision); |
| 820 | + ADD(alias, "v", vendor != SSB_ANY_VENDOR, vendor); |
| 821 | + ADD(alias, "id", coreid != SSB_ANY_ID, coreid); |
| 822 | + ADD(alias, "rev", revision != SSB_ANY_REV, revision); |
| 776 | 823 | add_wildcard(alias); |
| 777 | 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 | 828 | /* Looks like: bcma:mNidNrevNclN. */ |
| 782 | 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); |
| 786 | | − id->id = TO_NATIVE(id->id); |
| 787 | | − id->rev = TO_NATIVE(id->rev); |
| 788 | | − id->class = TO_NATIVE(id->class); |
| 832 | + DEF_FIELD(symval, bcma_device_id, manuf); |
| 833 | + DEF_FIELD(symval, bcma_device_id, id); |
| 834 | + DEF_FIELD(symval, bcma_device_id, rev); |
| 835 | + DEF_FIELD(symval, bcma_device_id, class); |
| 789 | 836 | |
| 790 | 837 | strcpy(alias, "bcma:"); |
| 791 | | − ADD(alias, "m", id->manuf != BCMA_ANY_MANUF, id->manuf); |
| 792 | | − ADD(alias, "id", id->id != BCMA_ANY_ID, id->id); |
| 793 | | − ADD(alias, "rev", id->rev != BCMA_ANY_REV, id->rev); |
| 794 | | − ADD(alias, "cl", id->class != BCMA_ANY_CLASS, id->class); |
| 838 | + ADD(alias, "m", manuf != BCMA_ANY_MANUF, manuf); |
| 839 | + ADD(alias, "id", id != BCMA_ANY_ID, id); |
| 840 | + ADD(alias, "rev", rev != BCMA_ANY_REV, rev); |
| 841 | + ADD(alias, "cl", class != BCMA_ANY_CLASS, class); |
| 795 | 842 | add_wildcard(alias); |
| 796 | 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 | 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 | 849 | char *alias) |
| 803 | 850 | { |
| 804 | | − id->device = TO_NATIVE(id->device); |
| 805 | | − id->vendor = TO_NATIVE(id->vendor); |
| 851 | + DEF_FIELD(symval, virtio_device_id, device); |
| 852 | + DEF_FIELD(symval, virtio_device_id, vendor); |
| 806 | 853 | |
| 807 | 854 | strcpy(alias, "virtio:"); |
| 808 | | − ADD(alias, "d", id->device != VIRTIO_DEV_ANY_ID, id->device); |
| 809 | | − ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor); |
| 855 | + ADD(alias, "d", device != VIRTIO_DEV_ANY_ID, device); |
| 856 | + ADD(alias, "v", vendor != VIRTIO_DEV_ANY_ID, vendor); |
| 810 | 857 | |
| 811 | 858 | add_wildcard(alias); |
| 812 | 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 | 864 | * Looks like: vmbus:guid |
| @@ -819,41 +866,44 @@ ADD_TO_DEVTABLE("virtio", struct virtio_device_id, do_virtio_entry); · 1 unmodified line |
| 819 | 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 | 870 | char *alias) |
| 824 | 871 | { |
| 825 | 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) |
| 829 | | − sprintf(&guid_name[i], "%02x", id->guid[i/2]); |
| 876 | + for (i = 0; i < (sizeof(*guid) * 2); i += 2) |
| 877 | + sprintf(&guid_name[i], "%02x", TO_NATIVE((*guid)[i/2])); |
| 830 | 878 | |
| 831 | 879 | strcpy(alias, "vmbus:"); |
| 832 | 880 | strcat(alias, guid_name); |
| 833 | 881 | |
| 834 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 908 | static const struct dmifield { |
| 859 | 909 | const char *prefix; |
| @@ -885,21 +935,21 @@ static void dmi_ascii_filter(char *d, const char *s) · 25 unmodified lines |
| 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 | 939 | char *alias) |
| 890 | 940 | { |
| 891 | 941 | int i, j; |
| 892 | | − |
| 942 | + DEF_FIELD_ADDR(symval, dmi_system_id, matches); |
| 893 | 943 | sprintf(alias, "dmi*"); |
| 894 | 944 | |
| 895 | 945 | for (i = 0; i < ARRAY_SIZE(dmi_fields); i++) { |
| 896 | 946 | for (j = 0; j < 4; j++) { |
| 897 | | − if (id->matches[j].slot && |
| 898 | | − id->matches[j].slot == dmi_fields[i].field) { |
| 947 | + if ((*matches)[j].slot && |
| 948 | + (*matches)[j].slot == dmi_fields[i].field) { |
| 899 | 949 | sprintf(alias + strlen(alias), ":%s*", |
| 900 | 950 | dmi_fields[i].prefix); |
| 901 | 951 | dmi_ascii_filter(alias + strlen(alias), |
| 902 | | − id->matches[j].substr); |
| 952 | + (*matches)[j].substr); |
| 903 | 953 | strcat(alias, "*"); |
| 904 | 954 | } |
| 905 | 955 | } |
| @@ -908,27 +958,30 @@ static int do_dmi_entry(const char *filename, struct dmi_system_id *id, · 2 unmodified lines |
| 908 | 958 | strcat(alias, ":"); |
| 909 | 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 | 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 | 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 | 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 | 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 | 979 | alias += sprintf(alias, MDIO_MODULE_PREFIX); |
| 927 | 980 | |
| 928 | 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 | 983 | *(alias++) = '?'; |
| 931 | | − else if ((id->phy_id >> (31-i)) & 1) |
| 984 | + else if ((phy_id >> (31-i)) & 1) |
| 932 | 985 | *(alias++) = '1'; |
| 933 | 986 | else |
| 934 | 987 | *(alias++) = '0'; |
| @@ -939,47 +992,50 @@ static int do_mdio_entry(const char *filename, · 4 unmodified lines |
| 939 | 992 | |
| 940 | 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 | 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 | 999 | char *alias) |
| 947 | 1000 | { |
| 948 | | − id->id = TO_NATIVE(id->id); |
| 1001 | + DEF_FIELD(symval, zorro_device_id, id); |
| 949 | 1002 | strcpy(alias, "zorro:"); |
| 950 | | − ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id); |
| 1003 | + ADD(alias, "i", id != ZORRO_WILDCARD, id); |
| 951 | 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 | 1008 | /* looks like: "pnp:dD" */ |
| 956 | 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 | 1014 | sprintf(alias, "pnp:d%c%c%c%x%x%x%x*", |
| 960 | | − 'A' + ((id->vendor >> 2) & 0x3f) - 1, |
| 961 | | − 'A' + (((id->vendor & 3) << 3) | ((id->vendor >> 13) & 7)) - 1, |
| 962 | | − 'A' + ((id->vendor >> 8) & 0x1f) - 1, |
| 963 | | − (id->function >> 4) & 0x0f, id->function & 0x0f, |
| 964 | | − (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f); |
| 1015 | + 'A' + ((vendor >> 2) & 0x3f) - 1, |
| 1016 | + 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, |
| 1017 | + 'A' + ((vendor >> 8) & 0x1f) - 1, |
| 1018 | + (function >> 4) & 0x0f, function & 0x0f, |
| 1019 | + (function >> 12) & 0x0f, (function >> 8) & 0x0f); |
| 965 | 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 | 1024 | /* Looks like: "ipack:fNvNdN". */ |
| 970 | 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); |
| 974 | | − id->device = TO_NATIVE(id->device); |
| 1028 | + DEF_FIELD(symval, ipack_device_id, format); |
| 1029 | + DEF_FIELD(symval, ipack_device_id, vendor); |
| 1030 | + DEF_FIELD(symval, ipack_device_id, device); |
| 975 | 1031 | strcpy(alias, "ipack:"); |
| 976 | | − ADD(alias, "f", id->format != IPACK_ANY_FORMAT, id->format); |
| 977 | | − ADD(alias, "v", id->vendor != IPACK_ANY_ID, id->vendor); |
| 978 | | − ADD(alias, "d", id->device != IPACK_ANY_ID, id->device); |
| 1032 | + ADD(alias, "f", format != IPACK_ANY_FORMAT, format); |
| 1033 | + ADD(alias, "v", vendor != IPACK_ANY_ID, vendor); |
| 1034 | + ADD(alias, "d", device != IPACK_ANY_ID, device); |
| 979 | 1035 | add_wildcard(alias); |
| 980 | 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 | 1041 | * Append a match expression for a single masked hex digit. |
| @@ -1030,25 +1086,27 @@ static void append_nibble_mask(char **outp, · 44 unmodified lines |
| 1030 | 1086 | * a ? or [] pattern matching exactly one digit. |
| 1031 | 1087 | */ |
| 1032 | 1088 | static int do_amba_entry(const char *filename, |
| 1033 | | − struct amba_id *id, char *alias) |
| 1089 | + void *symval, char *alias) |
| 1034 | 1090 | { |
| 1035 | 1091 | unsigned int digit; |
| 1036 | 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 | 1097 | fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: " |
| 1040 | 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 | 1101 | p += sprintf(alias, "amba:d"); |
| 1044 | 1102 | for (digit = 0; digit < 8; digit++) |
| 1045 | 1103 | append_nibble_mask(&p, |
| 1046 | | − (id->id >> (4 * (7 - digit))) & 0xf, |
| 1047 | | − (id->mask >> (4 * (7 - digit))) & 0xf); |
| 1104 | + (id >> (4 * (7 - digit))) & 0xf, |
| 1105 | + (mask >> (4 * (7 - digit))) & 0xf); |
| 1048 | 1106 | |
| 1049 | 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 | 1111 | /* LOOKS like x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:*,FEAT,* |
| 1054 | 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); · 1 unmodified line |
| 1056 | 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 | 1118 | char *alias) |
| 1061 | 1119 | { |
| 1062 | | − id->feature = TO_NATIVE(id->feature); |
| 1063 | | − id->family = TO_NATIVE(id->family); |
| 1064 | | − id->model = TO_NATIVE(id->model); |
| 1065 | | − id->vendor = TO_NATIVE(id->vendor); |
| 1120 | + DEF_FIELD(symval, x86_cpu_id, feature); |
| 1121 | + DEF_FIELD(symval, x86_cpu_id, family); |
| 1122 | + DEF_FIELD(symval, x86_cpu_id, model); |
| 1123 | + DEF_FIELD(symval, x86_cpu_id, vendor); |
| 1066 | 1124 | |
| 1067 | 1125 | strcpy(alias, "x86cpu:"); |
| 1068 | | − ADD(alias, "vendor:", id->vendor != X86_VENDOR_ANY, id->vendor); |
| 1069 | | − ADD(alias, ":family:", id->family != X86_FAMILY_ANY, id->family); |
| 1070 | | − ADD(alias, ":model:", id->model != X86_MODEL_ANY, id->model); |
| 1126 | + ADD(alias, "vendor:", vendor != X86_VENDOR_ANY, vendor); |
| 1127 | + ADD(alias, ":family:", family != X86_FAMILY_ANY, family); |
| 1128 | + ADD(alias, ":model:", model != X86_MODEL_ANY, model); |
| 1071 | 1129 | strcat(alias, ":feature:*"); |
| 1072 | | − if (id->feature != X86_FEATURE_ANY) |
| 1073 | | − sprintf(alias + strlen(alias), "%04X*", id->feature); |
| 1130 | + if (feature != X86_FEATURE_ANY) |
| 1131 | + sprintf(alias + strlen(alias), "%04X*", feature); |
| 1074 | 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 | 1136 | /* Does namelen bytes of name exactly match the symbol? */ |
| 1079 | 1137 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) |