From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755062AbcIEW1N (ORCPT ); Mon, 5 Sep 2016 18:27:13 -0400 Received: from down.free-electrons.com ([37.187.137.238]:57174 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754468AbcIEW1J (ORCPT ); Mon, 5 Sep 2016 18:27:09 -0400 Date: Tue, 6 Sep 2016 00:26:56 +0200 From: Alexandre Belloni To: Gabriele Mazzotta Cc: a.zummo@towertech.it, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, matthew.garrett@nebula.com Subject: Re: [PATCH v2 1/2] rtc-cmos: Ensure no expired alarm is left enabled after resume Message-ID: <20160905222656.ziowskma2gizsjtj@piout.net> References: <20160831225900.20122-1-gabriele.mzt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160831225900.20122-1-gabriele.mzt@gmail.com> User-Agent: Mutt/1.6.2-neo (2016-07-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi On 01/09/2016 at 00:58:59 +0200, Gabriele Mazzotta wrote : > static int cmos_resume(struct device *dev) > { > struct cmos_rtc *cmos = dev_get_drvdata(dev); > unsigned char tmp; > + bool is_wkalrm_expired; > > if (cmos->enabled_wake) { > if (cmos->wake_off) > @@ -913,6 +935,8 @@ static int cmos_resume(struct device *dev) > cmos->enabled_wake = 0; > } > > + is_wkalrm_expired = cmos_is_wkalrm_expired(dev); > + > spin_lock_irq(&rtc_lock); > tmp = cmos->suspend_ctrl; > cmos->suspend_ctrl = 0; > @@ -939,6 +963,17 @@ static int cmos_resume(struct device *dev) > tmp &= ~RTC_AIE; > hpet_mask_rtc_irq_bit(RTC_AIE); > } while (mask & RTC_AIE); > + > + /* > + * If RTC_AIE is set and we have an alarm set to go off in the > + * past, then the BIOS woke the system when the alarm went off > + * and we now have to clear it. > + */ > + if ((tmp & RTC_AIE) && is_wkalrm_expired) { Is there any issue dropping is_wkalrm_expired and calling cmos_is_wkalrm_expired() here? That would avoid calling cmos_is_wkalrm_expired on each wakeup. -- Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com