lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54B074B9.2090704@roeck-us.net>
Date:	Fri, 09 Jan 2015 16:39:21 -0800
From:	Guenter Roeck <linux@...ck-us.net>
To:	Alexandre Belloni <alexandre.belloni@...e-electrons.com>,
	Nicolas Ferre <nicolas.ferre@...el.com>
CC:	Boris Brezillon <boris.brezillon@...e-electrons.com>,
	Jean-Christophe Plagniol-Villard <plagnioj@...osoft.com>,
	Daniel Lezcano <daniel.lezcano@...aro.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Samuel Ortiz <sameo@...ux.intel.com>,
	Lee Jones <lee.jones@...aro.org>,
	Wim Van Sebroeck <wim@...ana.be>,
	linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
	linux-watchdog@...r.kernel.org
Subject: Re: [PATCH v2 3/8] watchdog: at91rm9200: use the regmap from mfd

On 01/09/2015 01:51 AM, Alexandre Belloni wrote:
> The system timer MFD driver is providing a regmap. Use it to access the
> registers.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@...e-electrons.com>
> ---
>   drivers/watchdog/Kconfig          |  2 +-
>   drivers/watchdog/at91rm9200_wdt.c | 27 +++++++++------------------
>   2 files changed, 10 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 08f41add1461..18c73bc159fc 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -154,7 +154,7 @@ config ARM_SP805_WATCHDOG
>
>   config AT91RM9200_WATCHDOG
>   	tristate "AT91RM9200 watchdog"
> -	depends on SOC_AT91RM9200
> +	depends on SOC_AT91RM9200 && MFD_ATMEL_ST
>   	help
>   	  Watchdog timer embedded into AT91RM9200 chips. This will reboot your
>   	  system when the timeout is reached.
> diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
> index d244112d5b6f..a493fe4b0dfc 100644
> --- a/drivers/watchdog/at91rm9200_wdt.c
> +++ b/drivers/watchdog/at91rm9200_wdt.c
> @@ -14,25 +14,22 @@
>   #include <linux/bitops.h>
>   #include <linux/errno.h>
>   #include <linux/fs.h>
> -#include <linux/init.h>
> -#include <linux/io.h>
>   #include <linux/kernel.h>
> +#include <linux/mfd/atmel-st.h>
>   #include <linux/miscdevice.h>
>   #include <linux/module.h>
>   #include <linux/moduleparam.h>
>   #include <linux/platform_device.h>
> -#include <linux/types.h>
> +#include <linux/regmap.h>
>   #include <linux/watchdog.h>
>   #include <linux/uaccess.h>
> -#include <linux/of.h>
> -#include <linux/of_device.h>
> -#include <mach/at91_st.h>
>
>   #define WDT_DEFAULT_TIME	5	/* seconds */
>   #define WDT_MAX_TIME		256	/* seconds */
>
>   static int wdt_time = WDT_DEFAULT_TIME;
>   static bool nowayout = WATCHDOG_NOWAYOUT;
> +static struct regmap *regmap_st;
>
>   module_param(wdt_time, int, 0);
>   MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="
> @@ -55,7 +52,7 @@ static unsigned long at91wdt_busy;
>    */
>   static inline void at91_wdt_stop(void)
>   {
> -	at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN);
> +	regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN);
>   }
>
>   /*
> @@ -63,9 +60,9 @@ static inline void at91_wdt_stop(void)
>    */
>   static inline void at91_wdt_start(void)
>   {
> -	at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN |
> +	regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN |
>   				(((65536 * wdt_time) >> 8) & AT91_ST_WDV));
> -	at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
> +	regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
>   }
>
>   /*
> @@ -73,7 +70,7 @@ static inline void at91_wdt_start(void)
>    */
>   static inline void at91_wdt_reload(void)
>   {
> -	at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
> +	regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
>   }
>
>   /* ......................................................................... */
> @@ -204,6 +201,7 @@ static struct miscdevice at91wdt_miscdev = {
>   static int at91wdt_probe(struct platform_device *pdev)
>   {
>   	int res;
> +	regmap_st = dev_get_drvdata(pdev->dev.parent);
>

Is it guaranteed that parent is never NULL, and that the parent's
drvdata is always set ?

Also, it seems that regmap_st will be overwritten if the device
is already open (see code below). That may not be a good idea.

Guenter

>   	if (at91wdt_miscdev.parent)
>   		return -EBUSY;
> @@ -254,12 +252,6 @@ static int at91wdt_resume(struct platform_device *pdev)
>   #define at91wdt_resume	NULL
>   #endif
>
> -static const struct of_device_id at91_wdt_dt_ids[] = {
> -	{ .compatible = "atmel,at91rm9200-wdt" },
> -	{ /* sentinel */ }
> -};
> -MODULE_DEVICE_TABLE(of, at91_wdt_dt_ids);
> -
>   static struct platform_driver at91wdt_driver = {
>   	.probe		= at91wdt_probe,
>   	.remove		= at91wdt_remove,
> @@ -267,8 +259,7 @@ static struct platform_driver at91wdt_driver = {
>   	.suspend	= at91wdt_suspend,
>   	.resume		= at91wdt_resume,
>   	.driver		= {
> -		.name	= "at91_wdt",
> -		.of_match_table = at91_wdt_dt_ids,
> +		.name	= "atmel_st_watchdog",
>   	},
>   };
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