Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f5e5b734d4c9ccc1f5f68bdf545bdc4b19681d28
Commit:     f5e5b734d4c9ccc1f5f68bdf545bdc4b19681d28
Parent:     c5eb2a2b65fe411dcfe13264cfa84788a75341fb
Author:     Russell King <[EMAIL PROTECTED]>
AuthorDate: Sun Mar 4 20:12:07 2007 +0000
Committer:  Russell King <[EMAIL PROTECTED]>
CommitDate: Sun Mar 4 20:12:07 2007 +0000

    [ARM] rtc-pcf8583: don't use BCD_TO_BIN/BIN_TO_BCD
    
    Both BCD_TO_BIN(x) and BIN_TO_BCD(x) have an unexpected side-effect -
    not only do they return the value as expected, they _modify_ their
    argument in the process.
    
    Let's play it safe and avoid these macros.
    
    Signed-off-by: Russell King <[EMAIL PROTECTED]>
---
 drivers/rtc/rtc-pcf8583.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c
index 5875ebb..a69db61 100644
--- a/drivers/rtc/rtc-pcf8583.c
+++ b/drivers/rtc/rtc-pcf8583.c
@@ -81,11 +81,11 @@ static int pcf8583_get_datetime(struct i2c_client *client, 
struct rtc_time *dt)
                buf[4] &= 0x3f;
                buf[5] &= 0x1f;
 
-               dt->tm_sec = BCD_TO_BIN(buf[1]);
-               dt->tm_min = BCD_TO_BIN(buf[2]);
-               dt->tm_hour = BCD_TO_BIN(buf[3]);
-               dt->tm_mday = BCD_TO_BIN(buf[4]);
-               dt->tm_mon = BCD_TO_BIN(buf[5]);
+               dt->tm_sec = BCD2BIN(buf[1]);
+               dt->tm_min = BCD2BIN(buf[2]);
+               dt->tm_hour = BCD2BIN(buf[3]);
+               dt->tm_mday = BCD2BIN(buf[4]);
+               dt->tm_mon = BCD2BIN(buf[5]);
        }
 
        return ret == 2 ? 0 : -EIO;
@@ -99,14 +99,14 @@ static int pcf8583_set_datetime(struct i2c_client *client, 
struct rtc_time *dt,
        buf[0] = 0;
        buf[1] = get_ctrl(client) | 0x80;
        buf[2] = 0;
-       buf[3] = BIN_TO_BCD(dt->tm_sec);
-       buf[4] = BIN_TO_BCD(dt->tm_min);
-       buf[5] = BIN_TO_BCD(dt->tm_hour);
+       buf[3] = BIN2BCD(dt->tm_sec);
+       buf[4] = BIN2BCD(dt->tm_min);
+       buf[5] = BIN2BCD(dt->tm_hour);
 
        if (datetoo) {
                len = 8;
-               buf[6] = BIN_TO_BCD(dt->tm_mday) | (dt->tm_year << 6);
-               buf[7] = BIN_TO_BCD(dt->tm_mon)  | (dt->tm_wday << 5);
+               buf[6] = BIN2BCD(dt->tm_mday) | (dt->tm_year << 6);
+               buf[7] = BIN2BCD(dt->tm_mon)  | (dt->tm_wday << 5);
        }
 
        ret = i2c_master_send(client, (char *)buf, len);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to