From patchwork Fri Aug 18 18:51:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 110429 Delivered-To: patches@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1287536qge; Fri, 18 Aug 2017 11:51:18 -0700 (PDT) X-Received: by 10.98.153.72 with SMTP id d69mr9582820pfe.42.1503082278160; Fri, 18 Aug 2017 11:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503082278; cv=none; d=google.com; s=arc-20160816; b=JmPNnnDoOdrr6gHPPz/W+2XKd8fYF0gYYUfUcvXeRR8Lcd+i6abhLE1BuV4IMOSJVJ Tq8v2eF0pw+iStkKreFCG+PYoHkxZ4dN6bQauLqpJEsxfjWN3UE9XnZ40LoswWQGZDbd XAd5EVEShNOZKNVmQKyuwTf9twyPNBHeuXK8tnRnejYzc2YBHSIBTAr0d+HQ67/mBwJ2 k8OwEMxP2ZBMpk0+F91tbxuZu6xHjYix8WH3xUsCt3tQggFz6nIpivOKhJIoLletwCvb jiCQlrfa2hd4fyvzOhdeCYFFA6rk/imbns+OP5VJf0lkziLFC1+L0RUaQcgxDY2P9m9a qg2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=6pQAXFbmxJV7I+O44FkmresS14+0glnCnVod1cGQ8K4=; b=iYV8wpXt3mUlq7FpC8E5cwcgTMDD71AF708Caqq9NgTr214pWqBp3HstQELZED4Boy pZyqBhLfRCp6NKPDynBL3w/I2GVgOQpE1jQAguIKFsvJ6SCPEvYZAG+DqcWz+VMlZ8ov Ryek8URur64fT1ysWNcHvdm8SYgxjEvJBJuWPU3Q5miWu+6zMkffqxTV1htR1RzLnCEd 9IhSY9NoaKCyGrADBVaur+62opHadDclkS5O2v7NWItyQuXEDWQKmphSAWwX0YRyUvcc BZxRR7iY5T3S1drwatmqWbYb+BhamDNvWTPJQ7OnYs7cJFAwKd0tXPEayBI8btBW9xhY oxWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TkBkxZpK; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22e as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-pg0-x22e.google.com (mail-pg0-x22e.google.com. [2607:f8b0:400e:c05::22e]) by mx.google.com with ESMTPS id h3si4336095pln.575.2017.08.18.11.51.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 11:51:18 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22e as permitted sender) client-ip=2607:f8b0:400e:c05::22e; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TkBkxZpK; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22e as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22e.google.com with SMTP id t80so41913521pgb.5 for ; Fri, 18 Aug 2017 11:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6pQAXFbmxJV7I+O44FkmresS14+0glnCnVod1cGQ8K4=; b=TkBkxZpKqdU7aqNVdT/6CuQnLyCM7LbCNZaI0g+lNgmDZ3cbE1+8ocMC9qt1cgtIVR SfbCsxl3ty5/ukksvtJRVozs9q5Z8SCBBgmJsBV6UC8KJ2CKbRcZH0mrr/+dHO1obYbx i9247JtsBQGZDLSw+92ZC/9+rqYmiUPR94QuY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6pQAXFbmxJV7I+O44FkmresS14+0glnCnVod1cGQ8K4=; b=RAzZZqGWAijsOixkpfcoLvpWUUz2LEU724Dppv6nfcWUnLxjzR5bhK2L8IdWkAuDE6 qfcGQdzQyklBPrONxfq6uG0MQaOkTCuRsGLq2lHurlDkXWs7jCuvtjOOto1A7L9FU0Ss ifeBzru/W5ECb0R4uh1zeJ6usHCGUF3QfLEGH3NzXiGk32WT3GxOTuuojpcJTdYeY/rj YTjamFRlGrcTWk2d179QOAKnyJKPJ0NfvCLs74Hbs3d1H9Pbf5FxWiGMzceSRdYMyCd6 /ZV1/RtDOzY6WcZNcopC/ELKxV/Wn9gVGre0vMJ/Cw1RXuA+UV/II/MM/JAYWoviX5wV t/nQ== X-Gm-Message-State: AHYfb5iQPOuIQ3K5n6p7H6QsWv8nrYxFqLdUHZfsOFnhacl1QWZDrD+m xkHeWSYQESN3/qF4poQ= X-Received: by 10.98.153.153 with SMTP id t25mr9610479pfk.224.1503082277886; Fri, 18 Aug 2017 11:51:17 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id l132sm12518790pfc.150.2017.08.18.11.51.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Aug 2017 11:51:16 -0700 (PDT) From: John Stultz To: lkml Cc: Geert Uytterhoeven , Thomas Gleixner , Ingo Molnar , Miroslav Lichvar , Richard Cochran , Prarit Bhargava , Stephen Boyd , John Stultz Subject: [PATCH 6/6] alarmtimer: Fix unavailable wake-up source in sysfs Date: Fri, 18 Aug 2017 11:51:02 -0700 Message-Id: <1503082262-29450-7-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503082262-29450-1-git-send-email-john.stultz@linaro.org> References: <1503082262-29450-1-git-send-email-john.stultz@linaro.org> From: Geert Uytterhoeven Currently the alarmtimer registers a wake-up source unconditionally, regardless of the system having a (wake-up capable) RTC or not. Hence the alarmtimer will always show up in /sys/kernel/debug/wakeup_sources, even if it is not available, and thus cannot be a wake-up source. To fix this, postpone registration until a wake-up capable RTC device is added. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Miroslav Lichvar Cc: Richard Cochran Cc: Prarit Bhargava Cc: Stephen Boyd Signed-off-by: Geert Uytterhoeven Signed-off-by: John Stultz --- kernel/time/alarmtimer.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 0b8ff7d..73a2b47 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -56,9 +56,9 @@ static ktime_t freezer_delta; static DEFINE_SPINLOCK(freezer_delta_lock); #endif +#ifdef CONFIG_RTC_CLASS static struct wakeup_source *ws; -#ifdef CONFIG_RTC_CLASS /* rtc timer and device for setting alarm wakeups at suspend */ static struct rtc_timer rtctimer; static struct rtc_device *rtcdev; @@ -89,6 +89,7 @@ static int alarmtimer_rtc_add_device(struct device *dev, { unsigned long flags; struct rtc_device *rtc = to_rtc_device(dev); + struct wakeup_source *__ws; if (rtcdev) return -EBUSY; @@ -98,13 +99,20 @@ static int alarmtimer_rtc_add_device(struct device *dev, if (!device_may_wakeup(rtc->dev.parent)) return -1; + __ws = wakeup_source_register("alarmtimer"); + spin_lock_irqsave(&rtcdev_lock, flags); if (!rtcdev) { rtcdev = rtc; /* hold a reference so it doesn't go away */ get_device(dev); + ws = __ws; + __ws = NULL; } spin_unlock_irqrestore(&rtcdev_lock, flags); + + wakeup_source_unregister(__ws); + return 0; } @@ -860,7 +868,6 @@ static int __init alarmtimer_init(void) error = PTR_ERR(pdev); goto out_drv; } - ws = wakeup_source_register("alarmtimer"); return 0; out_drv: