[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <C17EF62B-CCCE-4C5F-90A7-247EB860608E@holtmann.org>
Date: Mon, 25 Jan 2021 16:19:31 +0100
From: Marcel Holtmann <marcel@...tmann.org>
To: Abhishek Pandit-Subedi <abhishekpandit@...omium.org>
Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@...omium.org>,
Miao-chen Chou <mcchou@...omium.org>, michaelfsun@...gle.com,
Bluetooth Kernel Mailing List
<linux-bluetooth@...r.kernel.org>,
Archie Pusaka <apusaka@...omium.org>,
Johan Hedberg <johan.hedberg@...il.com>,
Luiz Augusto von Dentz <luiz.dentz@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] Bluetooth: btusb: Refactor gpio reset
Hi Abhishek,
> Refactor gpio reset to use a common gpio reset function.
>
> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@...omium.org>
> Reviewed-by: Miao-chen Chou <mcchou@...omium.org>
> ---
>
> drivers/bluetooth/btusb.c | 59 +++++++++++++--------------------------
> 1 file changed, 19 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index b14102fba6018..03341e6cbf3ed 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -547,6 +547,7 @@ struct btusb_data {
> struct usb_endpoint_descriptor *diag_rx_ep;
>
> struct gpio_desc *reset_gpio;
> + unsigned int reset_duration_ms;
>
> __u8 cmdreq_type;
> __u8 cmdreq;
> @@ -566,15 +567,21 @@ struct btusb_data {
> unsigned cmd_timeout_cnt;
> };
>
> -static void btusb_intel_cmd_timeout(struct hci_dev *hdev)
> +static void btusb_toggle_gpio(struct gpio_desc *desc, unsigned int duration)
> +{
> + gpiod_set_value_cansleep(desc, 1);
> + msleep(duration);
> + gpiod_set_value_cansleep(desc, 0);
> +}
> +
> +static void btusb_gpio_cmd_timeout(struct hci_dev *hdev)
> {
> struct btusb_data *data = hci_get_drvdata(hdev);
> - struct gpio_desc *reset_gpio = data->reset_gpio;
>
> if (++data->cmd_timeout_cnt < 5)
> return;
>
> - if (!reset_gpio) {
> + if (!data->reset_gpio) {
> bt_dev_err(hdev, "No way to reset. Ignoring and continuing");
> return;
> }
> @@ -592,39 +599,7 @@ static void btusb_intel_cmd_timeout(struct hci_dev *hdev)
> }
>
> bt_dev_err(hdev, "Initiating HW reset via gpio");
> - gpiod_set_value_cansleep(reset_gpio, 1);
> - msleep(100);
> - gpiod_set_value_cansleep(reset_gpio, 0);
> -}
> -
> -static void btusb_rtl_cmd_timeout(struct hci_dev *hdev)
> -{
> - struct btusb_data *data = hci_get_drvdata(hdev);
> - struct gpio_desc *reset_gpio = data->reset_gpio;
> -
> - if (++data->cmd_timeout_cnt < 5)
> - return;
> -
> - if (!reset_gpio) {
> - bt_dev_err(hdev, "No gpio to reset Realtek device, ignoring");
> - return;
> - }
> -
> - /* Toggle the hard reset line. The Realtek device is going to
> - * yank itself off the USB and then replug. The cleanup is handled
> - * correctly on the way out (standard USB disconnect), and the new
> - * device is detected cleanly and bound to the driver again like
> - * it should be.
> - */
> - if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) {
> - bt_dev_err(hdev, "last reset failed? Not resetting again");
> - return;
> - }
> -
> - bt_dev_err(hdev, "Reset Realtek device via gpio");
> - gpiod_set_value_cansleep(reset_gpio, 1);
> - msleep(200);
> - gpiod_set_value_cansleep(reset_gpio, 0);
> + btusb_toggle_gpio(data->reset_gpio, data->reset_duration_ms);
> }
You need to explain why this patch is correct. You are removing more code here. And there is an extra check in case of Realtek and a large comment.
Regards
Marcel
Powered by blists - more mailing lists