Message ID | 1321399263-13826-10-git-send-email-agust@denx.de |
---|---|
State | Superseded |
Headers | show |
Hello Anatolij, Anatolij Gustschin wrote: > Fix: > davinci_i2c.c: In function 'flush_rx': > davinci_i2c.c:81:6: warning: variable 'dummy' set but not used > [-Wunused-but-set-variable] > > Signed-off-by: Anatolij Gustschin <agust@denx.de> > Cc: Heiko Schocher <hs@denx.de> > --- > drivers/i2c/davinci_i2c.c | 4 +--- > 1 files changed, 1 insertions(+), 3 deletions(-) Thanks for fixing this! Acked-by: Heiko Schocher <hs@denx.de> bye, Heiko
On Tue, Nov 15, 2011 at 4:21 PM, Anatolij Gustschin <agust@denx.de> wrote: > Fix: > davinci_i2c.c: In function 'flush_rx': > davinci_i2c.c:81:6: warning: variable 'dummy' set but not used > [-Wunused-but-set-variable] > > Signed-off-by: Anatolij Gustschin <agust@denx.de> > Cc: Heiko Schocher <hs@denx.de> > --- > drivers/i2c/davinci_i2c.c | 4 +--- > 1 files changed, 1 insertions(+), 3 deletions(-) > > diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c > index 5e3406d..a09dc76 100644 > --- a/drivers/i2c/davinci_i2c.c > +++ b/drivers/i2c/davinci_i2c.c > @@ -78,13 +78,11 @@ static int poll_i2c_irq(int mask) > > void flush_rx(void) > { > - int dummy; > - > while (1) { > if (!(REG(I2C_STAT) & I2C_STAT_RRDY)) > break; > > - dummy = REG(I2C_DRR); > + (void)REG(I2C_DRR); This becomes: (void)(*(volatile unsigned int *)(I2C_DDR)) So we don't need that cast. Also, can we at get a comment about what / why we're doing this?
On Wed, 16 Nov 2011 08:42:07 -0700 Tom Rini <tom.rini@gmail.com> wrote: ... > > --- a/drivers/i2c/davinci_i2c.c > > +++ b/drivers/i2c/davinci_i2c.c > > @@ -78,13 +78,11 @@ static int poll_i2c_irq(int mask) > > > > void flush_rx(void) > > { > > - int dummy; > > - > > while (1) { > > if (!(REG(I2C_STAT) & I2C_STAT_RRDY)) > > break; > > > > - dummy = REG(I2C_DRR); > > + (void)REG(I2C_DRR); > > This becomes: > (void)(*(volatile unsigned int *)(I2C_DDR)) > > So we don't need that cast. Also, can we at get a comment about what > / why we're doing this? Ah, thanks for the pointer. Fixed in patch v2. I think that the code is self-explanatory and we don't need a comment. As long there is something shifted in and placed in data reception register we read and throw it away since this is a flush_rx(). Anatolij
diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c index 5e3406d..a09dc76 100644 --- a/drivers/i2c/davinci_i2c.c +++ b/drivers/i2c/davinci_i2c.c @@ -78,13 +78,11 @@ static int poll_i2c_irq(int mask) void flush_rx(void) { - int dummy; - while (1) { if (!(REG(I2C_STAT) & I2C_STAT_RRDY)) break; - dummy = REG(I2C_DRR); + (void)REG(I2C_DRR); REG(I2C_STAT) = I2C_STAT_RRDY; udelay(1000); }
Fix: davinci_i2c.c: In function 'flush_rx': davinci_i2c.c:81:6: warning: variable 'dummy' set but not used [-Wunused-but-set-variable] Signed-off-by: Anatolij Gustschin <agust@denx.de> Cc: Heiko Schocher <hs@denx.de> --- drivers/i2c/davinci_i2c.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)