[v3,05/13] extcon: arizona: Always use pm_runtime_get_sync() when we need the device to be awake
diff mbox series

Message ID 20210122164107.361939-6-hdegoede@redhat.com
State New, archived
Headers show
Series
  • MFD/extcon/ASoC: Rework arizona codec jack-detect support
Related show

Commit Message

Hans de Goede Jan. 22, 2021, 4:40 p.m. UTC
Before this commit the extcon-arizona code was mixing pm_runtime_get()
and pm_runtime_get_sync() in different places.

In all places where pm_runtime_get[_sync]() is called, the code
makes use of the device immediately after the call.
This means that we should always use pm_runtime_get_sync().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v3:
- This is a new patch in v3 of this patch-set
---
 drivers/extcon/extcon-arizona.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andy Shevchenko Jan. 22, 2021, 8:38 p.m. UTC | #1
On Fri, Jan 22, 2021 at 6:41 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Before this commit the extcon-arizona code was mixing pm_runtime_get()
> and pm_runtime_get_sync() in different places.
>
> In all places where pm_runtime_get[_sync]() is called, the code
> makes use of the device immediately after the call.
> This means that we should always use pm_runtime_get_sync().

I think it implies the non-atomic (may sleep) context in the below functions.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v3:
> - This is a new patch in v3 of this patch-set
> ---
>  drivers/extcon/extcon-arizona.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
> index 72d23b15108c..56d2ce05de50 100644
> --- a/drivers/extcon/extcon-arizona.c
> +++ b/drivers/extcon/extcon-arizona.c
> @@ -290,7 +290,7 @@ static void arizona_start_mic(struct arizona_extcon_info *info)
>         unsigned int mode;
>
>         /* Microphone detection can't use idle mode */
> -       pm_runtime_get(info->dev);
> +       pm_runtime_get_sync(info->dev);
>
>         if (info->detecting) {
>                 ret = regulator_allow_bypass(info->micvdd, false);
> @@ -695,7 +695,7 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
>         dev_dbg(arizona->dev, "Starting HPDET\n");
>
>         /* Make sure we keep the device enabled during the measurement */
> -       pm_runtime_get(info->dev);
> +       pm_runtime_get_sync(info->dev);
>
>         info->hpdet_active = true;
>
> --
> 2.28.0
>
Hans de Goede Jan. 22, 2021, 8:47 p.m. UTC | #2
Hi,

On 1/22/21 9:38 PM, Andy Shevchenko wrote:
> On Fri, Jan 22, 2021 at 6:41 PM Hans de Goede <hdegoede@redhat.com> wrote:
>>
>> Before this commit the extcon-arizona code was mixing pm_runtime_get()
>> and pm_runtime_get_sync() in different places.
>>
>> In all places where pm_runtime_get[_sync]() is called, the code
>> makes use of the device immediately after the call.
>> This means that we should always use pm_runtime_get_sync().
> 
> I think it implies the non-atomic (may sleep) context in the below functions.

Right, but there were always called with the info->lock mutex held anyways,
so no change there.

> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Thank you.

Regards,

Hans



> 
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> Changes in v3:
>> - This is a new patch in v3 of this patch-set
>> ---
>>  drivers/extcon/extcon-arizona.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
>> index 72d23b15108c..56d2ce05de50 100644
>> --- a/drivers/extcon/extcon-arizona.c
>> +++ b/drivers/extcon/extcon-arizona.c
>> @@ -290,7 +290,7 @@ static void arizona_start_mic(struct arizona_extcon_info *info)
>>         unsigned int mode;
>>
>>         /* Microphone detection can't use idle mode */
>> -       pm_runtime_get(info->dev);
>> +       pm_runtime_get_sync(info->dev);
>>
>>         if (info->detecting) {
>>                 ret = regulator_allow_bypass(info->micvdd, false);
>> @@ -695,7 +695,7 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
>>         dev_dbg(arizona->dev, "Starting HPDET\n");
>>
>>         /* Make sure we keep the device enabled during the measurement */
>> -       pm_runtime_get(info->dev);
>> +       pm_runtime_get_sync(info->dev);
>>
>>         info->hpdet_active = true;
>>
>> --
>> 2.28.0
>>
> 
>

Patch
diff mbox series

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 72d23b15108c..56d2ce05de50 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -290,7 +290,7 @@  static void arizona_start_mic(struct arizona_extcon_info *info)
 	unsigned int mode;
 
 	/* Microphone detection can't use idle mode */
-	pm_runtime_get(info->dev);
+	pm_runtime_get_sync(info->dev);
 
 	if (info->detecting) {
 		ret = regulator_allow_bypass(info->micvdd, false);
@@ -695,7 +695,7 @@  static void arizona_identify_headphone(struct arizona_extcon_info *info)
 	dev_dbg(arizona->dev, "Starting HPDET\n");
 
 	/* Make sure we keep the device enabled during the measurement */
-	pm_runtime_get(info->dev);
+	pm_runtime_get_sync(info->dev);
 
 	info->hpdet_active = true;