.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * |
---|
3 | 4 | * Bluetooth HCI UART driver for Intel devices |
---|
4 | 5 | * |
---|
5 | 6 | * Copyright (C) 2015 Intel Corporation |
---|
6 | | - * |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License as published by |
---|
10 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
11 | | - * (at your option) any later version. |
---|
12 | | - * |
---|
13 | | - * This program is distributed in the hope that it will be useful, |
---|
14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | | - * GNU General Public License for more details. |
---|
17 | | - * |
---|
18 | | - * You should have received a copy of the GNU General Public License |
---|
19 | | - * along with this program; if not, write to the Free Software |
---|
20 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
21 | | - * |
---|
22 | 7 | */ |
---|
23 | 8 | |
---|
24 | 9 | #include <linux/kernel.h> |
---|
.. | .. |
---|
64 | 49 | struct hci_lpm_pkt { |
---|
65 | 50 | __u8 opcode; |
---|
66 | 51 | __u8 dlen; |
---|
67 | | - __u8 data[0]; |
---|
| 52 | + __u8 data[]; |
---|
68 | 53 | } __packed; |
---|
69 | 54 | |
---|
70 | 55 | struct intel_device { |
---|
.. | .. |
---|
303 | 288 | |
---|
304 | 289 | static int intel_set_power(struct hci_uart *hu, bool powered) |
---|
305 | 290 | { |
---|
306 | | - struct list_head *p; |
---|
| 291 | + struct intel_device *idev; |
---|
307 | 292 | int err = -ENODEV; |
---|
308 | 293 | |
---|
309 | 294 | if (!hu->tty->dev) |
---|
.. | .. |
---|
311 | 296 | |
---|
312 | 297 | mutex_lock(&intel_device_list_lock); |
---|
313 | 298 | |
---|
314 | | - list_for_each(p, &intel_device_list) { |
---|
315 | | - struct intel_device *idev = list_entry(p, struct intel_device, |
---|
316 | | - list); |
---|
317 | | - |
---|
| 299 | + list_for_each_entry(idev, &intel_device_list, list) { |
---|
318 | 300 | /* tty device and pdev device should share the same parent |
---|
319 | 301 | * which is the UART port. |
---|
320 | 302 | */ |
---|
.. | .. |
---|
377 | 359 | |
---|
378 | 360 | static void intel_busy_work(struct work_struct *work) |
---|
379 | 361 | { |
---|
380 | | - struct list_head *p; |
---|
381 | 362 | struct intel_data *intel = container_of(work, struct intel_data, |
---|
382 | 363 | busy_work); |
---|
| 364 | + struct intel_device *idev; |
---|
383 | 365 | |
---|
384 | 366 | if (!intel->hu->tty->dev) |
---|
385 | 367 | return; |
---|
386 | 368 | |
---|
387 | 369 | /* Link is busy, delay the suspend */ |
---|
388 | 370 | mutex_lock(&intel_device_list_lock); |
---|
389 | | - list_for_each(p, &intel_device_list) { |
---|
390 | | - struct intel_device *idev = list_entry(p, struct intel_device, |
---|
391 | | - list); |
---|
392 | | - |
---|
| 371 | + list_for_each_entry(idev, &intel_device_list, list) { |
---|
393 | 372 | if (intel->hu->tty->dev->parent == idev->pdev->dev.parent) { |
---|
394 | 373 | pm_runtime_get(&idev->pdev->dev); |
---|
395 | 374 | pm_runtime_mark_last_busy(&idev->pdev->dev); |
---|
.. | .. |
---|
548 | 527 | struct sk_buff *skb; |
---|
549 | 528 | struct intel_version ver; |
---|
550 | 529 | struct intel_boot_params params; |
---|
551 | | - struct list_head *p; |
---|
| 530 | + struct intel_device *idev; |
---|
552 | 531 | const struct firmware *fw; |
---|
553 | 532 | char fwname[64]; |
---|
554 | 533 | u32 boot_param; |
---|
.. | .. |
---|
599 | 578 | * is in bootloader mode or if it already has operational firmware |
---|
600 | 579 | * loaded. |
---|
601 | 580 | */ |
---|
602 | | - err = btintel_read_version(hdev, &ver); |
---|
603 | | - if (err) |
---|
| 581 | + err = btintel_read_version(hdev, &ver); |
---|
| 582 | + if (err) |
---|
604 | 583 | return err; |
---|
605 | 584 | |
---|
606 | 585 | /* The hardware platform number has a fixed value of 0x37 and |
---|
.. | .. |
---|
708 | 687 | case 0x0b: /* SfP */ |
---|
709 | 688 | case 0x0c: /* WsP */ |
---|
710 | 689 | snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.sfi", |
---|
711 | | - le16_to_cpu(ver.hw_variant), |
---|
712 | | - le16_to_cpu(params.dev_revid)); |
---|
| 690 | + ver.hw_variant, le16_to_cpu(params.dev_revid)); |
---|
713 | 691 | break; |
---|
714 | 692 | case 0x12: /* ThP */ |
---|
715 | 693 | snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u-%u.sfi", |
---|
716 | | - le16_to_cpu(ver.hw_variant), |
---|
717 | | - le16_to_cpu(ver.hw_revision), |
---|
718 | | - le16_to_cpu(ver.fw_revision)); |
---|
| 694 | + ver.hw_variant, ver.hw_revision, ver.fw_revision); |
---|
719 | 695 | break; |
---|
720 | 696 | default: |
---|
721 | 697 | bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)", |
---|
.. | .. |
---|
737 | 713 | case 0x0b: /* SfP */ |
---|
738 | 714 | case 0x0c: /* WsP */ |
---|
739 | 715 | snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.ddc", |
---|
740 | | - le16_to_cpu(ver.hw_variant), |
---|
741 | | - le16_to_cpu(params.dev_revid)); |
---|
| 716 | + ver.hw_variant, le16_to_cpu(params.dev_revid)); |
---|
742 | 717 | break; |
---|
743 | 718 | case 0x12: /* ThP */ |
---|
744 | 719 | snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u-%u.ddc", |
---|
745 | | - le16_to_cpu(ver.hw_variant), |
---|
746 | | - le16_to_cpu(ver.hw_revision), |
---|
747 | | - le16_to_cpu(ver.fw_revision)); |
---|
| 720 | + ver.hw_variant, ver.hw_revision, ver.fw_revision); |
---|
748 | 721 | break; |
---|
749 | 722 | default: |
---|
750 | 723 | bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)", |
---|
.. | .. |
---|
854 | 827 | * until further LPM TX notification. |
---|
855 | 828 | */ |
---|
856 | 829 | mutex_lock(&intel_device_list_lock); |
---|
857 | | - list_for_each(p, &intel_device_list) { |
---|
858 | | - struct intel_device *dev = list_entry(p, struct intel_device, |
---|
859 | | - list); |
---|
| 830 | + list_for_each_entry(idev, &intel_device_list, list) { |
---|
860 | 831 | if (!hu->tty->dev) |
---|
861 | 832 | break; |
---|
862 | | - if (hu->tty->dev->parent == dev->pdev->dev.parent) { |
---|
863 | | - if (device_may_wakeup(&dev->pdev->dev)) { |
---|
| 833 | + if (hu->tty->dev->parent == idev->pdev->dev.parent) { |
---|
| 834 | + if (device_may_wakeup(&idev->pdev->dev)) { |
---|
864 | 835 | set_bit(STATE_LPM_ENABLED, &intel->flags); |
---|
865 | 836 | set_bit(STATE_TX_ACTIVE, &intel->flags); |
---|
866 | 837 | } |
---|
.. | .. |
---|
912 | 883 | set_bit(STATE_FIRMWARE_FAILED, &intel->flags); |
---|
913 | 884 | |
---|
914 | 885 | if (test_and_clear_bit(STATE_DOWNLOADING, &intel->flags) && |
---|
915 | | - test_bit(STATE_FIRMWARE_LOADED, &intel->flags)) { |
---|
916 | | - smp_mb__after_atomic(); |
---|
| 886 | + test_bit(STATE_FIRMWARE_LOADED, &intel->flags)) |
---|
917 | 887 | wake_up_bit(&intel->flags, STATE_DOWNLOADING); |
---|
918 | | - } |
---|
919 | 888 | |
---|
920 | 889 | /* When switching to the operational firmware the device |
---|
921 | 890 | * sends a vendor specific event indicating that the bootup |
---|
.. | .. |
---|
923 | 892 | */ |
---|
924 | 893 | } else if (skb->len == 9 && hdr->evt == 0xff && hdr->plen == 0x07 && |
---|
925 | 894 | skb->data[2] == 0x02) { |
---|
926 | | - if (test_and_clear_bit(STATE_BOOTING, &intel->flags)) { |
---|
927 | | - smp_mb__after_atomic(); |
---|
| 895 | + if (test_and_clear_bit(STATE_BOOTING, &intel->flags)) |
---|
928 | 896 | wake_up_bit(&intel->flags, STATE_BOOTING); |
---|
929 | | - } |
---|
930 | 897 | } |
---|
931 | 898 | recv: |
---|
932 | 899 | return hci_recv_frame(hdev, skb); |
---|
.. | .. |
---|
963 | 930 | break; |
---|
964 | 931 | case LPM_OP_SUSPEND_ACK: |
---|
965 | 932 | set_bit(STATE_SUSPENDED, &intel->flags); |
---|
966 | | - if (test_and_clear_bit(STATE_LPM_TRANSACTION, &intel->flags)) { |
---|
967 | | - smp_mb__after_atomic(); |
---|
| 933 | + if (test_and_clear_bit(STATE_LPM_TRANSACTION, &intel->flags)) |
---|
968 | 934 | wake_up_bit(&intel->flags, STATE_LPM_TRANSACTION); |
---|
969 | | - } |
---|
970 | 935 | break; |
---|
971 | 936 | case LPM_OP_RESUME_ACK: |
---|
972 | 937 | clear_bit(STATE_SUSPENDED, &intel->flags); |
---|
973 | | - if (test_and_clear_bit(STATE_LPM_TRANSACTION, &intel->flags)) { |
---|
974 | | - smp_mb__after_atomic(); |
---|
| 938 | + if (test_and_clear_bit(STATE_LPM_TRANSACTION, &intel->flags)) |
---|
975 | 939 | wake_up_bit(&intel->flags, STATE_LPM_TRANSACTION); |
---|
976 | | - } |
---|
977 | 940 | break; |
---|
978 | 941 | default: |
---|
979 | 942 | bt_dev_err(hdev, "Unknown LPM opcode (%02x)", lpm->opcode); |
---|
.. | .. |
---|
1022 | 985 | static int intel_enqueue(struct hci_uart *hu, struct sk_buff *skb) |
---|
1023 | 986 | { |
---|
1024 | 987 | struct intel_data *intel = hu->priv; |
---|
1025 | | - struct list_head *p; |
---|
| 988 | + struct intel_device *idev; |
---|
1026 | 989 | |
---|
1027 | 990 | BT_DBG("hu %p skb %p", hu, skb); |
---|
1028 | 991 | |
---|
.. | .. |
---|
1033 | 996 | * completed before enqueuing any packet. |
---|
1034 | 997 | */ |
---|
1035 | 998 | mutex_lock(&intel_device_list_lock); |
---|
1036 | | - list_for_each(p, &intel_device_list) { |
---|
1037 | | - struct intel_device *idev = list_entry(p, struct intel_device, |
---|
1038 | | - list); |
---|
1039 | | - |
---|
| 999 | + list_for_each_entry(idev, &intel_device_list, list) { |
---|
1040 | 1000 | if (hu->tty->dev->parent == idev->pdev->dev.parent) { |
---|
1041 | 1001 | pm_runtime_get_sync(&idev->pdev->dev); |
---|
1042 | 1002 | pm_runtime_mark_last_busy(&idev->pdev->dev); |
---|
.. | .. |
---|
1099 | 1059 | #ifdef CONFIG_ACPI |
---|
1100 | 1060 | static const struct acpi_device_id intel_acpi_match[] = { |
---|
1101 | 1061 | { "INT33E1", 0 }, |
---|
1102 | | - { }, |
---|
| 1062 | + { "INT33E3", 0 }, |
---|
| 1063 | + { } |
---|
1103 | 1064 | }; |
---|
1104 | 1065 | MODULE_DEVICE_TABLE(acpi, intel_acpi_match); |
---|
1105 | 1066 | #endif |
---|
.. | .. |
---|
1161 | 1122 | static const struct acpi_gpio_params host_wake_gpios = { 1, 0, false }; |
---|
1162 | 1123 | |
---|
1163 | 1124 | static const struct acpi_gpio_mapping acpi_hci_intel_gpios[] = { |
---|
1164 | | - { "reset-gpios", &reset_gpios, 1 }, |
---|
1165 | | - { "host-wake-gpios", &host_wake_gpios, 1 }, |
---|
1166 | | - { }, |
---|
| 1125 | + { "reset-gpios", &reset_gpios, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, |
---|
| 1126 | + { "host-wake-gpios", &host_wake_gpios, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, |
---|
| 1127 | + { } |
---|
1167 | 1128 | }; |
---|
1168 | 1129 | |
---|
1169 | 1130 | static int intel_probe(struct platform_device *pdev) |
---|
.. | .. |
---|
1253 | 1214 | |
---|
1254 | 1215 | int __init intel_init(void) |
---|
1255 | 1216 | { |
---|
1256 | | - platform_driver_register(&intel_driver); |
---|
| 1217 | + int err; |
---|
| 1218 | + |
---|
| 1219 | + err = platform_driver_register(&intel_driver); |
---|
| 1220 | + if (err) |
---|
| 1221 | + return err; |
---|
1257 | 1222 | |
---|
1258 | 1223 | return hci_uart_register_proto(&intel_proto); |
---|
1259 | 1224 | } |
---|