mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mark A. Greer" <mgreer@mvista.com>
To: LM Sensors <lm-sensors@lm-sensors.org>
Cc: Rudolf Marek <r.marek@sh.cvut.cz>,
	Jean Delvare <khali@linux-fr.org>,
	lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH 2.6.16-mm1 2/3] rtc: m41t00 driver cleanup
Date: Thu, 23 Mar 2006 18:21:37 -0700	[thread overview]
Message-ID: <20060324012137.GD9560@mag.az.mvista.com> (raw)
In-Reply-To: <20060323203843.GA18912@mag.az.mvista.com>

This patch does some cleanup to the m41t00 i2c/rtc driver including:
- use BCD2BIN/BIN2BCD instead of BCD_TO_BIN/BIN_TO_BCD
- use strlcpy instead of strncpy
- some whitespace cleanup

Signed-off-by: Mark A. Greer <mgreer@mvista.com>
---

 m41t00.c |   52 +++++++++++++++++++++++-----------------------------
 1 files changed, 23 insertions(+), 29 deletions(-)
---

diff -Nurp linux-2.6.16-mm1-wq/drivers/i2c/chips/m41t00.c linux-2.6.16-mm1-cleanup/drivers/i2c/chips/m41t00.c
--- linux-2.6.16-mm1-wq/drivers/i2c/chips/m41t00.c	2006-03-23 16:04:01.000000000 -0700
+++ linux-2.6.16-mm1-cleanup/drivers/i2c/chips/m41t00.c	2006-03-23 16:16:35.000000000 -0700
@@ -1,6 +1,4 @@
 /*
- * drivers/i2c/chips/m41t00.c
- *
  * I2C client/driver for the ST M41T00 Real-Time Clock chip.
  *
  * Author: Mark A. Greer <mgreer@mvista.com>
@@ -13,9 +11,6 @@
 /*
  * This i2c client/driver wedges between the drivers/char/genrtc.c RTC
  * interface and the SMBus interface of the i2c subsystem.
- * It would be more efficient to use i2c msgs/i2c_transfer directly but, as
- * recommened in .../Documentation/i2c/writing-clients section
- * "Sending and receiving", using SMBus level communication is preferred.
  */
 
 #include <linux/kernel.h>
@@ -42,17 +37,17 @@ static unsigned short ignore[] = { I2C_C
 static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END };
 
 static struct i2c_client_address_data addr_data = {
-	.normal_i2c		= normal_addr,
-	.probe			= ignore,
-	.ignore			= ignore,
+	.normal_i2c	= normal_addr,
+	.probe		= ignore,
+	.ignore		= ignore,
 };
 
 ulong
 m41t00_get_rtc_time(void)
 {
-	s32	sec, min, hour, day, mon, year;
-	s32	sec1, min1, hour1, day1, mon1, year1;
-	ulong	limit = 10;
+	s32 sec, min, hour, day, mon, year;
+	s32 sec1, min1, hour1, day1, mon1, year1;
+	ulong limit = 10;
 
 	sec = min = hour = day = mon = year = 0;
 	sec1 = min1 = hour1 = day1 = mon1 = year1 = 0;
@@ -98,12 +93,12 @@ m41t00_get_rtc_time(void)
 	mon &= 0x1f;
 	year &= 0xff;
 
-	BCD_TO_BIN(sec);
-	BCD_TO_BIN(min);
-	BCD_TO_BIN(hour);
-	BCD_TO_BIN(day);
-	BCD_TO_BIN(mon);
-	BCD_TO_BIN(year);
+	sec = BCD2BIN(sec);
+	min = BCD2BIN(min);
+	hour = BCD2BIN(hour);
+	day = BCD2BIN(day);
+	mon = BCD2BIN(mon);
+	year = BCD2BIN(year);
 
 	year += 1900;
 	if (year < 1970)
@@ -116,17 +111,17 @@ static void
 m41t00_set(void *arg)
 {
 	struct rtc_time	tm;
-	ulong	nowtime = *(ulong *)arg;
+	ulong nowtime = *(ulong *)arg;
 
 	to_tm(nowtime, &tm);
 	tm.tm_year = (tm.tm_year - 1900) % 100;
 
-	BIN_TO_BCD(tm.tm_sec);
-	BIN_TO_BCD(tm.tm_min);
-	BIN_TO_BCD(tm.tm_hour);
-	BIN_TO_BCD(tm.tm_mon);
-	BIN_TO_BCD(tm.tm_mday);
-	BIN_TO_BCD(tm.tm_year);
+	tm.tm_sec = BIN2BCD(tm.tm_sec);
+	tm.tm_min = BIN2BCD(tm.tm_min);
+	tm.tm_hour = BIN2BCD(tm.tm_hour);
+	tm.tm_mon = BIN2BCD(tm.tm_mon);
+	tm.tm_mday = BIN2BCD(tm.tm_mday);
+	tm.tm_year = BIN2BCD(tm.tm_year);
 
 	mutex_lock(&m41t00_mutex);
 	if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0)
@@ -144,10 +139,9 @@ m41t00_set(void *arg)
 		dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n");
 
 	mutex_unlock(&m41t00_mutex);
-	return;
 }
 
