Patchwork [U-Boot,v3,10/10] i2c: sh_i2c: use setbits/clrbits macro

login
register
mail settings
Submitter Tetsuyuki Kobayashi
Date Sept. 14, 2012, 5:08 a.m.
Message ID <1347599285-11830-11-git-send-email-koba@kmckk.co.jp>
Download mbox | patch
Permalink /patch/183804/
State Accepted
Delegated to: Heiko Schocher
Headers show

Comments

Tetsuyuki Kobayashi - Sept. 14, 2012, 5:08 a.m.
Use setbits/clrbits macro when read-modify-write register.

Signed-off-by: Tetsuyuki Kobayashi <koba@kmckk.co.jp>
---
Changes for v3:
 - new

 drivers/i2c/sh_i2c.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Nobuhiro Iwamatsu - Sept. 18, 2012, 12:57 a.m.
On Fri, Sep 14, 2012 at 2:08 PM, Tetsuyuki Kobayashi <koba@kmckk.co.jp> wrote:
> Use setbits/clrbits macro when read-modify-write register.
>
> Signed-off-by: Tetsuyuki Kobayashi <koba@kmckk.co.jp>
> ---
> Changes for v3:
>  - new
>
>  drivers/i2c/sh_i2c.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/sh_i2c.c b/drivers/i2c/sh_i2c.c
> index afcb503..44ba90e 100644
> --- a/drivers/i2c/sh_i2c.c
> +++ b/drivers/i2c/sh_i2c.c
> @@ -98,8 +98,8 @@ static int i2c_set_addr(struct sh_i2c *base, u8 id, u8 reg, int stop)
>  {
>         u8 icic = SH_IC_TACK;
>
> -       writeb(readb(&base->iccr) & ~SH_I2C_ICCR_ICE, &base->iccr);
> -       writeb(readb(&base->iccr) | SH_I2C_ICCR_ICE, &base->iccr);
> +       clrbits_8(&base->iccr, SH_I2C_ICCR_ICE);
> +       setbits_8(&base->iccr, SH_I2C_ICCR_ICE);
>
>         writeb(iccl & 0xff, &base->iccl);
>         writeb(icch & 0xff, &base->icch);
> @@ -114,7 +114,7 @@ static int i2c_set_addr(struct sh_i2c *base, u8 id, u8 reg, int stop)
>         writeb((SH_I2C_ICCR_ICE|SH_I2C_ICCR_RTS|SH_I2C_ICCR_BUSY), &base->iccr);
>         irq_dte(base);
>
> -       writeb(readb(&base->icsr) & ~SH_IC_TACK, &base->icsr);
> +       clrbits_8(&base->icsr, SH_IC_TACK);
>         writeb(id << 1, &base->icdr);
>         if (irq_dte_with_tack(base) != 0)
>                 return -1;
> @@ -131,7 +131,7 @@ static int i2c_set_addr(struct sh_i2c *base, u8 id, u8 reg, int stop)
>  static void i2c_finish(struct sh_i2c *base)
>  {
>         writeb(0, &base->icsr);
> -       writeb(readb(&base->iccr) & ~SH_I2C_ICCR_ICE, &base->iccr);
> +       clrbits_8(&base->iccr, SH_I2C_ICCR_ICE);
>  }
>
>  static int i2c_raw_write(struct sh_i2c *base, u8 id, u8 reg, u8 val)
> --
> 1.7.9.5

Acked-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>

Thanks!

Nobuhiro

Patch

diff --git a/drivers/i2c/sh_i2c.c b/drivers/i2c/sh_i2c.c
index afcb503..44ba90e 100644
--- a/drivers/i2c/sh_i2c.c
+++ b/drivers/i2c/sh_i2c.c
@@ -98,8 +98,8 @@  static int i2c_set_addr(struct sh_i2c *base, u8 id, u8 reg, int stop)
 {
 	u8 icic = SH_IC_TACK;
 
-	writeb(readb(&base->iccr) & ~SH_I2C_ICCR_ICE, &base->iccr);
-	writeb(readb(&base->iccr) | SH_I2C_ICCR_ICE, &base->iccr);
+	clrbits_8(&base->iccr, SH_I2C_ICCR_ICE);
+	setbits_8(&base->iccr, SH_I2C_ICCR_ICE);
 
 	writeb(iccl & 0xff, &base->iccl);
 	writeb(icch & 0xff, &base->icch);
@@ -114,7 +114,7 @@  static int i2c_set_addr(struct sh_i2c *base, u8 id, u8 reg, int stop)
 	writeb((SH_I2C_ICCR_ICE|SH_I2C_ICCR_RTS|SH_I2C_ICCR_BUSY), &base->iccr);
 	irq_dte(base);
 
-	writeb(readb(&base->icsr) & ~SH_IC_TACK, &base->icsr);
+	clrbits_8(&base->icsr, SH_IC_TACK);
 	writeb(id << 1, &base->icdr);
 	if (irq_dte_with_tack(base) != 0)
 		return -1;
@@ -131,7 +131,7 @@  static int i2c_set_addr(struct sh_i2c *base, u8 id, u8 reg, int stop)
 static void i2c_finish(struct sh_i2c *base)
 {
 	writeb(0, &base->icsr);
-	writeb(readb(&base->iccr) & ~SH_I2C_ICCR_ICE, &base->iccr);
+	clrbits_8(&base->iccr, SH_I2C_ICCR_ICE);
 }
 
 static int i2c_raw_write(struct sh_i2c *base, u8 id, u8 reg, u8 val)