Skip to content

Commit 294d749

Browse files
kirankrishnappa-intelVudentz
authored andcommitted
Bluetooth: btintel: Iterate only bluetooth device ACPI entries
Current flow interates over entire ACPI table entries looking for Bluetooth Per Platform Antenna Gain(PPAG) entry. This patch iterates over ACPI entries relvant to Bluetooth device only. Fixes: c585a92 ("Bluetooth: btintel: Set Per Platform Antenna Gain(PPAG)") Signed-off-by: Kiran K <kiran.k@intel.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 2f10e40 commit 294d749

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

drivers/bluetooth/btintel.c

+26-18
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@
2626
#define ECDSA_HEADER_LEN 320
2727

2828
#define BTINTEL_PPAG_NAME "PPAG"
29-
#define BTINTEL_PPAG_PREFIX "\\_SB_.PCI0.XHCI.RHUB"
29+
30+
/* structure to store the PPAG data read from ACPI table */
31+
struct btintel_ppag {
32+
u32 domain;
33+
u32 mode;
34+
acpi_status status;
35+
struct hci_dev *hdev;
36+
};
3037

3138
#define CMD_WRITE_BOOT_PARAMS 0xfc0e
3239
struct cmd_write_boot_params {
@@ -1295,17 +1302,16 @@ static acpi_status btintel_ppag_callback(acpi_handle handle, u32 lvl, void *data
12951302

12961303
status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
12971304
if (ACPI_FAILURE(status)) {
1298-
bt_dev_warn(hdev, "ACPI Failure: %s", acpi_format_exception(status));
1305+
bt_dev_warn(hdev, "PPAG-BT: ACPI Failure: %s", acpi_format_exception(status));
12991306
return status;
13001307
}
13011308

1302-
if (strncmp(BTINTEL_PPAG_PREFIX, string.pointer,
1303-
strlen(BTINTEL_PPAG_PREFIX))) {
1309+
len = strlen(string.pointer);
1310+
if (len < strlen(BTINTEL_PPAG_NAME)) {
13041311
kfree(string.pointer);
13051312
return AE_OK;
13061313
}
13071314

1308-
len = strlen(string.pointer);
13091315
if (strncmp((char *)string.pointer + len - 4, BTINTEL_PPAG_NAME, 4)) {
13101316
kfree(string.pointer);
13111317
return AE_OK;
@@ -1314,7 +1320,8 @@ static acpi_status btintel_ppag_callback(acpi_handle handle, u32 lvl, void *data
13141320

13151321
status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
13161322
if (ACPI_FAILURE(status)) {
1317-
bt_dev_warn(hdev, "ACPI Failure: %s", acpi_format_exception(status));
1323+
ppag->status = status;
1324+
bt_dev_warn(hdev, "PPAG-BT: ACPI Failure: %s", acpi_format_exception(status));
13181325
return status;
13191326
}
13201327

@@ -1323,8 +1330,9 @@ static acpi_status btintel_ppag_callback(acpi_handle handle, u32 lvl, void *data
13231330

13241331
if (p->type != ACPI_TYPE_PACKAGE || p->package.count != 2) {
13251332
kfree(buffer.pointer);
1326-
bt_dev_warn(hdev, "Invalid object type: %d or package count: %d",
1333+
bt_dev_warn(hdev, "PPAG-BT: Invalid object type: %d or package count: %d",
13271334
p->type, p->package.count);
1335+
ppag->status = AE_ERROR;
13281336
return AE_ERROR;
13291337
}
13301338

@@ -1335,6 +1343,7 @@ static acpi_status btintel_ppag_callback(acpi_handle handle, u32 lvl, void *data
13351343

13361344
ppag->domain = (u32)p->package.elements[0].integer.value;
13371345
ppag->mode = (u32)p->package.elements[1].integer.value;
1346+
ppag->status = AE_OK;
13381347
kfree(buffer.pointer);
13391348
return AE_CTRL_TERMINATE;
13401349
}
@@ -2314,12 +2323,11 @@ static int btintel_configure_offload(struct hci_dev *hdev)
23142323

23152324
static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver)
23162325
{
2317-
acpi_status status;
23182326
struct btintel_ppag ppag;
23192327
struct sk_buff *skb;
23202328
struct btintel_loc_aware_reg ppag_cmd;
23212329

2322-
/* PPAG is not supported if CRF is HrP2, Jfp2, JfP1 */
2330+
/* PPAG is not supported if CRF is HrP2, Jfp2, JfP1 */
23232331
switch (ver->cnvr_top & 0xFFF) {
23242332
case 0x504: /* Hrp2 */
23252333
case 0x202: /* Jfp2 */
@@ -2330,26 +2338,26 @@ static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver
23302338
memset(&ppag, 0, sizeof(ppag));
23312339

23322340
ppag.hdev = hdev;
2333-
status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
2334-
ACPI_UINT32_MAX, NULL,
2335-
btintel_ppag_callback, &ppag, NULL);
2341+
ppag.status = AE_NOT_FOUND;
2342+
acpi_walk_namespace(ACPI_TYPE_PACKAGE, ACPI_HANDLE(GET_HCIDEV_DEV(hdev)),
2343+
1, NULL, btintel_ppag_callback, &ppag, NULL);
23362344

2337-
if (ACPI_FAILURE(status)) {
2338-
/* Do not log warning message if ACPI entry is not found */
2339-
if (status == AE_NOT_FOUND)
2345+
if (ACPI_FAILURE(ppag.status)) {
2346+
if (ppag.status == AE_NOT_FOUND) {
2347+
bt_dev_dbg(hdev, "PPAG-BT: ACPI entry not found");
23402348
return;
2341-
bt_dev_warn(hdev, "PPAG: ACPI Failure: %s", acpi_format_exception(status));
2349+
}
23422350
return;
23432351
}
23442352

23452353
if (ppag.domain != 0x12) {
2346-
bt_dev_warn(hdev, "PPAG-BT Domain disabled");
2354+
bt_dev_warn(hdev, "PPAG-BT: domain is not bluetooth");
23472355
return;
23482356
}
23492357

23502358
/* PPAG mode, BIT0 = 0 Disabled, BIT0 = 1 Enabled */
23512359
if (!(ppag.mode & BIT(0))) {
2352-
bt_dev_dbg(hdev, "PPAG disabled");
2360+
bt_dev_dbg(hdev, "PPAG-BT: disabled");
23532361
return;
23542362
}
23552363

drivers/bluetooth/btintel.h

-7
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,6 @@ struct intel_offload_use_cases {
137137
__u8 preset[8];
138138
} __packed;
139139

140-
/* structure to store the PPAG data read from ACPI table */
141-
struct btintel_ppag {
142-
u32 domain;
143-
u32 mode;
144-
struct hci_dev *hdev;
145-
};
146-
147140
struct btintel_loc_aware_reg {
148141
__le32 mcc;
149142
__le32 sel;

include/net/bluetooth/hci_core.h

+1
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,7 @@ void hci_conn_add_sysfs(struct hci_conn *conn);
16131613
void hci_conn_del_sysfs(struct hci_conn *conn);
16141614

16151615
#define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev))
1616+
#define GET_HCIDEV_DEV(hdev) ((hdev)->dev.parent)
16161617

16171618
/* ----- LMP capabilities ----- */
16181619
#define lmp_encrypt_capable(dev) ((dev)->features[0][0] & LMP_ENCRYPT)

0 commit comments

Comments
 (0)