linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Rocky Liao <rjliao@codeaurora.org>
Cc: marcel@holtmann.org, johan.hedberg@gmail.com,
	linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org,
	c-hbandi@codeaurora.org, hemantg@codeaurora.org,
	mka@chromium.org
Subject: Re: [PATCH v1] Bluetooth: hci_qca: Replace devm_gpiod_get() with devm_gpiod_get_optional()
Date: Wed, 11 Mar 2020 10:24:12 +0100	[thread overview]
Message-ID: <20200311092412.GH14211@localhost> (raw)
In-Reply-To: <20200304131645.22057-1-rjliao@codeaurora.org>

On Wed, Mar 04, 2020 at 09:16:45PM +0800, Rocky Liao wrote:
> This patch replaces devm_gpiod_get() with devm_gpiod_get_optional() to get
> bt_en and replaces devm_clk_get() with devm_clk_get_optional() to get
> susclk. It also uses NULL check to determine whether the resource is
> available or not.
> 
> Fixes: 8a208b24d770 ("Bluetooth: hci_qca: Make bt_en and susclk not mandatory for QCA Rome")
> Signed-off-by: Rocky Liao <rjliao@codeaurora.org>
> ---
>  drivers/bluetooth/hci_qca.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)

> @@ -1901,15 +1901,15 @@ static int qca_serdev_probe(struct serdev_device *serdev)
>  		}
>  	} else {
>  		qcadev->btsoc_type = QCA_ROME;
> -		qcadev->bt_en = devm_gpiod_get(&serdev->dev, "enable",
> +		qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
>  					       GPIOD_OUT_LOW);
> -		if (IS_ERR(qcadev->bt_en)) {
> +		if (!qcadev->bt_en) {
>  			dev_warn(&serdev->dev, "failed to acquire enable gpio\n");

Shouldn't this be dev_dbg() if the gpio is indeed optional?

>  			power_ctrl_enabled = false;
>  		}
>  
> -		qcadev->susclk = devm_clk_get(&serdev->dev, NULL);
> -		if (IS_ERR(qcadev->susclk)) {
> +		qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL);
> +		if (!qcadev->susclk) {
>  			dev_warn(&serdev->dev, "failed to acquire clk\n");

Same here.

>  		} else {
>  			err = clk_set_rate(qcadev->susclk, SUSCLK_RATE_32KHZ);
> @@ -1924,7 +1924,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
>  		err = hci_uart_register_device(&qcadev->serdev_hu, &qca_proto);
>  		if (err) {
>  			BT_ERR("Rome serdev registration failed");
> -			if (!IS_ERR(qcadev->susclk))
> +			if (qcadev->susclk)
>  				clk_disable_unprepare(qcadev->susclk);

The clock framework allows you to pass in NULL precisely to be able to
handle optional resources without sprinkling conditionals all over (the
gpio subsystem does not however).

Applies to clk_set_rate() etc. above as well.

>  			return err;
>  		}
> @@ -1945,7 +1945,7 @@ static void qca_serdev_remove(struct serdev_device *serdev)
>  
>  	if (qca_is_wcn399x(qcadev->btsoc_type))
>  		qca_power_shutdown(&qcadev->serdev_hu);
> -	else if (!IS_ERR(qcadev->susclk))
> +	else if (qcadev->susclk)
>  		clk_disable_unprepare(qcadev->susclk);

Same here.

>  	hci_uart_unregister_device(&qcadev->serdev_hu);

Johan

      parent reply	other threads:[~2020-03-11  9:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-04 13:16 [PATCH v1] Bluetooth: hci_qca: Replace devm_gpiod_get() with devm_gpiod_get_optional() Rocky Liao
2020-03-04 16:02 ` Marcel Holtmann
2020-03-11  9:24 ` Johan Hovold [this message]

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=20200311092412.GH14211@localhost \
    --to=johan@kernel.org \
    --cc=bgodavar@codeaurora.org \
    --cc=c-hbandi@codeaurora.org \
    --cc=hemantg@codeaurora.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mka@chromium.org \
    --cc=rjliao@codeaurora.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).