On Wed, Mar 15, 2023 at 05:33:26PM +0530, Neeraj Sanjay Kale wrote: > This adds a driver based on serdev driver for the NXP BT serial protocol > based on running H:4, which can enable the built-in Bluetooth device > inside an NXP BT chip. > > This driver has Power Save feature that will put the chip into sleep state > whenever there is no activity for 2000ms, and will be woken up when any > activity is to be initiated over UART. > > This driver enables the power save feature by default by sending the vendor > specific commands to the chip during setup. > > During setup, the driver checks if a FW is already running on the chip > by waiting for the bootloader signature, and downloads device specific FW > file into the chip over UART if bootloader signature is received.. > > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@xxxxxxx> > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx> ... > +static int nxp_set_ind_reset(struct hci_dev *hdev, void *data) > +{ > + struct btnxpuart_dev *nxpdev = hci_get_drvdata(hdev); > + struct sk_buff *skb; > + u8 *status; > + u8 pcmd = 0; > + int err = 0; > + > + skb = nxp_drv_send_cmd(hdev, HCI_NXP_IND_RESET, 1, &pcmd); > + if (IS_ERR(skb)) > + return PTR_ERR(skb); > + > + status = skb_pull_data(skb, 1); > + if (status) { > + if (*status == 0) { > + set_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); nit: perhaps this can be written more idiomatically as: if (!status || *status) goto free_skb; set_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state); ... > + err = nxp_download_firmware(hdev); > + if (err < 0) > + goto free_skb; > + serdev_device_set_baudrate(nxpdev->serdev, nxpdev->fw_init_baudrate); > + nxpdev->current_baudrate = nxpdev->fw_init_baudrate; > + hci_cmd_sync_queue(hdev, send_wakeup_method_cmd, NULL, NULL); > + hci_cmd_sync_queue(hdev, send_ps_cmd, NULL, NULL); > + } > + } > + > +free_skb: > + kfree_skb(skb); > + return err; > +} ...