mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: Dinghao Liu <dinghao.liu@zju.edu.cn>, kjlu@umn.edu
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>,
	patches@opensource.cirrus.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v2] extcon: arizona: Fix runtime PM imbalance on error
Date: Mon, 25 May 2020 12:37:16 +0900	[thread overview]
Message-ID: <4a97ca96-0c0c-e895-ba03-9987b59229da@samsung.com> (raw)
In-Reply-To: <20200523061726.25903-1-dinghao.liu@zju.edu.cn>

Hi Dinghao Liu,

On 5/23/20 3:17 PM, Dinghao Liu wrote:
> When arizona_request_irq() returns an error code, a
> pairing runtime PM usage counter decrement is needed
> to keep the counter balanced. For error paths after
> this function, things are the same.
> 
> Also, remove calls to pm_runtime_disable() when
> pm_runtime_enable() has not been executed.
> 
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> 
> Changelog:
> 
> v2: - Add a new label "err_pm" to balance refcount.
>       Remove 3 calls to pm_runtime_disable().
>       Move pm_runtime_put() from the front of
>       input_register_device() to the back.
> ---
>  drivers/extcon/extcon-arizona.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
> index 7401733db08b..aae82db542a5 100644
> --- a/drivers/extcon/extcon-arizona.c
> +++ b/drivers/extcon/extcon-arizona.c
> @@ -1460,7 +1460,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
>  	if (!info->input) {
>  		dev_err(arizona->dev, "Can't allocate input dev\n");
>  		ret = -ENOMEM;
> -		goto err_register;
> +		return ret;
>  	}
>  
>  	info->input->name = "Headset";
> @@ -1492,7 +1492,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
>  		if (ret != 0) {
>  			dev_err(arizona->dev, "Failed to request GPIO%d: %d\n",
>  				pdata->micd_pol_gpio, ret);
> -			goto err_register;
> +			return ret;
>  		}
>  
>  		info->micd_pol_gpio = gpio_to_desc(pdata->micd_pol_gpio);
> @@ -1515,7 +1515,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
>  			dev_err(arizona->dev,
>  				"Failed to get microphone polarity GPIO: %d\n",
>  				ret);
> -			goto err_register;
> +			return ret;
>  		}
>  	}
>  
> @@ -1672,7 +1672,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
>  	if (ret != 0) {
>  		dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n",
>  			ret);
> -		goto err_gpio;
> +		goto err_pm;
>  	}
>  
>  	ret = arizona_set_irq_wake(arizona, jack_irq_rise, 1);
> @@ -1721,14 +1721,14 @@ static int arizona_extcon_probe(struct platform_device *pdev)
>  		dev_warn(arizona->dev, "Failed to set MICVDD to bypass: %d\n",
>  			 ret);
>  
> -	pm_runtime_put(&pdev->dev);
> -
>  	ret = input_register_device(info->input);
>  	if (ret) {
>  		dev_err(&pdev->dev, "Can't register input device: %d\n", ret);
>  		goto err_hpdet;
>  	}
>  
> +	pm_runtime_put(&pdev->dev);
> +
>  	return 0;
>  
>  err_hpdet:
> @@ -1743,10 +1743,11 @@ static int arizona_extcon_probe(struct platform_device *pdev)
>  	arizona_set_irq_wake(arizona, jack_irq_rise, 0);
>  err_rise:
>  	arizona_free_irq(arizona, jack_irq_rise, info);
> +err_pm:
> +	pm_runtime_put(&pdev->dev);
> +	pm_runtime_disable(&pdev->dev);
>  err_gpio:
>  	gpiod_put(info->micd_pol_gpio);
> -err_register:
> -	pm_runtime_disable(&pdev->dev);
>  	return ret;
>  }
>  
> 

Applied it. Thanks. 

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

      reply	other threads:[~2020-05-25  3:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200523061738epcas1p3de3e68c28c0dc34f1ef7c873ff396cd5@epcas1p3.samsung.com>
2020-05-23  6:17 ` Dinghao Liu
2020-05-25  3:37   ` Chanwoo Choi [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=4a97ca96-0c0c-e895-ba03-9987b59229da@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=dinghao.liu@zju.edu.cn \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=patches@opensource.cirrus.com \
    /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

all inboxes | Powered by JetHome®