Devicetree
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Rob Herring <robh+dt@kernel.org>,
	linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO
Date: Wed, 4 May 2022 00:05:50 +0200	[thread overview]
Message-ID: <20220503220550.3jczn2hzc5me34qj@pali> (raw)
In-Reply-To: <6f69677c-18d9-abd9-93d7-cf1f29603ed6@roeck-us.net>

On Monday 02 May 2022 21:37:16 Guenter Roeck wrote:
> On 5/2/22 20:57, Tzung-Bi Shih wrote:
> > On Fri, Apr 29, 2022 at 03:13:49PM +0200, Pali Rohár wrote:
> > > @@ -27,6 +27,7 @@
> > >   #include <linux/io.h>
> > >   #include <linux/slab.h>
> > >   #include <linux/property.h>
> > > +#include <linux/gpio/consumer.h>
> > 
> > It would be better to keep them alphabetically.  Anyway, they aren't sorted
> > originally...
> > 
> > > +static void max63xx_gpio_ping(struct max63xx_wdt *wdt)
> > > +{
> > > +	spin_lock(&wdt->lock);
> > 
> > Does it really need to acquire the lock?  It looks like the lock is to prevent
> > concurrent accesses to the mmap in max63xx_mmap_ping() and max63xx_mmap_set().
> > 
> 
> Actually, that doesn't work at all. spin_lock() directly contradicts
> with gpiod_set_value_cansleep().
> 
> > > +	gpiod_set_value_cansleep(wdt->gpio_wdi, 1);
> > > +	udelay(1);
> > 
> > Doesn't it need to include <linux/delay.h> for udelay()?
> > 
> > > @@ -225,10 +240,19 @@ static int max63xx_wdt_probe(struct platform_device *pdev)
> > >   		return -EINVAL;
> > >   	}
> > > +	wdt->gpio_wdi = devm_gpiod_get(dev, NULL, GPIOD_FLAGS_BIT_DIR_OUT);
> > > +	if (IS_ERR(wdt->gpio_wdi) && PTR_ERR(wdt->gpio_wdi) != -ENOENT)
> > 
> > Use devm_gpiod_get_optional() to make the intent clear.  Also, it gets rid of
> > the check for -ENOENT.
> > 
> > > +		return dev_err_probe(dev, PTR_ERR(wdt->gpio_wdi),
> > > +				     "unable to request gpio: %ld\n",
> > > +				     PTR_ERR(wdt->gpio_wdi));
> > 
> > It doesn't need to again print for PTR_ERR(wdt->gpio_wdi).  dev_err_probe()
> > prints the error.
> > 
> > >   	err = max63xx_mmap_init(pdev, wdt);
> > >   	if (err)
> > >   		return err;
> > > +	if (!IS_ERR(wdt->gpio_wdi))
> > > +		wdt->ping = max63xx_gpio_ping;
> > 
> > Thus, the max63xx_gpio_ping() overrides max63xx_mmap_ping() if the GPIO was
> > provided?  It would be better to mention the behavior in the commit message.
> > 
> > Also, could both the assignments of `wdt->gpio_wdi` and `wdt->ping` happen
> > after max63xx_mmap_init()?
> 

Hello! I'm going to look at all these issues. Recently I sent max63
watchdog driver also into U-Boot and seems that I mixed DTS and driver
code between U-Boot and Kernel... and tested something mixed.

I will do new testing again, and will check that I'm testing correct
code.

  reply	other threads:[~2022-05-03 22:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29 13:13 [PATCH v2 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding Pali Rohár
2022-04-29 13:13 ` [PATCH v2 2/2] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Pali Rohár
2022-05-03  3:57   ` Tzung-Bi Shih
2022-05-03  4:37     ` Guenter Roeck
2022-05-03 22:05       ` Pali Rohár [this message]
2022-07-05  0:12         ` Pali Rohár
2022-05-03 21:51 ` [PATCH v2 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding Rob Herring
2022-05-03 22:02   ` Pali Rohár

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=20220503220550.3jczn2hzc5me34qj@pali \
    --to=pali@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=robh+dt@kernel.org \
    --cc=tzungbi@kernel.org \
    --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