Skip to content

Commit

Permalink
rtc: v3020: fix v3020_mmio_read_bit()
Browse files Browse the repository at this point in the history
v3020_mmio_read_bit() always returns 0 when left_shift > 7.

v3020_mmio_read_bit()'s return type is (unsigned char).  The code returns
a value masked by (1 << left_shift) that is casted to the return type.  If
left_shift is larger than 7, the cast will always result in a 0 return
value.  The problem was discovered with left_shift = 16, and the included
patch corrects the problem.

The bug was introduced in the last (Apr 3 2009) commit of the file, kernel
versions 2.6.30 and later.

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Paul Gortmaker <p_gortmaker@yahoo.com>
Cc: Raphael Assenat <raph@8d.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Scott Valentine authored and Linus Torvalds committed Nov 12, 2009
1 parent 61df333 commit bcb3a16
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-v3020.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static void v3020_mmio_write_bit(struct v3020 *chip, unsigned char bit)

static unsigned char v3020_mmio_read_bit(struct v3020 *chip)
{
return readl(chip->ioaddress) & (1 << chip->leftshift);
return !!(readl(chip->ioaddress) & (1 << chip->leftshift));
}

static struct v3020_chip_ops v3020_mmio_ops = {
Expand Down

0 comments on commit bcb3a16

Please sign in to comment.