[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <57e2b00712121620n6667fae7w2d4fb615113e4b27@mail.gmail.com>
Date: Thu, 13 Dec 2007 00:20:39 +0000
From: "Byron Bradley" <byron.bbradley@...il.com>
To: "Andrew Morton" <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, p_gortmaker@...oo.com,
timtimred@...nas.org
Subject: Re: [PATCH] Add support for the S-35390A RTC chip.
On Dec 12, 2007 8:23 AM, Andrew Morton <akpm@...ux-foundation.org> wrote:
> On Thu, 6 Dec 2007 22:10:27 +0000 Byron Bradley <byron.bbradley@...il.com> wrote:
>
> > This adds basic get/set time support for the Seiko Instruments
> > S-35390A. This chip communicates using I2C and is used on the
> > QNAP TS-109/TS-209 NAS devices.
> >
>
> A nice looking little driver.
>
> > +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);
> > +}
>
> Please take a peek in include/linux/bitrev.h ;)
Thanks Andrew, I knew there must have been a function to do this
somewhere but all I could find were the swab functions.
> Could you review and runtime test this please?
>
> --- 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 <linux/module.h>
> #include <linux/rtc.h>
> #include <linux/i2c.h>
> +#include <linux/bitrev.h>
> #include <linux/bcd.h>
>
> #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]);
> _
The above patch works as expected.
Thanks,
--
Byron Bradley
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists