From: Andrew Morton <akpm@linux-foundation.org>
To: Byron Bradley <byron.bbradley@gmail.com>
Cc: linux-kernel@vger.kernel.org, p_gortmaker@yahoo.com,
timtimred@foonas.org
Subject: Re: [PATCH] Add support for the S-35390A RTC chip.
Date: Wed, 12 Dec 2007 00:23:33 -0800 [thread overview]
Message-ID: <20071212002333.dd4508dc.akpm@linux-foundation.org> (raw)
In-Reply-To: <1196979027-2589-1-git-send-email-byron.bbradley@gmail.com>
On Thu, 6 Dec 2007 22:10:27 +0000 Byron Bradley <byron.bbradley@gmail.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 ;)
(I worry about the handling of right-shift-of-negative-values
in your version, too).
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]);
_
next prev parent reply other threads:[~2007-12-12 8:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-06 22:10 [PATCH] Add support for the S-35390A RTC chip Byron Bradley
2007-12-12 8:23 ` Andrew Morton [this message]
2007-12-13 0:20 ` Byron Bradley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071212002333.dd4508dc.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=byron.bbradley@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=p_gortmaker@yahoo.com \
--cc=timtimred@foonas.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox