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

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: c585a92b2f9c ("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>

authored by

Kiran K and committed by
Luiz Augusto von Dentz
294d749b 2f10e40a

+27 -25
+26 -18
drivers/bluetooth/btintel.c
··· 26 26 #define ECDSA_HEADER_LEN 320 27 27 28 28 #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 + }; 30 37 31 38 #define CMD_WRITE_BOOT_PARAMS 0xfc0e 32 39 struct cmd_write_boot_params { ··· 1302 1295 1303 1296 status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); 1304 1297 if (ACPI_FAILURE(status)) { 1305 - bt_dev_warn(hdev, "ACPI Failure: %s", acpi_format_exception(status)); 1298 + bt_dev_warn(hdev, "PPAG-BT: ACPI Failure: %s", acpi_format_exception(status)); 1306 1299 return status; 1307 1300 } 1308 1301 1309 - if (strncmp(BTINTEL_PPAG_PREFIX, string.pointer, 1310 - strlen(BTINTEL_PPAG_PREFIX))) { 1302 + len = strlen(string.pointer); 1303 + if (len < strlen(BTINTEL_PPAG_NAME)) { 1311 1304 kfree(string.pointer); 1312 1305 return AE_OK; 1313 1306 } 1314 1307 1315 - len = strlen(string.pointer); 1316 1308 if (strncmp((char *)string.pointer + len - 4, BTINTEL_PPAG_NAME, 4)) { 1317 1309 kfree(string.pointer); 1318 1310 return AE_OK; ··· 1320 1314 1321 1315 status = acpi_evaluate_object(handle, NULL, NULL, &buffer); 1322 1316 if (ACPI_FAILURE(status)) { 1323 - bt_dev_warn(hdev, "ACPI Failure: %s", acpi_format_exception(status)); 1317 + ppag->status = status; 1318 + bt_dev_warn(hdev, "PPAG-BT: ACPI Failure: %s", acpi_format_exception(status)); 1324 1319 return status; 1325 1320 } 1326 1321 ··· 1330 1323 1331 1324 if (p->type != ACPI_TYPE_PACKAGE || p->package.count != 2) { 1332 1325 kfree(buffer.pointer); 1333 - bt_dev_warn(hdev, "Invalid object type: %d or package count: %d", 1326 + bt_dev_warn(hdev, "PPAG-BT: Invalid object type: %d or package count: %d", 1334 1327 p->type, p->package.count); 1328 + ppag->status = AE_ERROR; 1335 1329 return AE_ERROR; 1336 1330 } 1337 1331 ··· 1343 1335 1344 1336 ppag->domain = (u32)p->package.elements[0].integer.value; 1345 1337 ppag->mode = (u32)p->package.elements[1].integer.value; 1338 + ppag->status = AE_OK; 1346 1339 kfree(buffer.pointer); 1347 1340 return AE_CTRL_TERMINATE; 1348 1341 } ··· 2323 2314 2324 2315 static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver) 2325 2316 { 2326 - acpi_status status; 2327 2317 struct btintel_ppag ppag; 2328 2318 struct sk_buff *skb; 2329 2319 struct btintel_loc_aware_reg ppag_cmd; 2330 2320 2331 - /* PPAG is not supported if CRF is HrP2, Jfp2, JfP1 */ 2321 + /* PPAG is not supported if CRF is HrP2, Jfp2, JfP1 */ 2332 2322 switch (ver->cnvr_top & 0xFFF) { 2333 2323 case 0x504: /* Hrp2 */ 2334 2324 case 0x202: /* Jfp2 */ ··· 2338 2330 memset(&ppag, 0, sizeof(ppag)); 2339 2331 2340 2332 ppag.hdev = hdev; 2341 - status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 2342 - ACPI_UINT32_MAX, NULL, 2343 - btintel_ppag_callback, &ppag, NULL); 2333 + ppag.status = AE_NOT_FOUND; 2334 + acpi_walk_namespace(ACPI_TYPE_PACKAGE, ACPI_HANDLE(GET_HCIDEV_DEV(hdev)), 2335 + 1, NULL, btintel_ppag_callback, &ppag, NULL); 2344 2336 2345 - if (ACPI_FAILURE(status)) { 2346 - /* Do not log warning message if ACPI entry is not found */ 2347 - if (status == AE_NOT_FOUND) 2337 + if (ACPI_FAILURE(ppag.status)) { 2338 + if (ppag.status == AE_NOT_FOUND) { 2339 + bt_dev_dbg(hdev, "PPAG-BT: ACPI entry not found"); 2348 2340 return; 2349 - bt_dev_warn(hdev, "PPAG: ACPI Failure: %s", acpi_format_exception(status)); 2341 + } 2350 2342 return; 2351 2343 } 2352 2344 2353 2345 if (ppag.domain != 0x12) { 2354 - bt_dev_warn(hdev, "PPAG-BT Domain disabled"); 2346 + bt_dev_warn(hdev, "PPAG-BT: domain is not bluetooth"); 2355 2347 return; 2356 2348 } 2357 2349 2358 2350 /* PPAG mode, BIT0 = 0 Disabled, BIT0 = 1 Enabled */ 2359 2351 if (!(ppag.mode & BIT(0))) { 2360 - bt_dev_dbg(hdev, "PPAG disabled"); 2352 + bt_dev_dbg(hdev, "PPAG-BT: disabled"); 2361 2353 return; 2362 2354 } 2363 2355
-7
drivers/bluetooth/btintel.h
··· 137 137 __u8 preset[8]; 138 138 } __packed; 139 139 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 - 147 140 struct btintel_loc_aware_reg { 148 141 __le32 mcc; 149 142 __le32 sel;
+1
include/net/bluetooth/hci_core.h
··· 1613 1613 void hci_conn_del_sysfs(struct hci_conn *conn); 1614 1614 1615 1615 #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev)) 1616 + #define GET_HCIDEV_DEV(hdev) ((hdev)->dev.parent) 1616 1617 1617 1618 /* ----- LMP capabilities ----- */ 1618 1619 #define lmp_encrypt_capable(dev) ((dev)->features[0][0] & LMP_ENCRYPT)