From patchwork Fri Oct 23 06:29:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 534806 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-pa0-x23f.google.com (mail-pa0-x23f.google.com [IPv6:2607:f8b0:400e:c03::23f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DD0CB141326 for ; Fri, 23 Oct 2015 17:29:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b=GUvAMOfi; dkim-atps=neutral Received: by pabve7 with SMTP id ve7sf21924842pab.1 for ; Thu, 22 Oct 2015 23:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=from:to:cc:subject:date:message-id:mime-version:content-type :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:sender:list-subscribe:list-unsubscribe; bh=j2A/asjgc3pWNKTerv605Z9tKO67CuL9cb05LrjwVRg=; b=GUvAMOfiAk5Ck2aeu0ehM6zFMsmFu7IPcRhNmDe3af0qlp6YlQP1NV5rfzfZR1jUIe T+v4pswEHlchAFqLYfcffMqoYBe8Z1EwBf87ScDj+29eS676Rc8S9BBAmpxRJgnaBiaX iKZZhHzUIe7jzjBwLkytrrW9YomKx4ya0gtljPkIGDqNRSMQ/CZyTJ/L+TIyF0dhOl6y BdteDBGpFdZZJEMAfV4ag+khsp62VPyi6kxqoih1UAMioitYFT0ou93FYNtPXmCTXWLt xxM1dIFjskz/9sbPpR7/iycvsS6ojLpAquZbvlohqJJkmqWVALBNwvNGADwdxUYVHnno L7Yg== X-Received: by 10.50.6.40 with SMTP id x8mr49636igx.0.1445581794492; Thu, 22 Oct 2015 23:29:54 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.66.230 with SMTP id i6ls133880igt.38.canary; Thu, 22 Oct 2015 23:29:54 -0700 (PDT) X-Received: by 10.66.255.3 with SMTP id am3mr1882318pad.30.1445581794143; Thu, 22 Oct 2015 23:29:54 -0700 (PDT) Received: from comal.ext.ti.com (comal.ext.ti.com. [198.47.26.152]) by gmr-mx.google.com with ESMTPS id z7si361086igw.0.2015.10.22.23.29.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 22 Oct 2015 23:29:54 -0700 (PDT) Received-SPF: pass (google.com: domain of t-kristo@ti.com designates 198.47.26.152 as permitted sender) client-ip=198.47.26.152; Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id t9N6Tpvm006601; Fri, 23 Oct 2015 01:29:51 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t9N6Tosb026746; Fri, 23 Oct 2015 01:29:51 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Fri, 23 Oct 2015 01:29:51 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t9N6Tl7f023245; Fri, 23 Oct 2015 01:29:48 -0500 From: Tero Kristo To: , CC: , , , Subject: [rtc-linux] [PATCH] rtc: ds1307: Fix alarm programming for mcp794xx Date: Fri, 23 Oct 2015 09:29:57 +0300 Message-ID: <1445581797-19693-1-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Original-Sender: t-kristo@ti.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of t-kristo@ti.com designates 198.47.26.152 as permitted sender) smtp.mailfrom=t-kristo@ti.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: rtc-linux@googlegroups.com X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , mcp794xx alarm registers must be written in BCD format. However, the alarm programming logic neglected this by adding one to the value after bin2bcd conversion has been already done, writing bad values to month register in case the alarm being set is in October. In this case, the alarm month value becomes 0x0a instead of the expected 0x10. Fix by moving the +1 addition within the bin2bcd call also. Fixes: 1d1945d261a2 ("drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips") Signed-off-by: Tero Kristo Acked-by: Nishanth Menon --- drivers/rtc/rtc-ds1307.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index a705e64..188006c 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -718,9 +718,9 @@ static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t) regs[3] = bin2bcd(t->time.tm_sec); regs[4] = bin2bcd(t->time.tm_min); regs[5] = bin2bcd(t->time.tm_hour); - regs[6] = bin2bcd(t->time.tm_wday) + 1; + regs[6] = bin2bcd(t->time.tm_wday + 1); regs[7] = bin2bcd(t->time.tm_mday); - regs[8] = bin2bcd(t->time.tm_mon) + 1; + regs[8] = bin2bcd(t->time.tm_mon + 1); /* Clear the alarm 0 interrupt flag. */ regs[6] &= ~MCP794XX_BIT_ALMX_IF;