]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
rtc-ab8500-add-calibration-attribute-to-ab8500-rtc-v3
authorMark Godfrey <mark.godfrey@stericsson.com>
Thu, 8 Dec 2011 04:42:31 +0000 (15:42 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 15 Dec 2011 07:35:26 +0000 (18:35 +1100)
ChangeLog v2->v3:
- back to square 1. 0x80 is not allowed because the representation
  is not two's complement but bit 7 is a sign bit, thus 0x80 is
  just another way to say "zero". Sorry for the mess, clarified this
  with a comment in the code.

Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Mark Godfrey <mark.godfrey@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/rtc/rtc-ab8500.c

index d60d60599fbe1239b48ffc5644b84297fc6dc344..2bd391b2f44c82f2839a433de2abce527a8573e2 100644 (file)
@@ -265,8 +265,11 @@ static int ab8500_rtc_set_calibration(struct device *dev, int calibration)
        u8  rtccal = 0;
 
        /*
-        * Check that the calibration value (which is in units of 0.5 parts-per-million)
-        * is in the AB8500's range for RtcCalibration register.
+        * Check that the calibration value (which is in units of 0.5
+        * parts-per-million) is in the AB8500's range for RtcCalibration
+        * register. -128 (0x80) is not permitted because the AB8500 uses
+        * a sign-bit rather than two's complement, so 0x80 is just another
+        * representation of zero.
         */
        if ((calibration < -127) || (calibration > 127)) {
                dev_err(dev, "RtcCalibration value outside permitted range\n");
@@ -281,7 +284,7 @@ static int ab8500_rtc_set_calibration(struct device *dev, int calibration)
        if (calibration >= 0)
                rtccal = 0x7F & calibration;
        else
-               rtccal = ~(calibration - 1) | 0x80;
+               rtccal = ~(calibration -1) | 0x80;
 
        retval = abx500_set_register_interruptible(dev, AB8500_RTC,
                        AB8500_RTC_CALIB_REG, rtccal);