Patchwork [3/3] rtc-fm3130: improve readability

login
register
mail settings
Submitter Sergey Matyukevich
Date Nov. 18, 2009, 7:45 p.m.
Message ID <1258573509-12263-4-git-send-email-geomatsi@gmail.com>
Download mbox | patch
Permalink /patch/38786/
State Deferred
Headers show

Comments

Sergey Matyukevich - Nov. 18, 2009, 7:45 p.m.
add whitespaces and empty lines to improve code readability

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
---
 drivers/rtc/rtc-fm3130.c |   40 +++++++++++++++++++++++++---------------
 1 files changed, 25 insertions(+), 15 deletions(-)

Patch

diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c
index e18aed3..b497dfa 100644
--- a/drivers/rtc/rtc-fm3130.c
+++ b/drivers/rtc/rtc-fm3130.c
@@ -31,15 +31,15 @@ 
 #define FM3130_ALARM_MONTHS	(0xd)
 #define FM3130_ALARM_WP_CONTROL	(0xe)
 
-#define FM3130_CAL_CONTROL_BIT_nOSCEN (1 << 7) /* Osciallator enabled */
-#define FM3130_RTC_CONTROL_BIT_LB (1 << 7) /* Low battery */
-#define FM3130_RTC_CONTROL_BIT_AF (1 << 6) /* Alarm flag */
-#define FM3130_RTC_CONTROL_BIT_CF (1 << 5) /* Century overflow */
-#define FM3130_RTC_CONTROL_BIT_POR (1 << 4) /* Power on reset */
-#define FM3130_RTC_CONTROL_BIT_AEN (1 << 3) /* Alarm enable */
-#define FM3130_RTC_CONTROL_BIT_CAL (1 << 2) /* Calibration mode */
-#define FM3130_RTC_CONTROL_BIT_WRITE (1 << 1) /* W=1 -> write mode W=0 normal */
-#define FM3130_RTC_CONTROL_BIT_READ (1 << 0) /* R=1 -> read mode R=0 normal */
+#define FM3130_CAL_CONTROL_BIT_nOSCEN 	(1 << 7) /* Osciallator enabled */
+#define FM3130_RTC_CONTROL_BIT_LB 	(1 << 7) /* Low battery */
+#define FM3130_RTC_CONTROL_BIT_AF 	(1 << 6) /* Alarm flag */
+#define FM3130_RTC_CONTROL_BIT_CF 	(1 << 5) /* Century overflow */
+#define FM3130_RTC_CONTROL_BIT_POR 	(1 << 4) /* Power on reset */
+#define FM3130_RTC_CONTROL_BIT_AEN 	(1 << 3) /* Alarm enable */
+#define FM3130_RTC_CONTROL_BIT_CAL 	(1 << 2) /* Calibration mode */
+#define FM3130_RTC_CONTROL_BIT_WRITE 	(1 << 1) /* Write RTC */
+#define FM3130_RTC_CONTROL_BIT_READ 	(1 << 0) /* Read RTC */
 
 #define FM3130_CLOCK_REGS 7
 #define FM3130_ALARM_REGS 5
@@ -54,10 +54,12 @@  struct fm3130 {
 	int			alarm_valid;
 	int			data_valid;
 };
+
 static const struct i2c_device_id fm3130_id[] = {
 	{ "fm3130", 0 },
 	{ }
 };
+
 MODULE_DEVICE_TABLE(i2c, fm3130_id);
 
 #define FM3130_MODE_NORMAL		0
@@ -74,7 +76,7 @@  static void fm3130_rtc_mode(struct device *dev, int mode)
 	case FM3130_MODE_NORMAL:
 		fm3130->regs[FM3130_RTC_CONTROL] &=
 			~(FM3130_RTC_CONTROL_BIT_WRITE |
-			FM3130_RTC_CONTROL_BIT_READ);
+				FM3130_RTC_CONTROL_BIT_READ);
 		break;
 	case FM3130_MODE_WRITE:
 		fm3130->regs[FM3130_RTC_CONTROL] |= FM3130_RTC_CONTROL_BIT_WRITE;
