diff mbox

[03/11] watchdog/at91sam9_wdt: change the wdt_read and wdt_write macro to the inline function

Message ID 1352877369-19740-4-git-send-email-wenyou.yang@atmel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wenyou Yang Nov. 14, 2012, 7:16 a.m. UTC
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
---
 drivers/watchdog/at91sam9_wdt.c |   28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

Comments

Jean-Christophe PLAGNIOL-VILLARD Nov. 16, 2012, 1:49 p.m. UTC | #1
On 15:16 Wed 14 Nov     , Wenyou Yang wrote:
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
> ---
>  drivers/watchdog/at91sam9_wdt.c |   28 ++++++++++++++++++----------
>  1 file changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
> index 31c914a..98e7d5a 100644
> --- a/drivers/watchdog/at91sam9_wdt.c
> +++ b/drivers/watchdog/at91sam9_wdt.c
> @@ -34,11 +34,6 @@
>  
>  #define DRV_NAME "AT91SAM9 Watchdog"
>  
> -#define wdt_read(field) \
> -	__raw_readl(at91wdt_private.base + field)
> -#define wdt_write(field, val) \
> -	__raw_writel((val), at91wdt_private.base + field)
> -
>  /* AT91SAM9 watchdog runs a 12bit counter @ 256Hz,
>   * use this to convert a watchdog
>   * value from/to milliseconds.
> @@ -75,13 +70,24 @@ struct at91wdt_drvdata {
>  
>  /* ......................................................................... */
>  
> +static inline unsigned int wdt_read(struct at91wdt_drvdata *driver_data,
> +					unsigned int field)
> +{
> +	return __raw_readl(driver_data->base + field);
> +}
> +
> +static inline void wdt_write(struct at91wdt_drvdata *driver_data,
> +				unsigned int field, unsigned int val)
> +{
> +	__raw_writel((val), driver_data->base + field);
> +}
use relaxed version

Best Regrds,
J.
Wenyou Yang Dec. 4, 2012, 3:13 a.m. UTC | #2
Hi JC,

> -----Original Message-----

> From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj@jcrosoft.com]

> Sent: 2012?11?16? 21:49

> To: Yang, Wenyou

> Cc: linux-arm-kernel@lists.infradead.org; wim@iguana.be;

> linux-watchdog@vger.kernel.org; linux-kernel@vger.kernel.org; Ferre, Nicolas; Lin,

> JM

> Subject: Re: [PATCH 03/11] watchdog/at91sam9_wdt: change the wdt_read and

> wdt_write macro to the inline function

> 

> On 15:16 Wed 14 Nov     , Wenyou Yang wrote:

> > Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>

> > ---

> >  drivers/watchdog/at91sam9_wdt.c |   28 ++++++++++++++++++----------

> >  1 file changed, 18 insertions(+), 10 deletions(-)

> >

> > diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c

> > index 31c914a..98e7d5a 100644

> > --- a/drivers/watchdog/at91sam9_wdt.c

> > +++ b/drivers/watchdog/at91sam9_wdt.c

> > @@ -34,11 +34,6 @@

> >

> >  #define DRV_NAME "AT91SAM9 Watchdog"

> >

> > -#define wdt_read(field) \

> > -	__raw_readl(at91wdt_private.base + field)

> > -#define wdt_write(field, val) \

> > -	__raw_writel((val), at91wdt_private.base + field)

> > -

> >  /* AT91SAM9 watchdog runs a 12bit counter @ 256Hz,

> >   * use this to convert a watchdog

> >   * value from/to milliseconds.

> > @@ -75,13 +70,24 @@ struct at91wdt_drvdata {

> >

> >  /* ......................................................................... */

> >

> > +static inline unsigned int wdt_read(struct at91wdt_drvdata *driver_data,

> > +					unsigned int field)

> > +{

> > +	return __raw_readl(driver_data->base + field);

> > +}

> > +

> > +static inline void wdt_write(struct at91wdt_drvdata *driver_data,

> > +				unsigned int field, unsigned int val)

> > +{

> > +	__raw_writel((val), driver_data->base + field);

> > +}

> use relaxed version


Thanks, I will change it.
> 

> Best Regrds,

> J.


Best Regards,
Wenyou Yang
diff mbox

Patch

diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index 31c914a..98e7d5a 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -34,11 +34,6 @@ 
 
 #define DRV_NAME "AT91SAM9 Watchdog"
 
-#define wdt_read(field) \
-	__raw_readl(at91wdt_private.base + field)
-#define wdt_write(field, val) \
-	__raw_writel((val), at91wdt_private.base + field)
-
 /* AT91SAM9 watchdog runs a 12bit counter @ 256Hz,
  * use this to convert a watchdog
  * value from/to milliseconds.
@@ -75,13 +70,24 @@  struct at91wdt_drvdata {
 
 /* ......................................................................... */
 
+static inline unsigned int wdt_read(struct at91wdt_drvdata *driver_data,
+					unsigned int field)
+{
+	return __raw_readl(driver_data->base + field);
+}
+
+static inline void wdt_write(struct at91wdt_drvdata *driver_data,
+				unsigned int field, unsigned int val)
+{
+	__raw_writel((val), driver_data->base + field);
+}
 
 /*
  * Reload the watchdog timer.  (ie, pat the watchdog)
  */
-static inline void at91_wdt_reset(void)
+static inline void at91_wdt_reset(struct at91wdt_drvdata *driver_data)
 {
-	wdt_write(AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
+	wdt_write(driver_data, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
 }
 
 /*
@@ -103,13 +109,15 @@  static void at91_ping(unsigned long data)
  * Set the watchdog time interval in 1/256Hz (write-once)
  * Counter is 12 bit.
  */
-static int at91_wdt_settimeout(unsigned int timeout)
+static int at91_wdt_settimeout(struct watchdog_device *wddev,
+					unsigned int timeout)
 {
+	struct at91wdt_drvdata *driver_data = watchdog_get_drvdata(wddev);
 	unsigned int reg;
 	unsigned int mr;
 
 	/* Check if disabled */
-	mr = wdt_read(AT91_WDT_MR);
+	mr = wdt_read(driver_data, AT91_WDT_MR);
 	if (mr & AT91_WDT_WDDIS) {
 		pr_err("sorry, watchdog is disabled\n");
 		return -EIO;
@@ -126,7 +134,7 @@  static int at91_wdt_settimeout(unsigned int timeout)
 		| AT91_WDT_WDDBGHLT	/* disabled in debug mode */
 		| AT91_WDT_WDD		/* restart at any time */
 		| (timeout & AT91_WDT_WDV);  /* timer value */
-	wdt_write(AT91_WDT_MR, reg);
+	wdt_write(driver_data, AT91_WDT_MR, reg);
 
 	return 0;
 }