mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Scott Valentine" <svalentine@concentris-systems.com>
To: rtc-linux@googlegroups.com
Cc: a.zummo@towertech.it, raph@8d.com, linux-kernel@vger.kernel.org
Subject: [PATCH] RTC: v3020 driver bugfix
Date: Mon, 19 Oct 2009 15:11:23 -1000 (HST)	[thread overview]
Message-ID: <36176.167.216.14.194.1256001083.squirrel@www.concentris-systems.com> (raw)

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



             reply	other threads:[~2009-10-20  6:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-20  1:11 Scott Valentine [this message]
2009-11-03 22:01 ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36176.167.216.14.194.1256001083.squirrel@www.concentris-systems.com \
    --to=svalentine@concentris-systems.com \
    --cc=a.zummo@towertech.it \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raph@8d.com \
    --cc=rtc-linux@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®