| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ACPI-WMI mapping driver |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 11 | 12 | * WMI bus infrastructure by Andrew Lutomirski and Darren Hart: |
|---|
| 12 | 13 | * Copyright (C) 2015 Andrew Lutomirski |
|---|
| 13 | 14 | * Copyright (C) 2017 VMware, Inc. All Rights Reserved. |
|---|
| 14 | | - * |
|---|
| 15 | | - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 16 | | - * |
|---|
| 17 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 18 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 19 | | - * the Free Software Foundation; either version 2 of the License, or (at |
|---|
| 20 | | - * your option) any later version. |
|---|
| 21 | | - * |
|---|
| 22 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 23 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 24 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 25 | | - * General Public License for more details. |
|---|
| 26 | | - * |
|---|
| 27 | | - * You should have received a copy of the GNU General Public License along |
|---|
| 28 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 29 | | - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|---|
| 30 | | - * |
|---|
| 31 | | - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 32 | 15 | */ |
|---|
| 33 | 16 | |
|---|
| 34 | 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 46 | 29 | #include <linux/uaccess.h> |
|---|
| 47 | 30 | #include <linux/uuid.h> |
|---|
| 48 | 31 | #include <linux/wmi.h> |
|---|
| 32 | +#include <linux/fs.h> |
|---|
| 49 | 33 | #include <uapi/linux/wmi.h> |
|---|
| 50 | 34 | |
|---|
| 51 | 35 | ACPI_MODULE_NAME("wmi"); |
|---|
| .. | .. |
|---|
| 56 | 40 | static LIST_HEAD(wmi_block_list); |
|---|
| 57 | 41 | |
|---|
| 58 | 42 | struct guid_block { |
|---|
| 59 | | - char guid[16]; |
|---|
| 43 | + guid_t guid; |
|---|
| 60 | 44 | union { |
|---|
| 61 | 45 | char object_id[2]; |
|---|
| 62 | 46 | struct { |
|---|
| .. | .. |
|---|
| 127 | 111 | |
|---|
| 128 | 112 | static bool find_guid(const char *guid_string, struct wmi_block **out) |
|---|
| 129 | 113 | { |
|---|
| 130 | | - uuid_le guid_input; |
|---|
| 114 | + guid_t guid_input; |
|---|
| 131 | 115 | struct wmi_block *wblock; |
|---|
| 132 | 116 | struct guid_block *block; |
|---|
| 133 | 117 | |
|---|
| 134 | | - if (uuid_le_to_bin(guid_string, &guid_input)) |
|---|
| 118 | + if (guid_parse(guid_string, &guid_input)) |
|---|
| 135 | 119 | return false; |
|---|
| 136 | 120 | |
|---|
| 137 | 121 | list_for_each_entry(wblock, &wmi_block_list, list) { |
|---|
| 138 | 122 | block = &wblock->gblock; |
|---|
| 139 | 123 | |
|---|
| 140 | | - if (memcmp(block->guid, &guid_input, 16) == 0) { |
|---|
| 124 | + if (guid_equal(&block->guid, &guid_input)) { |
|---|
| 141 | 125 | if (out) |
|---|
| 142 | 126 | *out = wblock; |
|---|
| 143 | 127 | return true; |
|---|
| 144 | 128 | } |
|---|
| 145 | 129 | } |
|---|
| 146 | 130 | return false; |
|---|
| 131 | +} |
|---|
| 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 | + |
|---|
| 143 | +static const void *find_guid_context(struct wmi_block *wblock, |
|---|
| 144 | + struct wmi_driver *wdriver) |
|---|
| 145 | +{ |
|---|
| 146 | + const struct wmi_device_id *id; |
|---|
| 147 | + |
|---|
| 148 | + if (wblock == NULL || wdriver == NULL) |
|---|
| 149 | + return NULL; |
|---|
| 150 | + if (wdriver->id_table == NULL) |
|---|
| 151 | + return NULL; |
|---|
| 152 | + |
|---|
| 153 | + id = wdriver->id_table; |
|---|
| 154 | + while (*id->guid_string) { |
|---|
| 155 | + if (guid_parse_and_compare(id->guid_string, &wblock->gblock.guid)) |
|---|
| 156 | + return id->context; |
|---|
| 157 | + id++; |
|---|
| 158 | + } |
|---|
| 159 | + return NULL; |
|---|
| 147 | 160 | } |
|---|
| 148 | 161 | |
|---|
| 149 | 162 | static int get_subobj_info(acpi_handle handle, const char *pathname, |
|---|
| .. | .. |
|---|
| 196 | 209 | /** |
|---|
| 197 | 210 | * set_required_buffer_size - Sets the buffer size needed for performing IOCTL |
|---|
| 198 | 211 | * @wdev: A wmi bus device from a driver |
|---|
| 199 | | - * @instance: Instance index |
|---|
| 212 | + * @length: Required buffer size |
|---|
| 200 | 213 | * |
|---|
| 201 | 214 | * Allocates memory needed for buffer, stores the buffer size in that memory |
|---|
| 202 | 215 | */ |
|---|
| .. | .. |
|---|
| 216 | 229 | * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba |
|---|
| 217 | 230 | * @instance: Instance index |
|---|
| 218 | 231 | * @method_id: Method ID to call |
|---|
| 219 | | - * &in: Buffer containing input for the method call |
|---|
| 220 | | - * &out: Empty buffer to return the method results |
|---|
| 232 | + * @in: Buffer containing input for the method call |
|---|
| 233 | + * @out: Empty buffer to return the method results |
|---|
| 221 | 234 | * |
|---|
| 222 | 235 | * Call an ACPI-WMI method |
|---|
| 223 | 236 | */ |
|---|
| .. | .. |
|---|
| 238 | 251 | * @wdev: A wmi bus device from a driver |
|---|
| 239 | 252 | * @instance: Instance index |
|---|
| 240 | 253 | * @method_id: Method ID to call |
|---|
| 241 | | - * &in: Buffer containing input for the method call |
|---|
| 242 | | - * &out: Empty buffer to return the method results |
|---|
| 254 | + * @in: Buffer containing input for the method call |
|---|
| 255 | + * @out: Empty buffer to return the method results |
|---|
| 243 | 256 | * |
|---|
| 244 | 257 | * Call an ACPI-WMI method |
|---|
| 245 | 258 | */ |
|---|
| .. | .. |
|---|
| 335 | 348 | * expensive, but have no corresponding WCxx method. So we |
|---|
| 336 | 349 | * should not fail if this happens. |
|---|
| 337 | 350 | */ |
|---|
| 338 | | - if (acpi_has_method(handle, wc_method)) |
|---|
| 339 | | - wc_status = acpi_execute_simple_method(handle, |
|---|
| 340 | | - wc_method, 1); |
|---|
| 351 | + wc_status = acpi_execute_simple_method(handle, wc_method, 1); |
|---|
| 341 | 352 | } |
|---|
| 342 | 353 | |
|---|
| 343 | 354 | strcpy(method, "WQ"); |
|---|
| .. | .. |
|---|
| 367 | 378 | * wmi_query_block - Return contents of a WMI block (deprecated) |
|---|
| 368 | 379 | * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba |
|---|
| 369 | 380 | * @instance: Instance index |
|---|
| 370 | | - * &out: Empty buffer to return the contents of the data block to |
|---|
| 381 | + * @out: Empty buffer to return the contents of the data block to |
|---|
| 371 | 382 | * |
|---|
| 372 | 383 | * Return the contents of an ACPI-WMI data block to a buffer |
|---|
| 373 | 384 | */ |
|---|
| .. | .. |
|---|
| 402 | 413 | * wmi_set_block - Write to a WMI block |
|---|
| 403 | 414 | * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba |
|---|
| 404 | 415 | * @instance: Instance index |
|---|
| 405 | | - * &in: Buffer containing new values for the data block |
|---|
| 416 | + * @in: Buffer containing new values for the data block |
|---|
| 406 | 417 | * |
|---|
| 407 | 418 | * Write the contents of the input buffer to an ACPI-WMI data block |
|---|
| 408 | 419 | */ |
|---|
| .. | .. |
|---|
| 453 | 464 | |
|---|
| 454 | 465 | static void wmi_dump_wdg(const struct guid_block *g) |
|---|
| 455 | 466 | { |
|---|
| 456 | | - pr_info("%pUL:\n", g->guid); |
|---|
| 467 | + pr_info("%pUL:\n", &g->guid); |
|---|
| 457 | 468 | if (g->flags & ACPI_WMI_EVENT) |
|---|
| 458 | 469 | pr_info("\tnotify_id: 0x%02X\n", g->notify_id); |
|---|
| 459 | 470 | else |
|---|
| .. | .. |
|---|
| 513 | 524 | |
|---|
| 514 | 525 | /** |
|---|
| 515 | 526 | * wmi_install_notify_handler - Register handler for WMI events |
|---|
| 527 | + * @guid: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba |
|---|
| 516 | 528 | * @handler: Function to handle notifications |
|---|
| 517 | 529 | * @data: Data to be returned to handler when event is fired |
|---|
| 518 | 530 | * |
|---|
| .. | .. |
|---|
| 523 | 535 | { |
|---|
| 524 | 536 | struct wmi_block *block; |
|---|
| 525 | 537 | acpi_status status = AE_NOT_EXIST; |
|---|
| 526 | | - uuid_le guid_input; |
|---|
| 538 | + guid_t guid_input; |
|---|
| 527 | 539 | |
|---|
| 528 | 540 | if (!guid || !handler) |
|---|
| 529 | 541 | return AE_BAD_PARAMETER; |
|---|
| 530 | 542 | |
|---|
| 531 | | - if (uuid_le_to_bin(guid, &guid_input)) |
|---|
| 543 | + if (guid_parse(guid, &guid_input)) |
|---|
| 532 | 544 | return AE_BAD_PARAMETER; |
|---|
| 533 | 545 | |
|---|
| 534 | 546 | list_for_each_entry(block, &wmi_block_list, list) { |
|---|
| 535 | 547 | acpi_status wmi_status; |
|---|
| 536 | 548 | |
|---|
| 537 | | - if (memcmp(block->gblock.guid, &guid_input, 16) == 0) { |
|---|
| 549 | + if (guid_equal(&block->gblock.guid, &guid_input)) { |
|---|
| 538 | 550 | if (block->handler && |
|---|
| 539 | 551 | block->handler != wmi_notify_debug) |
|---|
| 540 | 552 | return AE_ALREADY_ACQUIRED; |
|---|
| .. | .. |
|---|
| 555 | 567 | |
|---|
| 556 | 568 | /** |
|---|
| 557 | 569 | * wmi_uninstall_notify_handler - Unregister handler for WMI events |
|---|
| 570 | + * @guid: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba |
|---|
| 558 | 571 | * |
|---|
| 559 | 572 | * Unregister handler for events sent to the ACPI-WMI mapper device. |
|---|
| 560 | 573 | */ |
|---|
| .. | .. |
|---|
| 562 | 575 | { |
|---|
| 563 | 576 | struct wmi_block *block; |
|---|
| 564 | 577 | acpi_status status = AE_NOT_EXIST; |
|---|
| 565 | | - uuid_le guid_input; |
|---|
| 578 | + guid_t guid_input; |
|---|
| 566 | 579 | |
|---|
| 567 | 580 | if (!guid) |
|---|
| 568 | 581 | return AE_BAD_PARAMETER; |
|---|
| 569 | 582 | |
|---|
| 570 | | - if (uuid_le_to_bin(guid, &guid_input)) |
|---|
| 583 | + if (guid_parse(guid, &guid_input)) |
|---|
| 571 | 584 | return AE_BAD_PARAMETER; |
|---|
| 572 | 585 | |
|---|
| 573 | 586 | list_for_each_entry(block, &wmi_block_list, list) { |
|---|
| 574 | 587 | acpi_status wmi_status; |
|---|
| 575 | 588 | |
|---|
| 576 | | - if (memcmp(block->gblock.guid, &guid_input, 16) == 0) { |
|---|
| 589 | + if (guid_equal(&block->gblock.guid, &guid_input)) { |
|---|
| 577 | 590 | if (!block->handler || |
|---|
| 578 | 591 | block->handler == wmi_notify_debug) |
|---|
| 579 | 592 | return AE_NULL_ENTRY; |
|---|
| .. | .. |
|---|
| 609 | 622 | { |
|---|
| 610 | 623 | struct acpi_object_list input; |
|---|
| 611 | 624 | union acpi_object params[1]; |
|---|
| 612 | | - struct guid_block *gblock; |
|---|
| 613 | 625 | struct wmi_block *wblock; |
|---|
| 614 | 626 | |
|---|
| 615 | 627 | input.count = 1; |
|---|
| .. | .. |
|---|
| 618 | 630 | params[0].integer.value = event; |
|---|
| 619 | 631 | |
|---|
| 620 | 632 | list_for_each_entry(wblock, &wmi_block_list, list) { |
|---|
| 621 | | - gblock = &wblock->gblock; |
|---|
| 633 | + struct guid_block *gblock = &wblock->gblock; |
|---|
| 622 | 634 | |
|---|
| 623 | 635 | if ((gblock->flags & ACPI_WMI_EVENT) && |
|---|
| 624 | 636 | (gblock->notify_id == event)) |
|---|
| .. | .. |
|---|
| 642 | 654 | } |
|---|
| 643 | 655 | EXPORT_SYMBOL_GPL(wmi_has_guid); |
|---|
| 644 | 656 | |
|---|
| 657 | +/** |
|---|
| 658 | + * wmi_get_acpi_device_uid() - Get _UID name of ACPI device that defines GUID |
|---|
| 659 | + * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba |
|---|
| 660 | + * |
|---|
| 661 | + * Find the _UID of ACPI device associated with this WMI GUID. |
|---|
| 662 | + * |
|---|
| 663 | + * Return: The ACPI _UID field value or NULL if the WMI GUID was not found |
|---|
| 664 | + */ |
|---|
| 665 | +char *wmi_get_acpi_device_uid(const char *guid_string) |
|---|
| 666 | +{ |
|---|
| 667 | + struct wmi_block *wblock = NULL; |
|---|
| 668 | + |
|---|
| 669 | + if (!find_guid(guid_string, &wblock)) |
|---|
| 670 | + return NULL; |
|---|
| 671 | + |
|---|
| 672 | + return acpi_device_uid(wblock->acpi_device); |
|---|
| 673 | +} |
|---|
| 674 | +EXPORT_SYMBOL_GPL(wmi_get_acpi_device_uid); |
|---|
| 675 | + |
|---|
| 645 | 676 | static struct wmi_block *dev_to_wblock(struct device *dev) |
|---|
| 646 | 677 | { |
|---|
| 647 | 678 | return container_of(dev, struct wmi_block, dev.dev); |
|---|
| .. | .. |
|---|
| 660 | 691 | { |
|---|
| 661 | 692 | struct wmi_block *wblock = dev_to_wblock(dev); |
|---|
| 662 | 693 | |
|---|
| 663 | | - return sprintf(buf, "wmi:%pUL\n", wblock->gblock.guid); |
|---|
| 694 | + return sprintf(buf, "wmi:%pUL\n", &wblock->gblock.guid); |
|---|
| 664 | 695 | } |
|---|
| 665 | 696 | static DEVICE_ATTR_RO(modalias); |
|---|
| 666 | 697 | |
|---|
| .. | .. |
|---|
| 669 | 700 | { |
|---|
| 670 | 701 | struct wmi_block *wblock = dev_to_wblock(dev); |
|---|
| 671 | 702 | |
|---|
| 672 | | - return sprintf(buf, "%pUL\n", wblock->gblock.guid); |
|---|
| 703 | + return sprintf(buf, "%pUL\n", &wblock->gblock.guid); |
|---|
| 673 | 704 | } |
|---|
| 674 | 705 | static DEVICE_ATTR_RO(guid); |
|---|
| 675 | 706 | |
|---|
| .. | .. |
|---|
| 752 | 783 | { |
|---|
| 753 | 784 | struct wmi_block *wblock = dev_to_wblock(dev); |
|---|
| 754 | 785 | |
|---|
| 755 | | - if (add_uevent_var(env, "MODALIAS=wmi:%pUL", wblock->gblock.guid)) |
|---|
| 786 | + if (add_uevent_var(env, "MODALIAS=wmi:%pUL", &wblock->gblock.guid)) |
|---|
| 756 | 787 | return -ENOMEM; |
|---|
| 757 | 788 | |
|---|
| 758 | | - if (add_uevent_var(env, "WMI_GUID=%pUL", wblock->gblock.guid)) |
|---|
| 789 | + if (add_uevent_var(env, "WMI_GUID=%pUL", &wblock->gblock.guid)) |
|---|
| 759 | 790 | return -ENOMEM; |
|---|
| 760 | 791 | |
|---|
| 761 | 792 | return 0; |
|---|
| .. | .. |
|---|
| 778 | 809 | if (id == NULL) |
|---|
| 779 | 810 | return 0; |
|---|
| 780 | 811 | |
|---|
| 781 | | - while (id->guid_string) { |
|---|
| 782 | | - uuid_le driver_guid; |
|---|
| 783 | | - |
|---|
| 784 | | - if (WARN_ON(uuid_le_to_bin(id->guid_string, &driver_guid))) |
|---|
| 785 | | - continue; |
|---|
| 786 | | - if (!memcmp(&driver_guid, wblock->gblock.guid, 16)) |
|---|
| 812 | + while (*id->guid_string) { |
|---|
| 813 | + if (guid_parse_and_compare(id->guid_string, &wblock->gblock.guid)) |
|---|
| 787 | 814 | return 1; |
|---|
| 788 | 815 | |
|---|
| 789 | 816 | id++; |
|---|
| .. | .. |
|---|
| 896 | 923 | .read = wmi_char_read, |
|---|
| 897 | 924 | .open = wmi_char_open, |
|---|
| 898 | 925 | .unlocked_ioctl = wmi_ioctl, |
|---|
| 899 | | - .compat_ioctl = wmi_ioctl, |
|---|
| 926 | + .compat_ioctl = compat_ptr_ioctl, |
|---|
| 900 | 927 | }; |
|---|
| 901 | 928 | |
|---|
| 902 | 929 | static int wmi_dev_probe(struct device *dev) |
|---|
| .. | .. |
|---|
| 911 | 938 | dev_warn(dev, "failed to enable device -- probing anyway\n"); |
|---|
| 912 | 939 | |
|---|
| 913 | 940 | if (wdriver->probe) { |
|---|
| 914 | | - ret = wdriver->probe(dev_to_wdev(dev)); |
|---|
| 941 | + ret = wdriver->probe(dev_to_wdev(dev), |
|---|
| 942 | + find_guid_context(wblock, wdriver)); |
|---|
| 915 | 943 | if (ret != 0) |
|---|
| 916 | 944 | goto probe_failure; |
|---|
| 917 | 945 | } |
|---|
| .. | .. |
|---|
| 997 | 1025 | .remove = wmi_dev_remove, |
|---|
| 998 | 1026 | }; |
|---|
| 999 | 1027 | |
|---|
| 1000 | | -static struct device_type wmi_type_event = { |
|---|
| 1028 | +static const struct device_type wmi_type_event = { |
|---|
| 1001 | 1029 | .name = "event", |
|---|
| 1002 | 1030 | .groups = wmi_event_groups, |
|---|
| 1003 | 1031 | .release = wmi_dev_release, |
|---|
| 1004 | 1032 | }; |
|---|
| 1005 | 1033 | |
|---|
| 1006 | | -static struct device_type wmi_type_method = { |
|---|
| 1034 | +static const struct device_type wmi_type_method = { |
|---|
| 1007 | 1035 | .name = "method", |
|---|
| 1008 | 1036 | .groups = wmi_method_groups, |
|---|
| 1009 | 1037 | .release = wmi_dev_release, |
|---|
| 1010 | 1038 | }; |
|---|
| 1011 | 1039 | |
|---|
| 1012 | | -static struct device_type wmi_type_data = { |
|---|
| 1040 | +static const struct device_type wmi_type_data = { |
|---|
| 1013 | 1041 | .name = "data", |
|---|
| 1014 | 1042 | .groups = wmi_data_groups, |
|---|
| 1015 | 1043 | .release = wmi_dev_release, |
|---|
| 1016 | 1044 | }; |
|---|
| 1017 | 1045 | |
|---|
| 1018 | 1046 | static int wmi_create_device(struct device *wmi_bus_dev, |
|---|
| 1019 | | - const struct guid_block *gblock, |
|---|
| 1020 | 1047 | struct wmi_block *wblock, |
|---|
| 1021 | 1048 | struct acpi_device *device) |
|---|
| 1022 | 1049 | { |
|---|
| .. | .. |
|---|
| 1024 | 1051 | char method[5]; |
|---|
| 1025 | 1052 | int result; |
|---|
| 1026 | 1053 | |
|---|
| 1027 | | - if (gblock->flags & ACPI_WMI_EVENT) { |
|---|
| 1054 | + if (wblock->gblock.flags & ACPI_WMI_EVENT) { |
|---|
| 1028 | 1055 | wblock->dev.dev.type = &wmi_type_event; |
|---|
| 1029 | 1056 | goto out_init; |
|---|
| 1030 | 1057 | } |
|---|
| 1031 | 1058 | |
|---|
| 1032 | | - if (gblock->flags & ACPI_WMI_METHOD) { |
|---|
| 1059 | + if (wblock->gblock.flags & ACPI_WMI_METHOD) { |
|---|
| 1033 | 1060 | wblock->dev.dev.type = &wmi_type_method; |
|---|
| 1034 | 1061 | mutex_init(&wblock->char_mutex); |
|---|
| 1035 | 1062 | goto out_init; |
|---|
| .. | .. |
|---|
| 1079 | 1106 | wblock->dev.dev.bus = &wmi_bus_type; |
|---|
| 1080 | 1107 | wblock->dev.dev.parent = wmi_bus_dev; |
|---|
| 1081 | 1108 | |
|---|
| 1082 | | - dev_set_name(&wblock->dev.dev, "%pUL", gblock->guid); |
|---|
| 1109 | + dev_set_name(&wblock->dev.dev, "%pUL", &wblock->gblock.guid); |
|---|
| 1083 | 1110 | |
|---|
| 1084 | 1111 | device_initialize(&wblock->dev.dev); |
|---|
| 1085 | 1112 | |
|---|
| .. | .. |
|---|
| 1099 | 1126 | } |
|---|
| 1100 | 1127 | } |
|---|
| 1101 | 1128 | |
|---|
| 1102 | | -static bool guid_already_parsed(struct acpi_device *device, |
|---|
| 1103 | | - const u8 *guid) |
|---|
| 1129 | +static bool guid_already_parsed(struct acpi_device *device, const guid_t *guid) |
|---|
| 1104 | 1130 | { |
|---|
| 1105 | 1131 | struct wmi_block *wblock; |
|---|
| 1106 | 1132 | |
|---|
| 1107 | 1133 | list_for_each_entry(wblock, &wmi_block_list, list) { |
|---|
| 1108 | | - if (memcmp(wblock->gblock.guid, guid, 16) == 0) { |
|---|
| 1134 | + if (guid_equal(&wblock->gblock.guid, guid)) { |
|---|
| 1109 | 1135 | /* |
|---|
| 1110 | 1136 | * Because we historically didn't track the relationship |
|---|
| 1111 | 1137 | * between GUIDs and ACPI nodes, we don't know whether |
|---|
| .. | .. |
|---|
| 1160 | 1186 | * case yet, so for now, we'll just ignore the duplicate |
|---|
| 1161 | 1187 | * for device creation. |
|---|
| 1162 | 1188 | */ |
|---|
| 1163 | | - if (guid_already_parsed(device, gblock[i].guid)) |
|---|
| 1189 | + if (guid_already_parsed(device, &gblock[i].guid)) |
|---|
| 1164 | 1190 | continue; |
|---|
| 1165 | 1191 | |
|---|
| 1166 | 1192 | wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 1172 | 1198 | wblock->acpi_device = device; |
|---|
| 1173 | 1199 | wblock->gblock = gblock[i]; |
|---|
| 1174 | 1200 | |
|---|
| 1175 | | - retval = wmi_create_device(wmi_bus_dev, &gblock[i], wblock, device); |
|---|
| 1201 | + retval = wmi_create_device(wmi_bus_dev, wblock, device); |
|---|
| 1176 | 1202 | if (retval) { |
|---|
| 1177 | 1203 | kfree(wblock); |
|---|
| 1178 | 1204 | continue; |
|---|
| .. | .. |
|---|
| 1197 | 1223 | retval = device_add(&wblock->dev.dev); |
|---|
| 1198 | 1224 | if (retval) { |
|---|
| 1199 | 1225 | dev_err(wmi_bus_dev, "failed to register %pUL\n", |
|---|
| 1200 | | - wblock->gblock.guid); |
|---|
| 1226 | + &wblock->gblock.guid); |
|---|
| 1201 | 1227 | if (debug_event) |
|---|
| 1202 | 1228 | wmi_method_enable(wblock, 0); |
|---|
| 1203 | 1229 | list_del(&wblock->list); |
|---|
| .. | .. |
|---|
| 1257 | 1283 | static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, |
|---|
| 1258 | 1284 | void *context) |
|---|
| 1259 | 1285 | { |
|---|
| 1260 | | - struct guid_block *block; |
|---|
| 1261 | 1286 | struct wmi_block *wblock; |
|---|
| 1262 | 1287 | bool found_it = false; |
|---|
| 1263 | 1288 | |
|---|
| 1264 | 1289 | list_for_each_entry(wblock, &wmi_block_list, list) { |
|---|
| 1265 | | - block = &wblock->gblock; |
|---|
| 1290 | + struct guid_block *block = &wblock->gblock; |
|---|
| 1266 | 1291 | |
|---|
| 1267 | 1292 | if (wblock->acpi_device->handle == handle && |
|---|
| 1268 | 1293 | (block->flags & ACPI_WMI_EVENT) && |
|---|
| .. | .. |
|---|
| 1310 | 1335 | wblock->handler(event, wblock->handler_data); |
|---|
| 1311 | 1336 | } |
|---|
| 1312 | 1337 | |
|---|
| 1313 | | - if (debug_event) { |
|---|
| 1314 | | - pr_info("DEBUG Event GUID: %pUL\n", |
|---|
| 1315 | | - wblock->gblock.guid); |
|---|
| 1316 | | - } |
|---|
| 1338 | + if (debug_event) |
|---|
| 1339 | + pr_info("DEBUG Event GUID: %pUL\n", &wblock->gblock.guid); |
|---|
| 1317 | 1340 | |
|---|
| 1318 | 1341 | acpi_bus_generate_netlink_event( |
|---|
| 1319 | 1342 | wblock->acpi_device->pnp.device_class, |
|---|