From: Andrew Morton Use bitrev8() Cc: Alessandro Zummo Cc: Byron Bradley Cc: David Brownell Signed-off-by: Andrew Morton --- drivers/rtc/rtc-s35390a.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff -puN drivers/rtc/rtc-s35390a.c~rtc-add-support-for-the-s-35390a-rtc-chip-fix drivers/rtc/rtc-s35390a.c --- a/drivers/rtc/rtc-s35390a.c~rtc-add-support-for-the-s-35390a-rtc-chip-fix +++ a/drivers/rtc/rtc-s35390a.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #define S35390A_CMD_STATUS1 0 @@ -121,13 +122,6 @@ static int s35390a_reg2hr(struct s35390a return hour; } -static inline char reverse(char x) -{ - x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); - x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); - return (x >> 4) | (x << 4); -} - static int s35390a_set_datetime(struct i2c_client *client, struct rtc_time *tm) { struct s35390a *s35390a = i2c_get_clientdata(client); @@ -149,7 +143,7 @@ static int s35390a_set_datetime(struct i /* This chip expects the bits of each byte to be in reverse order */ for (i = 0; i < 7; ++i) - buf[i] = reverse(buf[i]); + buf[i] = bitrev8(buf[i]); err = s35390a_set_reg(s35390a, S35390A_CMD_TIME1, buf, sizeof(buf)); @@ -168,7 +162,7 @@ static int s35390a_get_datetime(struct i /* This chip returns the bits of each byte in reverse order */ for (i = 0; i < 7; ++i) - buf[i] = reverse(buf[i]); + buf[i] = bitrev8(buf[i]); tm->tm_sec = BCD2BIN(buf[S35390A_BYTE_SECS]); tm->tm_min = BCD2BIN(buf[S35390A_BYTE_MINS]); _