Skip to contentSkip to conversation

Bluetooth: Use switch statement for Intel hardware variants

PATCH In review Tedd Ho-Jeong An 2 participants 2 messages Mar 6, 2017 – Mar 27, 2017 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Bluetooth: Use switch statement for Intel hardware variants

From: Tedd Ho-Jeong An <[email protected]>

Multiple new hardware variants are planned and the simple if statement would get really complicated and unreadable. So instead replace it with a simple switch statement.

The change is applied to both USB and UART.

---
 drivers/bluetooth/btusb.c     | 10 +++++++---
 drivers/bluetooth/hci_intel.c | 17 +++++++++++------
 2 files changed, 18 insertions(+), 9 deletions(-)
drivers/bluetooth/btusb.c +7 -3
index 1c8094e..348cf93 100644
@@ -2024,13 +2024,17 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
 		return -EINVAL;
 	}
 
-	/* At the moment the iBT 3.0 hardware variants 0x0b (LnP/SfP)
-	 * and 0x0c (WsP) are supported by this firmware loading method.
+	/* Check for supported iBT hardware variants of this firmware
+	 * loading method.
 	 *
 	 * This check has been put in place to ensure correct forward
 	 * compatibility options when newer hardware variants come along.
 	 */
-	if (ver.hw_variant != 0x0b && ver.hw_variant != 0x0c) {
+	switch (ver.hw_variant) {
+	case 0x0b:	/* 8260 SfP */
+	case 0x0c:	/* 8265 WsP */
+		break;
+	default:
 		BT_ERR("%s: Unsupported Intel hardware variant (%u)",
 		       hdev->name, ver.hw_variant);
 		return -EINVAL;
drivers/bluetooth/hci_intel.c +11 -6
index 9e27128..351e868 100644
@@ -601,12 +601,17 @@ static int intel_setup(struct hci_uart *hu)
 		return -EINVAL;
 	}
 
-	/* At the moment only the hardware variant iBT 3.0 (LnP/SfP) is
-	 * supported by this firmware loading method. This check has been
-	 * put in place to ensure correct forward compatibility options
-	 * when newer hardware variants come along.
-	 */
-	if (ver.hw_variant != 0x0b) {
+        /* Check for supported iBT hardware variants of this firmware
+         * loading method.
+         *
+         * This check has been put in place to ensure correct forward
+         * compatibility options when newer hardware variants come along.
+         */
+	switch (ver.hw_variant) {
+	case 0x0b:	/* 8260 LnP */
+	case 0x0c:	/* 8260 WsP */
+		break;
+	default:
 		bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)",
 			   ver.hw_variant);
 		return -EINVAL;
Signature · 1 line
2.7.4
maintainer
#1 lore raw

Hi Tedd,

Quoted 4 lines

Multiple new hardware variants are planned and the simple if statement would get really complicated and unreadable. So instead replace it with a simple switch statement.

Quoted 8 lines

The change is applied to both USB and UART.

---
drivers/bluetooth/btusb.c | 10 +++++++---
drivers/bluetooth/hci_intel.c | 17 +++++++++++------

2 files changed, 18 insertions(+), 9 deletions(-)

all 4 patches have been applied to bluetooth-next tree.

Regards

Marcel