From: Harish Bandi <c-hbandi@codeaurora.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
Balakrishna Godavarthi <bgodavar@codeaurora.org>
Cc: Marcel Holtmann <marcel@holtmann.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
Jeffrey Hugo <jeffrey.l.hugo@gmail.com>,
linux-arm-msm@vger.kernel.org,
linux-bluetooth-owner@vger.kernel.org
Subject: Re: [PATCH 4/4] Bluetooth: hci_qca: Split qca_power_setup()
Date: Fri, 18 Oct 2019 16:49:06 +0530 [thread overview]
Message-ID: <401f2b07e3c4404f3e0e3603900a9836@codeaurora.org> (raw)
In-Reply-To: <20191018052405.3693555-5-bjorn.andersson@linaro.org>
On 2019-10-18 10:54, Bjorn Andersson wrote:
> Split and rename qca_power_setup() in order to simplify each code path
> and to clarify that it is unrelated to qca_power_off() and
> qca_power_setup().
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
> drivers/bluetooth/hci_qca.c | 61 ++++++++++++++++++++++---------------
> 1 file changed, 36 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 01f941e9adf3..c591a8ba9d93 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -160,7 +160,8 @@ struct qca_serdev {
> const char *firmware_name;
> };
>
> -static int qca_power_setup(struct hci_uart *hu, bool on);
> +static int qca_regulator_enable(struct qca_serdev *qcadev);
> +static void qca_regulator_disable(struct qca_serdev *qcadev);
> static void qca_power_shutdown(struct hci_uart *hu);
> static int qca_power_off(struct hci_dev *hdev);
>
> @@ -516,7 +517,7 @@ static int qca_open(struct hci_uart *hu)
> } else {
> hu->init_speed = qcadev->init_speed;
> hu->oper_speed = qcadev->oper_speed;
> - ret = qca_power_setup(hu, true);
> + ret = qca_regulator_enable(qcadev);
> if (ret) {
> destroy_workqueue(qca->workqueue);
> kfree_skb(qca->rx_skb);
> @@ -1186,7 +1187,7 @@ static int qca_wcn3990_init(struct hci_uart *hu)
> qcadev = serdev_device_get_drvdata(hu->serdev);
> if (!qcadev->bt_power->vregs_on) {
> serdev_device_close(hu->serdev);
> - ret = qca_power_setup(hu, true);
> + ret = qca_regulator_enable(qcadev);
> if (ret)
> return ret;
>
> @@ -1351,9 +1352,12 @@ static const struct qca_vreg_data
> qca_soc_data_wcn3998 = {
>
> static void qca_power_shutdown(struct hci_uart *hu)
> {
> + struct qca_serdev *qcadev;
> struct qca_data *qca = hu->priv;
> unsigned long flags;
>
> + qcadev = serdev_device_get_drvdata(hu->serdev);
> +
> /* From this point we go into power off state. But serial port is
> * still open, stop queueing the IBS data and flush all the buffered
> * data in skb's.
> @@ -1365,7 +1369,7 @@ static void qca_power_shutdown(struct hci_uart
> *hu)
>
> host_set_baudrate(hu, 2400);
> qca_send_power_pulse(hu, false);
> - qca_power_setup(hu, false);
> + qca_regulator_disable(qcadev);
> }
>
> static int qca_power_off(struct hci_dev *hdev)
> @@ -1381,36 +1385,43 @@ static int qca_power_off(struct hci_dev *hdev)
> return 0;
> }
>
> -static int qca_power_setup(struct hci_uart *hu, bool on)
> +static int qca_regulator_enable(struct qca_serdev *qcadev)
> {
> - struct regulator_bulk_data *vreg_bulk;
> - struct qca_serdev *qcadev;
> - int num_vregs;
> - int ret = 0;
> + struct qca_power *power = qcadev->bt_power;
> + int ret;
>
> - qcadev = serdev_device_get_drvdata(hu->serdev);
> - if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_bulk)
> - return -EINVAL;
> + /* Already enabled */
> + if (power->vregs_on)
> + return 0;
>
> - vreg_bulk = qcadev->bt_power->vreg_bulk;
> - num_vregs = qcadev->bt_power->num_vregs;
> - BT_DBG("on: %d (%d regulators)", on, num_vregs);
> - if (on && !qcadev->bt_power->vregs_on) {
> - ret = regulator_bulk_enable(num_vregs, vreg_bulk);
> - if (ret)
> - return ret;
> + BT_DBG("enabling %d regulators)", power->num_vregs);
>
> - qcadev->bt_power->vregs_on = true;
> - } else if (!on && qcadev->bt_power->vregs_on) {
> - /* turn off regulator in reverse order */
> - regulator_bulk_disable(num_vregs, vreg_bulk);
> + ret = regulator_bulk_enable(power->num_vregs, power->vreg_bulk);
> + if (ret)
> + return ret;
>
> - qcadev->bt_power->vregs_on = false;
> - }
> + power->vregs_on = true;
>
> return 0;
> }
>
> +static void qca_regulator_disable(struct qca_serdev *qcadev)
> +{
> + struct qca_power *power;
> +
> + if (!qcadev)
> + return;
> +
> + power = qcadev->bt_power;
> +
> + /* Already disabled? */
> + if (!power->vregs_on)
> + return;
> +
> + regulator_bulk_disable(power->num_vregs, power->vreg_bulk);
> + power->vregs_on = false;
> +}
> +
> static int qca_init_regulators(struct qca_power *qca,
> const struct qca_vreg *vregs, size_t num_vregs)
> {
next prev parent reply other threads:[~2019-10-18 11:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 5:24 [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Bjorn Andersson
2019-10-18 5:24 ` [PATCH 1/4] Bluetooth: hci_qca: Update regulator_set_load() usage Bjorn Andersson
2019-10-18 11:18 ` Harish Bandi
2019-10-18 5:24 ` [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage Bjorn Andersson
2019-10-18 11:18 ` Harish Bandi
2019-10-18 18:22 ` Matthias Kaehlcke
2019-10-21 6:37 ` Harish Bandi
2019-10-22 6:05 ` Balakrishna Godavarthi
2019-10-22 17:15 ` Matthias Kaehlcke
2019-10-30 6:18 ` Balakrishna Godavarthi
2019-10-18 5:24 ` [PATCH 3/4] Bluetooth: hci_qca: Use regulator bulk enable/disable Bjorn Andersson
2019-10-18 11:18 ` Harish Bandi
2019-10-18 5:24 ` [PATCH 4/4] Bluetooth: hci_qca: Split qca_power_setup() Bjorn Andersson
2019-10-18 11:19 ` Harish Bandi [this message]
2019-10-18 7:59 ` [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Marcel Holtmann
2019-10-18 14:52 ` Jeffrey Hugo
2019-10-18 11:17 ` Harish Bandi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=401f2b07e3c4404f3e0e3603900a9836@codeaurora.org \
--to=c-hbandi@codeaurora.org \
--cc=bgodavar@codeaurora.org \
--cc=bjorn.andersson@linaro.org \
--cc=jeffrey.l.hugo@gmail.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-bluetooth-owner@vger.kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).