@@ -99,7 +101,7 @@  static int fm3130_get_time(struct device *dev, struct rtc_time *t)
 	if (!fm3130->data_valid) {
 		/* We have invalid data in RTC, probably due
 		to battery faults or other problems. Return EIO
-		for now, it will allow us to set data later insted
+		for now, it will allow us to set data later instead
 		of error during probing which disables device */
 		return -EIO;
 	}
@@ -149,12 +151,11 @@  static int fm3130_get_time(struct device *dev, struct rtc_time *t)
 	return rtc_valid_tm(t);
 }
 
-
 static int fm3130_set_time(struct device *dev, struct rtc_time *t)
 {
 	struct fm3130 *fm3130 = dev_get_drvdata(dev);
-	int		tmp, i;
-	u8		*buf = fm3130->regs;
+	u8 *buf = fm3130->regs;
+	int tmp, i;
 
 	dev_dbg(dev, "%s secs=%d, mins=%d, "
 		"hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n",
@@ -201,8 +202,8 @@  static int fm3130_set_time(struct device *dev, struct rtc_time *t)
 static int fm3130_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
 	struct fm3130 *fm3130 = dev_get_drvdata(dev);
-	int tmp;
 	struct rtc_time *tm = &alrm->time;
+	int tmp;
 
 	if (!fm3130->alarm_valid) {
 		/* We have invalid alarm in RTC, probably due
@@ -215,10 +216,12 @@  static int fm3130_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	/* read the RTC alarm registers all at once */
 	tmp = i2c_transfer(to_i2c_adapter(fm3130->client->dev.parent),
 			&fm3130->msg[2], 2);
+
 	if (tmp != 2) {
 		dev_err(dev, "%s error %d\n", "read", tmp);
 		return -EIO;
 	}
+
 	dev_dbg(dev, "alarm read %02x %02x %02x %02x %02x\n",
 			fm3130->regs[FM3130_ALARM_SECONDS],
 			fm3130->regs[FM3130_ALARM_MINUTES],
@@ -287,12 +290,14 @@  static int fm3130_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 			fm3130->regs[FM3130_ALARM_HOURS],
 			fm3130->regs[FM3130_ALARM_DATE],
 			fm3130->regs[FM3130_ALARM_MONTHS]);
+
 	/* Writing time registers, we don't support multibyte transfers */
 	for (i = 0; i < FM3130_ALARM_REGS; i++) {
 		i2c_smbus_write_byte_data(fm3130->client,
 					FM3130_ALARM_SECONDS + i,
 					fm3130->regs[FM3130_ALARM_SECONDS + i]);
 	}
+
 	fm3130->regs[FM3130_RTC_CONTROL] =
 		i2c_smbus_read_byte_data(fm3130->client, FM3130_RTC_CONTROL);
 
@@ -415,6 +420,7 @@  static int __devinit fm3130_probe(struct i2c_client *client,
 
 	fm3130->regs[FM3130_RTC_CONTROL] =
 		i2c_smbus_read_byte_data(client, FM3130_RTC_CONTROL);
+
 	fm3130->regs[FM3130_CAL_CONTROL] =
 		i2c_smbus_read_byte_data(client, FM3130_CAL_CONTROL);
 
@@ -457,6 +463,7 @@  static int __devinit fm3130_probe(struct i2c_client *client,
 				~FM3130_RTC_CONTROL_BIT_POR);
 		dev_dbg(&client->dev, "POR bit is set\n");
 	}
+
 	/* ACS is controlled by alarm */
 	i2c_smbus_write_byte_data(client, FM3130_ALARM_WP_CONTROL, 0x80);
 
@@ -532,13 +539,16 @@  bad_clock:
 	   Time setting from u-boot doesn't work anyway */
 	fm3130->rtc = rtc_device_register(client->name, &client->dev,
 				&fm3130_rtc_ops, THIS_MODULE);
+
 	if (IS_ERR(fm3130->rtc)) {
 		err = PTR_ERR(fm3130->rtc);
 		dev_err(&client->dev,
 			"unable to register the class device\n");
 		goto exit_free;
 	}
+
 	return 0;
+
 exit_free:
 	kfree(fm3130);
 	return err;