Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: intel-ish-hid: fix module device-id handling

A late addititon to the intel-ish-hid framework caused a build failure
with clang, and introduced an ABI to the module loader that stops working
if any driver ever needs to bind to more than one UUID:

drivers/hid/intel-ish-hid/ishtp-fw-loader.c:1067:4: error: initializer element is not a compile-time constant

Change the ishtp_device_id to have correct documentation and a driver_data
field like all the other ones, and change the drivers to use the ID table
as the primary identification in a way that works with all compilers
and avoids duplciating the identifiers.

Fixes: f155dfeaa4ee ("platform/x86: isthp_eclite: only load for matching devices")
Fixes: facfe0a4fdce ("platform/chrome: chros_ec_ishtp: only load for matching devices")
Fixes: 0d0cccc0fd83 ("HID: intel-ish-hid: hid-client: only load for matching devices")
Fixes: 44e2a58cb880 ("HID: intel-ish-hid: fw-loader: only load for matching devices")
Fixes: cb1a2c6847f7 ("HID: intel-ish-hid: use constants for modaliases")
Fixes: fa443bc3c1e4 ("HID: intel-ish-hid: add support for MODULE_DEVICE_TABLE()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
[jkosina@suse.cz: fix ecl_ishtp_cl_driver.id initialization]
[jkosina@suse.cz: fix conflict with already fixed kerneldoc]
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Arnd Bergmann and committed by
Jiri Kosina
bf9167a8 64355db3

+37 -47
+8 -11
drivers/hid/intel-ish-hid/ishtp-fw-loader.c
··· 76 76 #define LOADER_XFER_MODE_ISHTP BIT(1) 77 77 78 78 /* ISH Transport Loader client unique GUID */ 79 - static const guid_t loader_ishtp_guid = 80 - GUID_INIT(0xc804d06a, 0x55bd, 0x4ea7, 81 - 0xad, 0xed, 0x1e, 0x31, 0x22, 0x8c, 0x76, 0xdc); 79 + static const struct ishtp_device_id loader_ishtp_id_table[] = { 80 + { .guid = GUID_INIT(0xc804d06a, 0x55bd, 0x4ea7, 81 + 0xad, 0xed, 0x1e, 0x31, 0x22, 0x8c, 0x76, 0xdc) }, 82 + { } 83 + }; 84 + MODULE_DEVICE_TABLE(ishtp, loader_ishtp_id_table); 82 85 83 86 #define FILENAME_SIZE 256 84 87 ··· 883 880 884 881 fw_client = 885 882 ishtp_fw_cl_get_client(ishtp_get_ishtp_device(loader_ishtp_cl), 886 - &loader_ishtp_guid); 883 + &loader_ishtp_id_table[0].guid); 887 884 if (!fw_client) { 888 885 dev_err(cl_data_to_dev(client_data), 889 886 "ISH client uuid not found\n"); ··· 1060 1057 1061 1058 static struct ishtp_cl_driver loader_ishtp_cl_driver = { 1062 1059 .name = "ish-loader", 1063 - .guid = &loader_ishtp_guid, 1060 + .id = loader_ishtp_id_table, 1064 1061 .probe = loader_ishtp_cl_probe, 1065 1062 .remove = loader_ishtp_cl_remove, 1066 1063 .reset = loader_ishtp_cl_reset, 1067 1064 }; 1068 - 1069 - static const struct ishtp_device_id loader_ishtp_id_table[] = { 1070 - { loader_ishtp_guid }, 1071 - { } 1072 - }; 1073 - MODULE_DEVICE_TABLE(ishtp, loader_ishtp_id_table); 1074 1065 1075 1066 static int __init ish_loader_init(void) 1076 1067 {
+8 -11
drivers/hid/intel-ish-hid/ishtp-hid-client.c
··· 12 12 #include "ishtp-hid.h" 13 13 14 14 /* ISH Transport protocol (ISHTP in short) GUID */ 15 - static const guid_t hid_ishtp_guid = 16 - GUID_INIT(0x33AECD58, 0xB679, 0x4E54, 17 - 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26); 15 + static const struct ishtp_device_id hid_ishtp_id_table[] = { 16 + { .guid = GUID_INIT(0x33AECD58, 0xB679, 0x4E54, 17 + 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26), }, 18 + { } 19 + }; 20 + MODULE_DEVICE_TABLE(ishtp, hid_ishtp_id_table); 18 21 19 22 /* Rx ring buffer pool size */ 20 23 #define HID_CL_RX_RING_SIZE 32 ··· 665 662 ishtp_set_tx_ring_size(hid_ishtp_cl, HID_CL_TX_RING_SIZE); 666 663 ishtp_set_rx_ring_size(hid_ishtp_cl, HID_CL_RX_RING_SIZE); 667 664 668 - fw_client = ishtp_fw_cl_get_client(dev, &hid_ishtp_guid); 665 + fw_client = ishtp_fw_cl_get_client(dev, &hid_ishtp_id_table[0].guid); 669 666 if (!fw_client) { 670 667 dev_err(cl_data_to_dev(client_data), 671 668 "ish client uuid not found\n"); ··· 948 945 949 946 static struct ishtp_cl_driver hid_ishtp_cl_driver = { 950 947 .name = "ish-hid", 951 - .guid = &hid_ishtp_guid, 948 + .id = hid_ishtp_id_table, 952 949 .probe = hid_ishtp_cl_probe, 953 950 .remove = hid_ishtp_cl_remove, 954 951 .reset = hid_ishtp_cl_reset, 955 952 .driver.pm = &hid_ishtp_pm_ops, 956 953 }; 957 - 958 - static const struct ishtp_device_id hid_ishtp_id_table[] = { 959 - { hid_ishtp_guid }, 960 - { } 961 - }; 962 - MODULE_DEVICE_TABLE(ishtp, hid_ishtp_id_table); 963 954 964 955 static int __init ish_hid_init(void) 965 956 {
+1 -1
drivers/hid/intel-ish-hid/ishtp/bus.c
··· 241 241 struct ishtp_cl_device *device = to_ishtp_cl_device(dev); 242 242 struct ishtp_cl_driver *driver = to_ishtp_cl_driver(drv); 243 243 244 - return guid_equal(driver->guid, 244 + return guid_equal(&driver->id[0].guid, 245 245 &device->fw_client->props.protocol_name); 246 246 } 247 247
+8 -11
drivers/platform/chrome/cros_ec_ishtp.c
··· 41 41 #define ISHTP_SEND_TIMEOUT (3 * HZ) 42 42 43 43 /* ISH Transport CrOS EC ISH client unique GUID */ 44 - static const guid_t cros_ish_guid = 45 - GUID_INIT(0x7b7154d0, 0x56f4, 0x4bdc, 46 - 0xb0, 0xd8, 0x9e, 0x7c, 0xda, 0xe0, 0xd6, 0xa0); 44 + static const struct ishtp_device_id cros_ec_ishtp_id_table[] = { 45 + { .guid = GUID_INIT(0x7b7154d0, 0x56f4, 0x4bdc, 46 + 0xb0, 0xd8, 0x9e, 0x7c, 0xda, 0xe0, 0xd6, 0xa0), }, 47 + { } 48 + }; 49 + MODULE_DEVICE_TABLE(ishtp, cros_ec_ishtp_id_table); 47 50 48 51 struct header { 49 52 u8 channel; ··· 392 389 ishtp_set_tx_ring_size(cros_ish_cl, CROS_ISH_CL_TX_RING_SIZE); 393 390 ishtp_set_rx_ring_size(cros_ish_cl, CROS_ISH_CL_RX_RING_SIZE); 394 391 395 - fw_client = ishtp_fw_cl_get_client(dev, &cros_ish_guid); 392 + fw_client = ishtp_fw_cl_get_client(dev, &cros_ec_ishtp_id_table[0].guid); 396 393 if (!fw_client) { 397 394 dev_err(cl_data_to_dev(client_data), 398 395 "ish client uuid not found\n"); ··· 768 765 769 766 static struct ishtp_cl_driver cros_ec_ishtp_driver = { 770 767 .name = "cros_ec_ishtp", 771 - .guid = &cros_ish_guid, 768 + .id = cros_ec_ishtp_id_table, 772 769 .probe = cros_ec_ishtp_probe, 773 770 .remove = cros_ec_ishtp_remove, 774 771 .reset = cros_ec_ishtp_reset, ··· 776 773 .pm = &cros_ec_ishtp_pm_ops, 777 774 }, 778 775 }; 779 - 780 - static const struct ishtp_device_id cros_ec_ishtp_id_table[] = { 781 - { cros_ish_guid }, 782 - { } 783 - }; 784 - MODULE_DEVICE_TABLE(ishtp, cros_ec_ishtp_id_table); 785 776 786 777 static int __init cros_ec_ishtp_mod_init(void) 787 778 {
+8 -11
drivers/platform/x86/intel/ishtp_eclite.c
··· 93 93 }; 94 94 95 95 /* eclite ishtp client UUID: 6a19cc4b-d760-4de3-b14d-f25ebd0fbcd9 */ 96 - static const guid_t ecl_ishtp_guid = 97 - GUID_INIT(0x6a19cc4b, 0xd760, 0x4de3, 98 - 0xb1, 0x4d, 0xf2, 0x5e, 0xbd, 0xf, 0xbc, 0xd9); 96 + static const struct ishtp_device_id ecl_ishtp_id_table[] = { 97 + { .guid = GUID_INIT(0x6a19cc4b, 0xd760, 0x4de3, 98 + 0xb1, 0x4d, 0xf2, 0x5e, 0xbd, 0xf, 0xbc, 0xd9), }, 99 + { } 100 + }; 101 + MODULE_DEVICE_TABLE(ishtp, ecl_ishtp_id_table); 99 102 100 103 /* ACPI DSM UUID: 91d936a7-1f01-49c6-a6b4-72f00ad8d8a5 */ 101 104 static const guid_t ecl_acpi_guid = ··· 465 462 ishtp_set_tx_ring_size(ecl_ishtp_cl, ECL_CL_TX_RING_SIZE); 466 463 ishtp_set_rx_ring_size(ecl_ishtp_cl, ECL_CL_RX_RING_SIZE); 467 464 468 - fw_client = ishtp_fw_cl_get_client(dev, &ecl_ishtp_guid); 465 + fw_client = ishtp_fw_cl_get_client(dev, &ecl_ishtp_id_table[0].guid); 469 466 if (!fw_client) { 470 467 dev_err(cl_data_to_dev(opr_dev), "fw client not found\n"); 471 468 return -ENOENT; ··· 677 674 678 675 static struct ishtp_cl_driver ecl_ishtp_cl_driver = { 679 676 .name = "ishtp-eclite", 680 - .guid = &ecl_ishtp_guid, 677 + .id = ecl_ishtp_id_table, 681 678 .probe = ecl_ishtp_cl_probe, 682 679 .remove = ecl_ishtp_cl_remove, 683 680 .reset = ecl_ishtp_cl_reset, 684 681 .driver.pm = &ecl_ishtp_pm_ops, 685 682 }; 686 - 687 - static const struct ishtp_device_id ecl_ishtp_id_table[] = { 688 - { ecl_ishtp_guid }, 689 - { } 690 - }; 691 - MODULE_DEVICE_TABLE(ishtp, ecl_ishtp_id_table); 692 683 693 684 static int __init ecl_ishtp_init(void) 694 685 {
+2 -2
include/linux/intel-ish-client-if.h
··· 9 9 #define _INTEL_ISH_CLIENT_IF_H_ 10 10 11 11 #include <linux/device.h> 12 - #include <linux/uuid.h> 12 + #include <linux/mod_devicetable.h> 13 13 14 14 struct ishtp_cl_device; 15 15 struct ishtp_device; ··· 40 40 struct ishtp_cl_driver { 41 41 struct device_driver driver; 42 42 const char *name; 43 - const guid_t *guid; 43 + const struct ishtp_device_id *id; 44 44 int (*probe)(struct ishtp_cl_device *dev); 45 45 void (*remove)(struct ishtp_cl_device *dev); 46 46 int (*reset)(struct ishtp_cl_device *dev);
+2
include/linux/mod_devicetable.h
··· 902 902 /** 903 903 * struct ishtp_device_id - ISHTP device identifier 904 904 * @guid: GUID of the device. 905 + * @driver_data: pointer to driver specific data 905 906 */ 906 907 struct ishtp_device_id { 907 908 guid_t guid; 909 + kernel_ulong_t driver_data; 908 910 }; 909 911 910 912 #endif /* LINUX_MOD_DEVICETABLE_H */