From: Tzung-Bi Shih <tzungbi@kernel.org>
To: "Pali Rohár" <pali@kernel.org>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
Guenter Roeck <linux@roeck-us.net>,
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: Tue, 3 May 2022 11:57:53 +0800 [thread overview]
Message-ID: <YnCoQUGQsXIfbowQ@google.com> (raw)
In-Reply-To: <20220429131349.21229-2-pali@kernel.org>
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().
> + 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()?
next prev parent reply other threads:[~2022-05-03 3:58 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 [this message]
2022-05-03 4:37 ` Guenter Roeck
2022-05-03 22:05 ` Pali Rohár
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=YnCoQUGQsXIfbowQ@google.com \
--to=tzungbi@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=pali@kernel.org \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).