From patchwork Thu Feb 18 14:49:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 584751 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-qk0-x238.google.com (mail-qk0-x238.google.com [IPv6:2607:f8b0:400d:c09::238]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3A9F6140082 for ; Fri, 19 Feb 2016 01:49:57 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b=PycOc0DG; dkim-atps=neutral Received: by mail-qk0-x238.google.com with SMTP id u128sf11700579qkh.1 for ; Thu, 18 Feb 2016 06:49:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references: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=qoQAzdR2VNMO7s0priwDo6nF7tksFjqfhEdVavEg5IY=; b=PycOc0DGKpbMpgVfwVk2ya7f90weT5YxbOVzGMBRYyKO7mN30PgRWN15/VBKw/X+sj Als/vi7IJ2s38Z3BTA95cxjC95zWhLnDO7AEkk9UDT53B7IaPMGfy4DfLgjRt3NbqjN1 ReeShf7rbcmSwabRLUE5QWgx95zT3x9A6bSLYiqeRuKyQF0pnb86oDL7W2oKwPQHbrJU +WtIWUa4f7naU7niGgVQt71+ytNAJ1SzmP/Q0rKEHU1JsN+xvFnqJMpsL1oheytj+iIs Oqpgxo2mfj8/2zO4uH2cfQ/i+LO8k4wXGOnDjyHlqVfS6JIp0gD0IitPMvzKASJGmITL b1KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references: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=qoQAzdR2VNMO7s0priwDo6nF7tksFjqfhEdVavEg5IY=; b=PEJ+rvBBddYGWfXkI7mLAy1zhp2C0R7fHhhbctiFNypPF2tr7GrlzjZJQ3FjMXhF04 f2g0nmY0w5BAXSGhAAqe3Ba6HwNAKdbCHrrMVJGRVLCXTPr/VkMkTZU2yjJ5SlSIOPZR zajLxUI2AZGcAlV8hk2Xg5mvkkxgyFXK5M9GVr+EIt3zSQ360HY4TZvNf2AgyLOCM3/B TCLjfxUkRGVzQU6Y6A6pd/2yiLRf6DN8v0uBZh1HpkN5bUrw9d2k3vXdEKsEcsYlfLew v6eyv1QEsJG3/ufpTVYd6kr/daasFQ/mPRZ6pwjFKc8WdhmL7ZaqsSl1S573n7omWtoU Ebxw== X-Gm-Message-State: AG10YOT8b3uctQBQFOkej60JAgNCTfDVoUKTrgxlKJmn5M793+024bHYLkSZnGkZ0POZIQ== X-Received: by 10.50.155.65 with SMTP id vu1mr72008igb.0.1455806995506; Thu, 18 Feb 2016 06:49:55 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.79.170 with SMTP id k10ls188820igx.9.canary; Thu, 18 Feb 2016 06:49:55 -0800 (PST) X-Received: by 10.50.50.138 with SMTP id c10mr3207070igo.3.1455806995139; Thu, 18 Feb 2016 06:49:55 -0800 (PST) Received: from mail-pa0-x22d.google.com (mail-pa0-x22d.google.com. [2607:f8b0:400e:c03::22d]) by gmr-mx.google.com with ESMTPS id 79si1002499pft.0.2016.02.18.06.49.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Feb 2016 06:49:55 -0800 (PST) Received-SPF: pass (google.com: domain of akinobu.mita@gmail.com designates 2607:f8b0:400e:c03::22d as permitted sender) client-ip=2607:f8b0:400e:c03::22d; Received: by mail-pa0-x22d.google.com with SMTP id fy10so31981277pac.1 for ; Thu, 18 Feb 2016 06:49:55 -0800 (PST) X-Received: by 10.66.141.71 with SMTP id rm7mr10682561pab.106.1455806995028; Thu, 18 Feb 2016 06:49:55 -0800 (PST) Received: from localhost.localdomain (KD113159139091.ppp-bb.dion.ne.jp. [113.159.139.91]) by smtp.gmail.com with ESMTPSA id 69sm10962010pfj.20.2016.02.18.06.49.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Feb 2016 06:49:53 -0800 (PST) From: Akinobu Mita To: rtc-linux@googlegroups.com Cc: Akinobu Mita , Alessandro Zummo , Alexandre Belloni , Dennis Aberilla Subject: [rtc-linux] [PATCH v2 4/4] rtc: ds3232-core: fix read on /dev/rtc after RTC_AIE_ON Date: Thu, 18 Feb 2016 23:49:32 +0900 Message-Id: <1455806972-27284-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455806972-27284-1-git-send-email-akinobu.mita@gmail.com> References: <1455806972-27284-1-git-send-email-akinobu.mita@gmail.com> X-Original-Sender: Akinobu.Mita@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of akinobu.mita@gmail.com designates 2607:f8b0:400e:c03::22d as permitted sender) smtp.mailfrom=akinobu.mita@gmail.com; dkim=pass header.i=@gmail.com; dmarc=pass (p=NONE dis=NONE) header.from=gmail.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: , The rtctest (tools/testing/selftests/timers/rtctest.c) found that reading ds3232 rtc device immediately return the value 0x20 (RTC_AF) without waiting alarm interrupt. This is because alarm_irq_enable() of ds3232 driver changes RTC_AF flag in rtc->irq_data. So calling ioctl with RTC_AIE_ON generates invalid value in rtc device. The lower-level driver should not touch rtc->irq_data directly. Signed-off-by: Akinobu Mita Cc: Alessandro Zummo Cc: Alexandre Belloni Cc: Dennis Aberilla --- * no changes since v1 drivers/rtc/rtc-ds3232-core.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/rtc/rtc-ds3232-core.c b/drivers/rtc/rtc-ds3232-core.c index 600673a..ca29277 100644 --- a/drivers/rtc/rtc-ds3232-core.c +++ b/drivers/rtc/rtc-ds3232-core.c @@ -273,7 +273,7 @@ out: return ret; } -static void ds3232_update_alarm(struct device *dev) +static void ds3232_update_alarm(struct device *dev, unsigned int enabled) { struct ds3232 *ds3232 = dev_get_drvdata(dev); int control; @@ -303,7 +303,7 @@ static void ds3232_update_alarm(struct device *dev) if (control < 0) goto unlock; - if (ds3232->rtc->irq_data & (RTC_AF | RTC_UF)) + if (enabled || (ds3232->rtc->irq_data & RTC_UF)) /* enable alarm1 interrupt */ control |= DS3232_REG_CR_A1IE; else @@ -322,12 +322,8 @@ static int ds3232_alarm_irq_enable(struct device *dev, unsigned int enabled) if (ds3232->ops->irq(dev) <= 0) return -EINVAL; - if (enabled) - ds3232->rtc->irq_data |= RTC_AF; - else - ds3232->rtc->irq_data &= ~RTC_AF; + ds3232_update_alarm(dev, enabled); - ds3232_update_alarm(dev); return 0; }