hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/bluetooth/hci_intel.c
....@@ -1,24 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 *
34 * Bluetooth HCI UART driver for Intel devices
45 *
56 * 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
- *
227 */
238
249 #include <linux/kernel.h>
....@@ -64,7 +49,7 @@
6449 struct hci_lpm_pkt {
6550 __u8 opcode;
6651 __u8 dlen;
67
- __u8 data[0];
52
+ __u8 data[];
6853 } __packed;
6954
7055 struct intel_device {
....@@ -303,7 +288,7 @@
303288
304289 static int intel_set_power(struct hci_uart *hu, bool powered)
305290 {
306
- struct list_head *p;
291
+ struct intel_device *idev;
307292 int err = -ENODEV;
308293
309294 if (!hu->tty->dev)
....@@ -311,10 +296,7 @@
311296
312297 mutex_lock(&intel_device_list_lock);
313298
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) {
318300 /* tty device and pdev device should share the same parent
319301 * which is the UART port.
320302 */
....@@ -377,19 +359,16 @@
377359
378360 static void intel_busy_work(struct work_struct *work)
379361 {
380
- struct list_head *p;
381362 struct intel_data *intel = container_of(work, struct intel_data,
382363 busy_work);
364
+ struct intel_device *idev;
383365
384366 if (!intel->hu->tty->dev)
385367 return;
386368
387369 /* Link is busy, delay the suspend */
388370 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) {
393372 if (intel->hu->tty->dev->parent == idev->pdev->dev.parent) {
394373 pm_runtime_get(&idev->pdev->dev);
395374 pm_runtime_mark_last_busy(&idev->pdev->dev);
....@@ -548,7 +527,7 @@
548527 struct sk_buff *skb;
549528 struct intel_version ver;
550529 struct intel_boot_params params;
551
- struct list_head *p;
530
+ struct intel_device *idev;
552531 const struct firmware *fw;
553532 char fwname[64];
554533 u32 boot_param;
....@@ -599,8 +578,8 @@
599578 * is in bootloader mode or if it already has operational firmware
600579 * loaded.
601580 */
602
- err = btintel_read_version(hdev, &ver);
603
- if (err)
581
+ err = btintel_read_version(hdev, &ver);
582
+ if (err)
604583 return err;
605584
606585 /* The hardware platform number has a fixed value of 0x37 and
....@@ -708,14 +687,11 @@
708687 case 0x0b: /* SfP */
709688 case 0x0c: /* WsP */
710689 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));
713691 break;
714692 case 0x12: /* ThP */
715693 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);
719695 break;
720696 default:
721697 bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)",
....@@ -737,14 +713,11 @@
737713 case 0x0b: /* SfP */
738714 case 0x0c: /* WsP */
739715 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));
742717 break;
743718 case 0x12: /* ThP */
744719 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);
748721 break;
749722 default:
750723 bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)",
....@@ -854,13 +827,11 @@
854827 * until further LPM TX notification.
855828 */
856829 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) {
860831 if (!hu->tty->dev)
861832 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)) {
864835 set_bit(STATE_LPM_ENABLED, &intel->flags);
865836 set_bit(STATE_TX_ACTIVE, &intel->flags);
866837 }
....@@ -912,10 +883,8 @@
912883 set_bit(STATE_FIRMWARE_FAILED, &intel->flags);
913884
914885 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))
917887 wake_up_bit(&intel->flags, STATE_DOWNLOADING);
918
- }
919888
920889 /* When switching to the operational firmware the device
921890 * sends a vendor specific event indicating that the bootup
....@@ -923,10 +892,8 @@
923892 */
924893 } else if (skb->len == 9 && hdr->evt == 0xff && hdr->plen == 0x07 &&
925894 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))
928896 wake_up_bit(&intel->flags, STATE_BOOTING);
929
- }
930897 }
931898 recv:
932899 return hci_recv_frame(hdev, skb);
....@@ -963,17 +930,13 @@
963930 break;
964931 case LPM_OP_SUSPEND_ACK:
965932 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))
968934 wake_up_bit(&intel->flags, STATE_LPM_TRANSACTION);
969
- }
970935 break;
971936 case LPM_OP_RESUME_ACK:
972937 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))
975939 wake_up_bit(&intel->flags, STATE_LPM_TRANSACTION);
976
- }
977940 break;
978941 default:
979942 bt_dev_err(hdev, "Unknown LPM opcode (%02x)", lpm->opcode);
....@@ -1022,7 +985,7 @@
1022985 static int intel_enqueue(struct hci_uart *hu, struct sk_buff *skb)
1023986 {
1024987 struct intel_data *intel = hu->priv;
1025
- struct list_head *p;
988
+ struct intel_device *idev;
1026989
1027990 BT_DBG("hu %p skb %p", hu, skb);
1028991
....@@ -1033,10 +996,7 @@
1033996 * completed before enqueuing any packet.
1034997 */
1035998 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) {
10401000 if (hu->tty->dev->parent == idev->pdev->dev.parent) {
10411001 pm_runtime_get_sync(&idev->pdev->dev);
10421002 pm_runtime_mark_last_busy(&idev->pdev->dev);
....@@ -1099,7 +1059,8 @@
10991059 #ifdef CONFIG_ACPI
11001060 static const struct acpi_device_id intel_acpi_match[] = {
11011061 { "INT33E1", 0 },
1102
- { },
1062
+ { "INT33E3", 0 },
1063
+ { }
11031064 };
11041065 MODULE_DEVICE_TABLE(acpi, intel_acpi_match);
11051066 #endif
....@@ -1161,9 +1122,9 @@
11611122 static const struct acpi_gpio_params host_wake_gpios = { 1, 0, false };
11621123
11631124 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
+ { }
11671128 };
11681129
11691130 static int intel_probe(struct platform_device *pdev)
....@@ -1253,7 +1214,11 @@
12531214
12541215 int __init intel_init(void)
12551216 {
1256
- platform_driver_register(&intel_driver);
1217
+ int err;
1218
+
1219
+ err = platform_driver_register(&intel_driver);
1220
+ if (err)
1221
+ return err;
12571222
12581223 return hci_uart_register_proto(&intel_proto);
12591224 }