Bluetooth: Add conditional check before requesting gpio

Add a condition check before calling gpio_request in order
to avoid non-fatal panic.

Change-Id: Id77b99b0a7c119efb75e50c85ec185895dd8c031
Signed-off-by: Mahesh Kumar Sharma <smahesh@codeaurora.org>
This commit is contained in:
Mahesh Kumar Sharma 2021-01-27 10:12:14 -08:00
commit 669c9af027

View file

@ -398,25 +398,30 @@ static int bt_configure_gpios(int on)
bt_power_src_status[BT_RESET_GPIO] =
gpio_get_value(bt_reset_gpio);
}
rc = gpio_request(xo_reset_gpio, "xo_reset_gpio_n");
if (rc) {
pr_err("%s: unable to request gpio %d (%d)\n",
pr_info("xo_reset_gpio(%d)\n", xo_reset_gpio);
if (xo_reset_gpio > 0) {
rc = gpio_request(xo_reset_gpio, "xo_reset_gpio_n");
if (rc) {
pr_err("%s: unable to request gpio %d (%d)\n",
__func__, xo_reset_gpio, rc);
} else {
pr_info("%s: gpio_request for xo_reset_gpio succeed\n",
} else {
pr_info("%s: gpio_request for xo_reset_gpio succeed\n",
__func__);
//pull GPIO high
rc = gpio_direction_output(xo_reset_gpio, 1);
if (rc) {
pr_err("%s: Unable to set direction of xo_reset_gpio\n",
__func__);
}
udelay(2000);
//pull GPIO low after 2 ms delay
rc = gpio_direction_output(xo_reset_gpio, 0);
if (rc) {
pr_err("%s: Unable to set direction of xo_reset_gpio\n",
__func__);
//pull GPIO high
rc = gpio_direction_output(xo_reset_gpio, 1);
if (rc) {
pr_err("%s: Unable to set direction of xo_reset_gpio\n",
__func__);
}
udelay(2000);
//pull GPIO low after 2 ms delay
rc = gpio_direction_output(xo_reset_gpio, 0);
if (rc) {
pr_err("%s: Unable to set direction of xo_reset_gpio\n",
__func__);
}
}
}
msleep(50);