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

Bluetooth: hci_uart: Fix speed selection

hu->proto->*speed will always be used for all device where it is set.
But hu->*speed should be used if exist, so the test should be swapped.

The equivalent change is needed in bcm_setup() of hci_bcm.c.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Frederic Danis and committed by
Marcel Holtmann
960ef1d7 2a973dfa

+28 -11
+22 -5
drivers/bluetooth/hci_bcm.c
··· 131 131 { 132 132 char fw_name[64]; 133 133 const struct firmware *fw; 134 + unsigned int speed; 134 135 int err; 135 136 136 137 BT_DBG("hu %p", hu); ··· 154 153 goto finalize; 155 154 } 156 155 157 - if (hu->proto->init_speed) 158 - hci_uart_set_baudrate(hu, hu->proto->init_speed); 156 + /* Init speed if any */ 157 + if (hu->init_speed) 158 + speed = hu->init_speed; 159 + else if (hu->proto->init_speed) 160 + speed = hu->proto->init_speed; 161 + else 162 + speed = 0; 159 163 160 - if (hu->proto->oper_speed) { 161 - err = bcm_set_baudrate(hu, hu->proto->oper_speed); 164 + if (speed) 165 + hci_uart_set_baudrate(hu, speed); 166 + 167 + /* Operational speed if any */ 168 + if (hu->oper_speed) 169 + speed = hu->oper_speed; 170 + else if (hu->proto->oper_speed) 171 + speed = hu->proto->oper_speed; 172 + else 173 + speed = 0; 174 + 175 + if (speed) { 176 + err = bcm_set_baudrate(hu, speed); 162 177 if (!err) 163 - hci_uart_set_baudrate(hu, hu->proto->oper_speed); 178 + hci_uart_set_baudrate(hu, speed); 164 179 } 165 180 166 181 finalize:
+6 -6
drivers/bluetooth/hci_ldisc.c
··· 370 370 int err; 371 371 372 372 /* Init speed if any */ 373 - if (hu->proto->init_speed) 374 - speed = hu->proto->init_speed; 375 - else if (hu->init_speed) 373 + if (hu->init_speed) 376 374 speed = hu->init_speed; 375 + else if (hu->proto->init_speed) 376 + speed = hu->proto->init_speed; 377 377 else 378 378 speed = 0; 379 379 ··· 381 381 hci_uart_set_baudrate(hu, speed); 382 382 383 383 /* Operational speed if any */ 384 - if (hu->proto->oper_speed) 385 - speed = hu->proto->oper_speed; 386 - else if (hu->oper_speed) 384 + if (hu->oper_speed) 387 385 speed = hu->oper_speed; 386 + else if (hu->proto->oper_speed) 387 + speed = hu->proto->oper_speed; 388 388 else 389 389 speed = 0; 390 390