linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Linus Walleij <linus.walleij@linaro.org>,
	Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-watchdog@vger.kernel.org,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	Charles Keepax <ckeepax@opensource.cirrus.com>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH] watchdog: wm831x: Use GPIO descriptor
Date: Fri, 4 Jan 2019 17:45:38 -0800	[thread overview]
Message-ID: <42d28b28-4c6f-e726-0d0d-60bda2da3f5b@roeck-us.net> (raw)
In-Reply-To: <20190105010908.26623-1-linus.walleij@linaro.org>

On 1/4/19 5:09 PM, Linus Walleij wrote:
> The WM831x watchdog driver passes a global GPIO number from
> platform data into this driver, this is discouraged so pass
> a GPIO descriptor instead.
> 
> More thorough approaches are possible passing descriptors
> associated with the device through machine descriptor tables,
> but no boardfiles in the kernel currently use this driver
> so it is hard to test.
> 

There is a semantic change: Up to now, the gpio descriptor/pin
is released when the driver is removed. This is no longer the
case after this patch is applied. What happens with the provided
gpiod on driver removal ?

Anyway, it seems to me that it might make more sense to remove
the platform data and all its uses entirely. It isn't provided
and thus not used, and who knows if it even works. Providing
it would require changes in the mfd driver, which are unlikely
to happen at this point since the driver is close to 10 years old.

Mark, since you wrote that code, do you have any idea what
the use case might be (or have been) ?

Thanks,
Guenter

> Cc: Richard Fitzgerald <rf@opensource.cirrus.com>
> Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
> Cc: Mark Brown <broonie@kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>   drivers/watchdog/wm831x_wdt.c    | 23 ++++++-----------------
>   include/linux/mfd/wm831x/pdata.h |  3 ++-
>   2 files changed, 8 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/watchdog/wm831x_wdt.c b/drivers/watchdog/wm831x_wdt.c
> index 116c2f47b463..998a39f83c48 100644
> --- a/drivers/watchdog/wm831x_wdt.c
> +++ b/drivers/watchdog/wm831x_wdt.c
> @@ -13,7 +13,7 @@
>   #include <linux/platform_device.h>
>   #include <linux/watchdog.h>
>   #include <linux/uaccess.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/consumer.h>
>   
>   #include <linux/mfd/wm831x/core.h>
>   #include <linux/mfd/wm831x/pdata.h>
> @@ -29,7 +29,7 @@ struct wm831x_wdt_drvdata {
>   	struct watchdog_device wdt;
>   	struct wm831x *wm831x;
>   	struct mutex lock;
> -	int update_gpio;
> +	struct gpio_desc *update_gpiod;
>   	int update_state;
>   };
>   
> @@ -103,8 +103,8 @@ static int wm831x_wdt_ping(struct watchdog_device *wdt_dev)
>   
>   	mutex_lock(&driver_data->lock);
>   
> -	if (driver_data->update_gpio) {
> -		gpio_set_value_cansleep(driver_data->update_gpio,
> +	if (driver_data->update_gpiod) {
> +		gpiod_set_value_cansleep(driver_data->update_gpiod,
>   					driver_data->update_state);
>   		driver_data->update_state = !driver_data->update_state;
>   		ret = 0;
> @@ -239,19 +239,8 @@ static int wm831x_wdt_probe(struct platform_device *pdev)
>   		reg |= pdata->secondary << WM831X_WDOG_SECACT_SHIFT;
>   		reg |= pdata->software << WM831X_WDOG_RST_SRC_SHIFT;
>   
> -		if (pdata->update_gpio) {
> -			ret = devm_gpio_request_one(&pdev->dev,
> -						pdata->update_gpio,
> -						GPIOF_OUT_INIT_LOW,
> -						"Watchdog update");
> -			if (ret < 0) {
> -				dev_err(wm831x->dev,
> -					"Failed to request update GPIO: %d\n",
> -					ret);
> -				return ret;
> -			}
> -
> -			driver_data->update_gpio = pdata->update_gpio;
> +		if (pdata->update_gpiod) {
> +			driver_data->update_gpiod = pdata->update_gpiod;
>   
>   			/* Make sure the watchdog takes hardware updates */
>   			reg |= WM831X_WDOG_RST_SRC;
> diff --git a/include/linux/mfd/wm831x/pdata.h b/include/linux/mfd/wm831x/pdata.h
> index dcc9631b3052..ea7e9ad10a14 100644
> --- a/include/linux/mfd/wm831x/pdata.h
> +++ b/include/linux/mfd/wm831x/pdata.h
> @@ -15,6 +15,7 @@
>   #ifndef __MFD_WM831X_PDATA_H__
>   #define __MFD_WM831X_PDATA_H__
>   
> +struct gpio_desc;
>   struct wm831x;
>   struct regulator_init_data;
>   
> @@ -95,7 +96,7 @@ enum wm831x_watchdog_action {
>   
>   struct wm831x_watchdog_pdata {
>   	enum wm831x_watchdog_action primary, secondary;
> -	int update_gpio;
> +	struct gpio_desc *update_gpiod;
>   	unsigned int software:1;
>   };
>   
> 


      reply	other threads:[~2019-01-05  1:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-05  1:09 [PATCH] watchdog: wm831x: Use GPIO descriptor Linus Walleij
2019-01-05  1:45 ` Guenter Roeck [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=42d28b28-4c6f-e726-0d0d-60bda2da3f5b@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=rf@opensource.cirrus.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;
as well as URLs for NNTP newsgroup(s).