From patchwork Wed Nov 25 16:32:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 39320 Return-Path: <32FsNSwIJCYwzCu21yD.s4279s-1y3ADw44w1uw74A58.s42@listserv.bounces.google.com> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-yw0-f146.google.com (mail-yw0-f146.google.com [209.85.211.146]) by ozlabs.org (Postfix) with ESMTP id 28600B7BA5 for ; Thu, 26 Nov 2009 03:31:22 +1100 (EST) Received: by ywh10 with SMTP id 10sf14160981ywh.1 for ; Wed, 25 Nov 2009 08:31:21 -0800 (PST) Received: by 10.90.59.3 with SMTP id h3mr518888aga.36.1259166681008; Wed, 25 Nov 2009 08:31:21 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.213.37.194 with SMTP id y2ls146103ebd.3.p; Wed, 25 Nov 2009 08:31:19 -0800 (PST) Received: by 10.213.103.202 with SMTP id l10mr1100982ebo.5.1259166679588; Wed, 25 Nov 2009 08:31:19 -0800 (PST) Received: by 10.213.103.202 with SMTP id l10mr1100980ebo.5.1259166679572; Wed, 25 Nov 2009 08:31:19 -0800 (PST) Received: from mx1.emlix.com (mx1.emlix.com [193.175.82.87]) by gmr-mx.google.com with ESMTP id 18si663058ewy.4.2009.11.25.08.31.19; Wed, 25 Nov 2009 08:31:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of jw@emlix.com designates 193.175.82.87 as permitted sender) client-ip=193.175.82.87; Received: from gate.emlix.com ([193.175.27.217]:53609 helo=mailer.emlix.com) by mx1.emlix.com with esmtp (Exim 4.63) (envelope-from ) id 1NDKlv-0006ND-FA; Wed, 25 Nov 2009 17:31:15 +0100 Received: by mailer.emlix.com id 1NDKlv-0004wT-Cq; Wed, 25 Nov 2009 17:31:15 +0100 From: Johannes Weiner To: Alessandro Zummo , Paul Gortmaker Cc: Andrew Morton , rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [rtc-linux] [patch 3/3] rtc-x1205: unconditionally set date when setting clock Date: Wed, 25 Nov 2009 17:32:16 +0100 Message-Id: <1259166736-31006-3-git-send-email-jw@emlix.com> In-Reply-To: <1259166736-31006-1-git-send-email-jw@emlix.com> References: <1259166736-31006-1-git-send-email-jw@emlix.com> Organization: emlix gmbh, Goettingen, Germany X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of jw@emlix.com designates 193.175.82.87 as permitted sender) smtp.mail=jw@emlix.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: X-Thread-Url: http://groups.google.com/group/rtc-linux/t/bfc22d084dca0f6f X-Message-Url: http://groups.google.com/group/rtc-linux/msg/d4d9a244fd9311b0 List-Unsubscribe: , List-Subscribe: , 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: Johannes Weiner --- drivers/rtc/rtc-x1205.c | 53 ++++++++++++++++------------------------------- 1 files changed, 18 insertions(+), 35 deletions(-) diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index 6583c1a..9aae491 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c @@ -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, - int datetoo, u8 reg_base, unsigned char alm_enable) + u8 reg_base, unsigned char alm_enable) { - int i, xfer, nbytes; - unsigned char buf[8]; + int i, xfer; unsigned char rdata[10] = { 0, reg_base }; + unsigned char *buf = rdata + 2; static const unsigned char wel[3] = { 0, X1205_REG_SR, X1205_SR_WEL }; @@ -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 }; dev_dbg(&client->dev, - "%s: secs=%d, mins=%d, hours=%d\n", - __func__, - tm->tm_sec, tm->tm_min, tm->tm_hour); + "%s: sec=%d min=%d hour=%d mday=%d mon=%d year=%d wday=%d\n", + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, + tm->tm_mon, tm->tm_year, tm->tm_wday); buf[CCR_SEC] = bin2bcd(tm->tm_sec); buf[CCR_MIN] = bin2bcd(tm->tm_min); @@ -180,23 +180,15 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, /* set hour and 24hr bit */ 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 */ + buf[CCR_MONTH] = bin2bcd(tm->tm_mon + 1); - /* month, 1 - 12 */ - buf[CCR_MONTH] = bin2bcd(tm->tm_mon + 1); - - /* year, since the rtc epoch*/ - buf[CCR_YEAR] = bin2bcd(tm->tm_year % 100); - buf[CCR_WDAY] = tm->tm_wday & 0x07; - buf[CCR_Y2K] = bin2bcd((tm->tm_year + 1900) / 100); - } + /* year, since the rtc epoch*/ + buf[CCR_YEAR] = bin2bcd(tm->tm_year % 100); + buf[CCR_WDAY] = tm->tm_wday & 0x07; + buf[CCR_Y2K] = bin2bcd((tm->tm_year + 1900) / 100); /* If writing alarm registers, set compare bits on registers 0-4 */ if (reg_base < X1205_CCR_BASE) @@ -214,17 +206,8 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, return -EIO; } - - /* write register's data */ - 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) { + xfer = i2c_master_send(client, rdata, sizeof(rdata)); + if (xfer != sizeof(rdata)) { dev_err(&client->dev, "%s: result=%d addr=%02x, data=%02x\n", __func__, @@ -282,7 +265,7 @@ static int x1205_fix_osc(struct i2c_client *client) 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) 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) static int x1205_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) { 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) @@ -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) { 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)