.. | .. |
---|
40 | 40 | static LIST_HEAD(wmi_block_list); |
---|
41 | 41 | |
---|
42 | 42 | struct guid_block { |
---|
43 | | - char guid[16]; |
---|
| 43 | + guid_t guid; |
---|
44 | 44 | union { |
---|
45 | 45 | char object_id[2]; |
---|
46 | 46 | struct { |
---|
.. | .. |
---|
121 | 121 | list_for_each_entry(wblock, &wmi_block_list, list) { |
---|
122 | 122 | block = &wblock->gblock; |
---|
123 | 123 | |
---|
124 | | - if (memcmp(block->guid, &guid_input, 16) == 0) { |
---|
| 124 | + if (guid_equal(&block->guid, &guid_input)) { |
---|
125 | 125 | if (out) |
---|
126 | 126 | *out = wblock; |
---|
127 | 127 | return true; |
---|
.. | .. |
---|
130 | 130 | return false; |
---|
131 | 131 | } |
---|
132 | 132 | |
---|
| 133 | +static bool guid_parse_and_compare(const char *string, const guid_t *guid) |
---|
| 134 | +{ |
---|
| 135 | + guid_t guid_input; |
---|
| 136 | + |
---|
| 137 | + if (guid_parse(string, &guid_input)) |
---|
| 138 | + return false; |
---|
| 139 | + |
---|
| 140 | + return guid_equal(&guid_input, guid); |
---|
| 141 | +} |
---|
| 142 | + |
---|
133 | 143 | static const void *find_guid_context(struct wmi_block *wblock, |
---|
134 | 144 | struct wmi_driver *wdriver) |
---|
135 | 145 | { |
---|
136 | 146 | const struct wmi_device_id *id; |
---|
137 | | - guid_t guid_input; |
---|
138 | 147 | |
---|
139 | 148 | if (wblock == NULL || wdriver == NULL) |
---|
140 | 149 | return NULL; |
---|
.. | .. |
---|
143 | 152 | |
---|
144 | 153 | id = wdriver->id_table; |
---|
145 | 154 | while (*id->guid_string) { |
---|
146 | | - if (guid_parse(id->guid_string, &guid_input)) |
---|
147 | | - continue; |
---|
148 | | - if (!memcmp(wblock->gblock.guid, &guid_input, 16)) |
---|
| 155 | + if (guid_parse_and_compare(id->guid_string, &wblock->gblock.guid)) |
---|
149 | 156 | return id->context; |
---|
150 | 157 | id++; |
---|
151 | 158 | } |
---|
.. | .. |
---|
457 | 464 | |
---|
458 | 465 | static void wmi_dump_wdg(const struct guid_block *g) |
---|
459 | 466 | { |
---|
460 | | - pr_info("%pUL:\n", g->guid); |
---|
| 467 | + pr_info("%pUL:\n", &g->guid); |
---|
461 | 468 | if (g->flags & ACPI_WMI_EVENT) |
---|
462 | 469 | pr_info("\tnotify_id: 0x%02X\n", g->notify_id); |
---|
463 | 470 | else |
---|
.. | .. |
---|
539 | 546 | list_for_each_entry(block, &wmi_block_list, list) { |
---|
540 | 547 | acpi_status wmi_status; |
---|
541 | 548 | |
---|
542 | | - if (memcmp(block->gblock.guid, &guid_input, 16) == 0) { |
---|
| 549 | + if (guid_equal(&block->gblock.guid, &guid_input)) { |
---|
543 | 550 | if (block->handler && |
---|
544 | 551 | block->handler != wmi_notify_debug) |
---|
545 | 552 | return AE_ALREADY_ACQUIRED; |
---|
.. | .. |
---|
579 | 586 | list_for_each_entry(block, &wmi_block_list, list) { |
---|
580 | 587 | acpi_status wmi_status; |
---|
581 | 588 | |
---|
582 | | - if (memcmp(block->gblock.guid, &guid_input, 16) == 0) { |
---|
| 589 | + if (guid_equal(&block->gblock.guid, &guid_input)) { |
---|
583 | 590 | if (!block->handler || |
---|
584 | 591 | block->handler == wmi_notify_debug) |
---|
585 | 592 | return AE_NULL_ENTRY; |
---|
.. | .. |
---|
615 | 622 | { |
---|
616 | 623 | struct acpi_object_list input; |
---|
617 | 624 | union acpi_object params[1]; |
---|
618 | | - struct guid_block *gblock; |
---|
619 | 625 | struct wmi_block *wblock; |
---|
620 | 626 | |
---|
621 | 627 | input.count = 1; |
---|
.. | .. |
---|
624 | 630 | params[0].integer.value = event; |
---|
625 | 631 | |
---|
626 | 632 | list_for_each_entry(wblock, &wmi_block_list, list) { |
---|
627 | | - gblock = &wblock->gblock; |
---|
| 633 | + struct guid_block *gblock = &wblock->gblock; |
---|
628 | 634 | |
---|
629 | 635 | if ((gblock->flags & ACPI_WMI_EVENT) && |
---|
630 | 636 | (gblock->notify_id == event)) |
---|
.. | .. |
---|
685 | 691 | { |
---|
686 | 692 | struct wmi_block *wblock = dev_to_wblock(dev); |
---|
687 | 693 | |
---|
688 | | - return sprintf(buf, "wmi:%pUL\n", wblock->gblock.guid); |
---|
| 694 | + return sprintf(buf, "wmi:%pUL\n", &wblock->gblock.guid); |
---|
689 | 695 | } |
---|
690 | 696 | static DEVICE_ATTR_RO(modalias); |
---|
691 | 697 | |
---|
.. | .. |
---|
694 | 700 | { |
---|
695 | 701 | struct wmi_block *wblock = dev_to_wblock(dev); |
---|
696 | 702 | |
---|
697 | | - return sprintf(buf, "%pUL\n", wblock->gblock.guid); |
---|
| 703 | + return sprintf(buf, "%pUL\n", &wblock->gblock.guid); |
---|
698 | 704 | } |
---|
699 | 705 | static DEVICE_ATTR_RO(guid); |
---|
700 | 706 | |
---|
.. | .. |
---|
777 | 783 | { |
---|
778 | 784 | struct wmi_block *wblock = dev_to_wblock(dev); |
---|
779 | 785 | |
---|
780 | | - if (add_uevent_var(env, "MODALIAS=wmi:%pUL", wblock->gblock.guid)) |
---|
| 786 | + if (add_uevent_var(env, "MODALIAS=wmi:%pUL", &wblock->gblock.guid)) |
---|
781 | 787 | return -ENOMEM; |
---|
782 | 788 | |
---|
783 | | - if (add_uevent_var(env, "WMI_GUID=%pUL", wblock->gblock.guid)) |
---|
| 789 | + if (add_uevent_var(env, "WMI_GUID=%pUL", &wblock->gblock.guid)) |
---|
784 | 790 | return -ENOMEM; |
---|
785 | 791 | |
---|
786 | 792 | return 0; |
---|
.. | .. |
---|
804 | 810 | return 0; |
---|
805 | 811 | |
---|
806 | 812 | while (*id->guid_string) { |
---|
807 | | - guid_t driver_guid; |
---|
808 | | - |
---|
809 | | - if (WARN_ON(guid_parse(id->guid_string, &driver_guid))) |
---|
810 | | - continue; |
---|
811 | | - if (!memcmp(&driver_guid, wblock->gblock.guid, 16)) |
---|
| 813 | + if (guid_parse_and_compare(id->guid_string, &wblock->gblock.guid)) |
---|
812 | 814 | return 1; |
---|
813 | 815 | |
---|
814 | 816 | id++; |
---|
.. | .. |
---|
1042 | 1044 | }; |
---|
1043 | 1045 | |
---|
1044 | 1046 | static int wmi_create_device(struct device *wmi_bus_dev, |
---|
1045 | | - const struct guid_block *gblock, |
---|
1046 | 1047 | struct wmi_block *wblock, |
---|
1047 | 1048 | struct acpi_device *device) |
---|
1048 | 1049 | { |
---|
.. | .. |
---|
1050 | 1051 | char method[5]; |
---|
1051 | 1052 | int result; |
---|
1052 | 1053 | |
---|
1053 | | - if (gblock->flags & ACPI_WMI_EVENT) { |
---|
| 1054 | + if (wblock->gblock.flags & ACPI_WMI_EVENT) { |
---|
1054 | 1055 | wblock->dev.dev.type = &wmi_type_event; |
---|
1055 | 1056 | goto out_init; |
---|
1056 | 1057 | } |
---|
1057 | 1058 | |
---|
1058 | | - if (gblock->flags & ACPI_WMI_METHOD) { |
---|
| 1059 | + if (wblock->gblock.flags & ACPI_WMI_METHOD) { |
---|
1059 | 1060 | wblock->dev.dev.type = &wmi_type_method; |
---|
1060 | 1061 | mutex_init(&wblock->char_mutex); |
---|
1061 | 1062 | goto out_init; |
---|
.. | .. |
---|
1105 | 1106 | wblock->dev.dev.bus = &wmi_bus_type; |
---|
1106 | 1107 | wblock->dev.dev.parent = wmi_bus_dev; |
---|
1107 | 1108 | |
---|
1108 | | - dev_set_name(&wblock->dev.dev, "%pUL", gblock->guid); |
---|
| 1109 | + dev_set_name(&wblock->dev.dev, "%pUL", &wblock->gblock.guid); |
---|
1109 | 1110 | |
---|
1110 | 1111 | device_initialize(&wblock->dev.dev); |
---|
1111 | 1112 | |
---|
.. | .. |
---|
1125 | 1126 | } |
---|
1126 | 1127 | } |
---|
1127 | 1128 | |
---|
1128 | | -static bool guid_already_parsed(struct acpi_device *device, const u8 *guid) |
---|
| 1129 | +static bool guid_already_parsed(struct acpi_device *device, const guid_t *guid) |
---|
1129 | 1130 | { |
---|
1130 | 1131 | struct wmi_block *wblock; |
---|
1131 | 1132 | |
---|
1132 | 1133 | list_for_each_entry(wblock, &wmi_block_list, list) { |
---|
1133 | | - if (memcmp(wblock->gblock.guid, guid, 16) == 0) { |
---|
| 1134 | + if (guid_equal(&wblock->gblock.guid, guid)) { |
---|
1134 | 1135 | /* |
---|
1135 | 1136 | * Because we historically didn't track the relationship |
---|
1136 | 1137 | * between GUIDs and ACPI nodes, we don't know whether |
---|
.. | .. |
---|
1185 | 1186 | * case yet, so for now, we'll just ignore the duplicate |
---|
1186 | 1187 | * for device creation. |
---|
1187 | 1188 | */ |
---|
1188 | | - if (guid_already_parsed(device, gblock[i].guid)) |
---|
| 1189 | + if (guid_already_parsed(device, &gblock[i].guid)) |
---|
1189 | 1190 | continue; |
---|
1190 | 1191 | |
---|
1191 | 1192 | wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL); |
---|
.. | .. |
---|
1197 | 1198 | wblock->acpi_device = device; |
---|
1198 | 1199 | wblock->gblock = gblock[i]; |
---|
1199 | 1200 | |
---|
1200 | | - retval = wmi_create_device(wmi_bus_dev, &gblock[i], wblock, device); |
---|
| 1201 | + retval = wmi_create_device(wmi_bus_dev, wblock, device); |
---|
1201 | 1202 | if (retval) { |
---|
1202 | 1203 | kfree(wblock); |
---|
1203 | 1204 | continue; |
---|
.. | .. |
---|
1222 | 1223 | retval = device_add(&wblock->dev.dev); |
---|
1223 | 1224 | if (retval) { |
---|
1224 | 1225 | dev_err(wmi_bus_dev, "failed to register %pUL\n", |
---|
1225 | | - wblock->gblock.guid); |
---|
| 1226 | + &wblock->gblock.guid); |
---|
1226 | 1227 | if (debug_event) |
---|
1227 | 1228 | wmi_method_enable(wblock, 0); |
---|
1228 | 1229 | list_del(&wblock->list); |
---|
.. | .. |
---|
1282 | 1283 | static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, |
---|
1283 | 1284 | void *context) |
---|
1284 | 1285 | { |
---|
1285 | | - struct guid_block *block; |
---|
1286 | 1286 | struct wmi_block *wblock; |
---|
1287 | 1287 | bool found_it = false; |
---|
1288 | 1288 | |
---|
1289 | 1289 | list_for_each_entry(wblock, &wmi_block_list, list) { |
---|
1290 | | - block = &wblock->gblock; |
---|
| 1290 | + struct guid_block *block = &wblock->gblock; |
---|
1291 | 1291 | |
---|
1292 | 1292 | if (wblock->acpi_device->handle == handle && |
---|
1293 | 1293 | (block->flags & ACPI_WMI_EVENT) && |
---|
.. | .. |
---|
1336 | 1336 | } |
---|
1337 | 1337 | |
---|
1338 | 1338 | if (debug_event) |
---|
1339 | | - pr_info("DEBUG Event GUID: %pUL\n", wblock->gblock.guid); |
---|
| 1339 | + pr_info("DEBUG Event GUID: %pUL\n", &wblock->gblock.guid); |
---|
1340 | 1340 | |
---|
1341 | 1341 | acpi_bus_generate_netlink_event( |
---|
1342 | 1342 | wblock->acpi_device->pnp.device_class, |
---|