Linux Watchdog driver development
 help / color / mirror / Atom feed
From: Xingyu Wu <xingyu.wu@starfivetech.com>
To: Guenter Roeck <linux@roeck-us.net>,
	<linux-watchdog@vger.kernel.org>,
	"Wim Van Sebroeck" <wim@linux-watchdog.org>
Cc: Samin Guo <samin.guo@starfivetech.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] watchdog: starfive: Fix the probe return error if PM and early_enable are both disabled
Date: Wed, 26 Apr 2023 09:49:48 +0800	[thread overview]
Message-ID: <dca081d0-cc06-3e65-ec9b-3885baf5dcde@starfivetech.com> (raw)
In-Reply-To: <2ea16959-4525-90fb-b928-d652a4613574@roeck-us.net>

On 2023/4/25 22:06, Guenter Roeck wrote:
> On 4/25/23 03:04, Xingyu Wu wrote:
>> When the starfive watchdog driver uses 'pm_runtime_put_sync()' as probe
>> return value at last and 'early_enable' is disabled, it could return the
>> error '-ENOSYS' if the CONFIG_PM is disabled, but the driver should works
>> normally.
>>
>> Add a check to make sure the PM is enabled and then use
>> 'pm_runtime_put_sync()' as return value when 'early_enable' is disabled.
>>
>> Fixes: db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")
>> Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
>> ---
>>
>> Hi, Guenter and Wim,
>>
>> This patch fixes the issue of StarFive watchdog driver and rebases on
>> the master branch of linux-next.
>>
>> Thanks.
>>   ---
>>   drivers/watchdog/starfive-wdt.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
>> index 1995cceca51e..51e487e09960 100644
>> --- a/drivers/watchdog/starfive-wdt.c
>> +++ b/drivers/watchdog/starfive-wdt.c
>> @@ -492,7 +492,8 @@ static int starfive_wdt_probe(struct platform_device *pdev)
>>           goto err_exit;
>>         if (!early_enable)
>> -        return pm_runtime_put_sync(&pdev->dev);
>> +        if (pm_runtime_enabled(&pdev->dev))
>> +            return pm_runtime_put_sync(&pdev->dev);
>>   
> 
> Why not just
> 
>     if (!early_enable)
>         pm_runtime_put_sync(&pdev->dev)
> 
> like almost every other caller of pm_runtime_put_sync() ?
> 

The function of pm_runtime_put_sync() is that:

static inline int pm_runtime_put_sync(struct device *dev)
{
	return __pm_runtime_idle(dev, RPM_GET_PUT);
}

and when do not enable CONFIG_PM, the __pm_runtime_idle() is that:

static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
{
	return -ENOSYS;
}

If I do not open PM, it will return error saying probe failed
but it works fine without PM. I had tested that and probe really
was failed. So I should add this check before using pm_runtime_put_sync().

Best regards,
Xingyu Wu


  reply	other threads:[~2023-04-26  1:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25 10:04 [PATCH v1] watchdog: starfive: Fix the probe return error if PM and early_enable are both disabled Xingyu Wu
2023-04-25 14:06 ` Guenter Roeck
2023-04-26  1:49   ` Xingyu Wu [this message]
2023-04-26  2:01     ` Guenter Roeck
2023-04-26  2:44       ` Xingyu Wu

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=dca081d0-cc06-3e65-ec9b-3885baf5dcde@starfivetech.com \
    --to=xingyu.wu@starfivetech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=samin.guo@starfivetech.com \
    --cc=wim@linux-watchdog.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