From 553f0a22a41f1a6e15125ea725c696c8d70f1462 Mon Sep 17 00:00:00 2001 From: Mark Godfrey Date: Thu, 8 Dec 2011 15:42:31 +1100 Subject: [PATCH] rtc-ab8500-add-calibration-attribute-to-ab8500-rtc-v3 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 Signed-off-by: Mark Godfrey Signed-off-by: Linus Walleij Cc: Alessandro Zummo Signed-off-by: Andrew Morton --- drivers/rtc/rtc-ab8500.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c index d60d60599fbe..2bd391b2f44c 100644 --- a/drivers/rtc/rtc-ab8500.c +++ b/drivers/rtc/rtc-ab8500.c @@ -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); -- 2.39.5