-static ulong	new_time;
+static ulong new_time;
 
 int
 m41t00_set_rtc_time(ulong nowtime)
@@ -179,7 +173,7 @@ m41t00_probe(struct i2c_adapter *adap, i
 	if (!client)
 		return -ENOMEM;
 
-	strncpy(client->name, M41T00_DRV_NAME, I2C_NAME_SIZE);
+	strlcpy(client->name, M41T00_DRV_NAME, I2C_NAME_SIZE);
 	client->addr = addr;
 	client->adapter = adap;
 	client->driver = &m41t00_driver;
@@ -203,7 +197,7 @@ m41t00_attach(struct i2c_adapter *adap)
 static int
 m41t00_detach(struct i2c_client *client)
 {
-	int	rc;
+	int rc;
 
 	if ((rc = i2c_detach_client(client)) == 0) {
 		kfree(client);
@@ -214,6 +208,7 @@ m41t00_detach(struct i2c_client *client)
 
 static struct i2c_driver m41t00_driver = {
 	.driver = {
+		.owner	= THIS_MODULE,
 		.name	= M41T00_DRV_NAME,
 	},
 	.id		= I2C_DRIVERID_STM41T00,
@@ -231,7 +226,6 @@ static void __exit
 m41t00_exit(void)
 {
 	i2c_del_driver(&m41t00_driver);
-	return;
 }
 
 module_init(m41t00_init);

  parent reply	other threads:[~2006-03-24  1:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <440B4B6E.8080307@sh.cvut.cz>
     [not found] ` <zt2d4LqL.1141645514.2993990.khali@localhost>
     [not found]   ` <20060307170107.GA5250@mag.az.mvista.com>
     [not found]     ` <20060318001254.GA14079@mag.az.mvista.com>
     [not found]       ` <20060323210856.f1bfd02b.khali@linux-fr.org>
     [not found]         ` <20060323203843.GA18912@mag.az.mvista.com>
2006-03-24  1:18           ` [PATCH 2.6.16-mm1 1/3] rtc: m41t00 driver should use workqueue instead of tasklet Mark A. Greer
2006-03-27 17:03             ` Jean Delvare
2006-03-28  0:22               ` Mark A. Greer
2006-03-24  1:21           ` Mark A. Greer [this message]
2006-03-27 17:11             ` [PATCH 2.6.16-mm1 2/3] rtc: m41t00 driver cleanup Jean Delvare
2006-03-27 22:35               ` Mark A. Greer
2006-03-28  0:23               ` Mark A. Greer
2006-03-24  1:24           ` [PATCH 2.6.16-mm1 3/3] rtc: add support for m41t81 & m41t85 chips to m41t00 driver Mark A. Greer
2006-03-26 22:58             ` Andrew Morton
2006-03-27 22:34               ` Mark A. Greer
2006-03-28  0:26               ` Mark A. Greer
2006-03-28  0:51                 ` Andrew Morton
2006-03-28 12:21                   ` Jean Delvare
2006-03-28 17:15                     ` Mark A. Greer
2006-03-28 15:54                 ` Jean Delvare
2006-03-28 18:11                   ` Mark A. Greer
2006-03-28 18:30                     ` Jean Delvare
2006-03-28 23:12                       ` Mark A. Greer
2006-04-01 17:20                         ` Jean Delvare
2006-04-03 18:01                           ` Mark A. Greer

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=20060324012137.GD9560@mag.az.mvista.com \
    --to=mgreer@mvista.com \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=r.marek@sh.cvut.cz \
    /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

Powered by JetHome