From patchwork Thu Jul 20 23:18:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 791795 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-rtc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="WrUUfqI/"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xD8wR5PHkz9s72 for ; Fri, 21 Jul 2017 09:18:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964998AbdGTXSr (ORCPT ); Thu, 20 Jul 2017 19:18:47 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:58048 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964882AbdGTXSq (ORCPT ); Thu, 20 Jul 2017 19:18:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Date:Sender:Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References:In-Reply-To; bh=j0ZEv6OpxaJs7whGXUznR251t0ZyExmRdg+MoBGZMfw=; b=WrUUfqI/U9KtaGZaq+JHzWFYyI8p+PdQ2csbHKjN1qQhoatUMCeMuiYBscLxzfgCxWkctT9j5n92k9IPYygnzeZGa06W7Gedwfg37lOjBvA+q0H4oGP8UHMEdtdlQFyEWOx0HVUiieRyPGHyPGda1u+25iuoi8DVU6D6Vx5nnJc=; Received: from e0022681537dd.dyn.armlinux.org.uk ([2001:4d48:ad52:3201:222:68ff:fe15:37dd]:38124 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1dYKiM-0004wR-GO; Fri, 21 Jul 2017 00:18:38 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1dYKiK-0001kZ-6E; Fri, 21 Jul 2017 00:18:36 +0100 In-Reply-To: <20170720231745.GE31807@n2100.armlinux.org.uk> References: <20170720231745.GE31807@n2100.armlinux.org.uk> From: Russell King To: Alessandro Zummo Cc: Linus Walleij , Alexandre Belloni , linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org Subject: [PATCH 3/4] rtc: pl031: avoid exposing alarm if no interrupt MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 21 Jul 2017 00:18:36 +0100 Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org If the RTC has no interrupt, there is little point in exposing the RTC alarm capabilities, as it can't be used as a wakeup source nor can it deliver an event to userspace. Signed-off-by: Russell King Reviewed-by: Linus Walleij --- drivers/rtc/rtc-pl031.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index 5960fbd08b05..64c77ec1b4ea 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c @@ -329,12 +329,14 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) ldata = devm_kzalloc(&adev->dev, sizeof(struct pl031_local), GFP_KERNEL); - if (!ldata) { + ops = devm_kmemdup(&adev->dev, &vendor->ops, sizeof(vendor->ops), + GFP_KERNEL); + if (!ldata || !ops) { ret = -ENOMEM; goto out; } - ldata->vendor = vendor; + ldata->vendor = vendor; ldata->base = devm_ioremap(&adev->dev, adev->res.start, resource_size(&adev->res)); if (!ldata->base) { @@ -372,6 +374,13 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) } } + if (!adev->irq[0]) { + /* When there's no interrupt, no point in exposing the alarm */ + ops->read_alarm = NULL; + ops->set_alarm = NULL; + ops->alarm_irq_enable = NULL; + } + device_init_wakeup(&adev->dev, true); ldata->rtc = rtc_device_register("pl031", &adev->dev, ops, THIS_MODULE);