Commit d973b632 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds

rtc-x1205: unconditionally set date when setting clock

All callsites of x1205_set_datetime() want the date to be set as well, so
remove the flag parameter and set it unconditionally.
Signed-off-by: default avatarJohannes Weiner <jw@emlix.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Paul Gortmaker <p_gortmaker@yahoo.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a91912f8
...@@ -155,11 +155,11 @@ static int x1205_get_status(struct i2c_client *client, unsigned char *sr) ...@@ -155,11 +155,11 @@ static int x1205_get_status(struct i2c_client *client, unsigned char *sr)
} }
static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
int datetoo, u8 reg_base, unsigned char alm_enable) u8 reg_base, unsigned char alm_enable)
{ {
int i, xfer, nbytes; int i, xfer;
unsigned char buf[8];
unsigned char rdata[10] = { 0, reg_base }; unsigned char rdata[10] = { 0, reg_base };
unsigned char *buf = rdata + 2;
static const unsigned char wel[3] = { 0, X1205_REG_SR, static const unsigned char wel[3] = { 0, X1205_REG_SR,
X1205_SR_WEL }; X1205_SR_WEL };
...@@ -170,9 +170,9 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, ...@@ -170,9 +170,9 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
static const unsigned char diswe[3] = { 0, X1205_REG_SR, 0 }; static const unsigned char diswe[3] = { 0, X1205_REG_SR, 0 };
dev_dbg(&client->dev, dev_dbg(&client->dev,
"%s: secs=%d, mins=%d, hours=%d\n", "%s: sec=%d min=%d hour=%d mday=%d mon=%d year=%d wday=%d\n",
__func__, __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday,
tm->tm_sec, tm->tm_min, tm->tm_hour); tm->tm_mon, tm->tm_year, tm->tm_wday);
buf[CCR_SEC] = bin2bcd(tm->tm_sec); buf[CCR_SEC] = bin2bcd(tm->tm_sec);
buf[CCR_MIN] = bin2bcd(tm->tm_min); buf[CCR_MIN] = bin2bcd(tm->tm_min);
...@@ -180,13 +180,6 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, ...@@ -180,13 +180,6 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
/* set hour and 24hr bit */ /* set hour and 24hr bit */
buf[CCR_HOUR] = bin2bcd(tm->tm_hour) | X1205_HR_MIL; buf[CCR_HOUR] = bin2bcd(tm->tm_hour) | X1205_HR_MIL;
/* should we also set the date? */
if (datetoo) {
dev_dbg(&client->dev,
"%s: mday=%d, mon=%d, year=%d, wday=%d\n",
__func__,
tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
buf[CCR_MDAY] = bin2bcd(tm->tm_mday); buf[CCR_MDAY] = bin2bcd(tm->tm_mday);
/* month, 1 - 12 */ /* month, 1 - 12 */
...@@ -196,7 +189,6 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, ...@@ -196,7 +189,6 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
buf[CCR_YEAR] = bin2bcd(tm->tm_year % 100); buf[CCR_YEAR] = bin2bcd(tm->tm_year % 100);
buf[CCR_WDAY] = tm->tm_wday & 0x07; buf[CCR_WDAY] = tm->tm_wday & 0x07;
buf[CCR_Y2K] = bin2bcd((tm->tm_year + 1900) / 100); buf[CCR_Y2K] = bin2bcd((tm->tm_year + 1900) / 100);
}
/* If writing alarm registers, set compare bits on registers 0-4 */ /* If writing alarm registers, set compare bits on registers 0-4 */
if (reg_base < X1205_CCR_BASE) if (reg_base < X1205_CCR_BASE)
...@@ -214,17 +206,8 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, ...@@ -214,17 +206,8 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
return -EIO; return -EIO;
} }
xfer = i2c_master_send(client, rdata, sizeof(rdata));
/* write register's data */ if (xfer != sizeof(rdata)) {
if (datetoo)
nbytes = 8;
else
nbytes = 3;
for (i = 0; i < nbytes; i++)
rdata[2+i] = buf[i];
xfer = i2c_master_send(client, rdata, nbytes+2);
if (xfer != nbytes+2) {
dev_err(&client->dev, dev_err(&client->dev,
"%s: result=%d addr=%02x, data=%02x\n", "%s: result=%d addr=%02x, data=%02x\n",
__func__, __func__,
...@@ -282,7 +265,7 @@ static int x1205_fix_osc(struct i2c_client *client) ...@@ -282,7 +265,7 @@ static int x1205_fix_osc(struct i2c_client *client)
memset(&tm, 0, sizeof(tm)); memset(&tm, 0, sizeof(tm));
err = x1205_set_datetime(client, &tm, 1, X1205_CCR_BASE, 0); err = x1205_set_datetime(client, &tm, X1205_CCR_BASE, 0);
if (err < 0) if (err < 0)
dev_err(&client->dev, "unable to restart the oscillator\n"); dev_err(&client->dev, "unable to restart the oscillator\n");
...@@ -481,7 +464,7 @@ static int x1205_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -481,7 +464,7 @@ static int x1205_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
static int x1205_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) static int x1205_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{ {
return x1205_set_datetime(to_i2c_client(dev), return x1205_set_datetime(to_i2c_client(dev),
&alrm->time, 1, X1205_ALM0_BASE, alrm->enabled); &alrm->time, X1205_ALM0_BASE, alrm->enabled);
} }
static int x1205_rtc_read_time(struct device *dev, struct rtc_time *tm) static int x1205_rtc_read_time(struct device *dev, struct rtc_time *tm)
...@@ -493,7 +476,7 @@ static int x1205_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -493,7 +476,7 @@ static int x1205_rtc_read_time(struct device *dev, struct rtc_time *tm)
static int x1205_rtc_set_time(struct device *dev, struct rtc_time *tm) static int x1205_rtc_set_time(struct device *dev, struct rtc_time *tm)
{ {
return x1205_set_datetime(to_i2c_client(dev), return x1205_set_datetime(to_i2c_client(dev),
tm, 1, X1205_CCR_BASE, 0); tm, X1205_CCR_BASE, 0);
} }
static int x1205_rtc_proc(struct device *dev, struct seq_file *seq) static int x1205_rtc_proc(struct device *dev, struct seq_file *seq)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment