* [PATCH] RTC: v3020 driver bugfix
@ 2009-10-20 1:11 Scott Valentine
2009-11-03 22:01 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Scott Valentine @ 2009-10-20 1:11 UTC (permalink / raw)
To: rtc-linux; +Cc: a.zummo, raph, linux-kernel
v3020 read_bit always returns 0 when left_shift > 7
The v3020 read_bit function'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.
diff -uNr a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
--- a/drivers/rtc/rtc-v3020.c 2009-10-15 14:41:50.000000000 -1000
+++ b/drivers/rtc/rtc-v3020.c 2009-10-19 14:06:27.000000000 -1000
@@ -96,7 +96,7 @@
static unsigned char v3020_mmio_read_bit(struct v3020 *chip)
{
- return readl(chip->ioaddress) & (1 << chip->leftshift);
+ return ((readl(chip->ioaddress) & (1 << chip->leftshift)) != 0);
}
static struct v3020_chip_ops v3020_mmio_ops = {
Scott Valentine
Concentris Systems LLC
Manoa Innovation Center, Suite #238
2800 Woodlawn Drive
Honolulu, HI 96822
http://www.Concentris-Systems.com
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] RTC: v3020 driver bugfix
2009-10-20 1:11 [PATCH] RTC: v3020 driver bugfix Scott Valentine
@ 2009-11-03 22:01 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2009-11-03 22:01 UTC (permalink / raw)
To: svalentine; +Cc: rtc-linux, a.zummo, raph, linux-kernel
On Mon, 19 Oct 2009 15:11:23 -1000 (HST)
"Scott Valentine" <svalentine@concentris-systems.com> wrote:
> v3020 read_bit always returns 0 when left_shift > 7
>
> The v3020 read_bit function'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.
>
> diff -uNr a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
> --- a/drivers/rtc/rtc-v3020.c 2009-10-15 14:41:50.000000000 -1000
> +++ b/drivers/rtc/rtc-v3020.c 2009-10-19 14:06:27.000000000 -1000
> @@ -96,7 +96,7 @@
>
> static unsigned char v3020_mmio_read_bit(struct v3020 *chip)
> {
> - return readl(chip->ioaddress) & (1 << chip->leftshift);
> + return ((readl(chip->ioaddress) & (1 << chip->leftshift)) != 0);
> }
>
> static struct v3020_chip_ops v3020_mmio_ops = {
OK.
It's strange that the function returns `unsigned char' instead of say
int or bool.
We may as well do this in the same way as v3020_gpio_read_bit():
--- a/drivers/rtc/rtc-v3020.c~rtc-v3020-fix-v3020_mmio_read_bit
+++ a/drivers/rtc/rtc-v3020.c
@@ -96,7 +96,7 @@ static void v3020_mmio_write_bit(struct
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 = {
_
You didn't include a Signed-off-by: for this patch.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-03 22:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-20 1:11 [PATCH] RTC: v3020 driver bugfix Scott Valentine
2009-11-03 22:01 ` Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.