RE: [PATCH] platform/x86: thinkpad_acpi: disable bluetooth for some machines

From: David Laight
Date: Thu Mar 07 2019 - 11:59:55 EST


From: Jiaxun Yang
> Sent: 07 March 2019 08:08
...
> +static int __init have_bt_fwbug(void)
> +{
> + /* Some AMD based ThinkPads have a firmware bug that calling
> + * "GBDC" will cause bluetooth on Intel wireless cards blocked
> + */
> + if (dmi_check_system(bt_fwbug_list)) {
> + if (pci_get_device(PCI_VENDOR_ID_INTEL, 0x24F3, NULL) || \

WTF if that \ ??

> + pci_get_device(PCI_VENDOR_ID_INTEL, 0x24FD, NULL) || \
> + pci_get_device(PCI_VENDOR_ID_INTEL, 0x2526, NULL))
> + return 1;
> + else
> + return 0;
> + } else {
> + return 0;
> + }
> +}

You don't need 'else' after a 'return'.
I'd also put the return nearer the test.

While the above could be written:
return dmi_check_system(bt_fwbug_list) &&
(pci_get_device(PCI_VENDOR_ID_INTEL, 0x24F3, NULL) ||
pci_get_device(PCI_VENDOR_ID_INTEL, 0x24FD, NULL) ||
pci_get_device(PCI_VENDOR_ID_INTEL, 0x2526, NULL));

I think I'd write:
if (!dmi_check_system(bt_fwbug_list))
return 0;
return pci_get_device(PCI_VENDOR_ID_INTEL, 0x24F3, NULL) ||
pci_get_device(PCI_VENDOR_ID_INTEL, 0x24FD, NULL) ||
pci_get_device(PCI_VENDOR_ID_INTEL, 0x2526, NULL);

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)