From patchwork Tue Jul 21 13:50:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6836281 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C4656C05AC for ; Tue, 21 Jul 2015 13:55:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1C86206A0 for ; Tue, 21 Jul 2015 13:55:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 208182069A for ; Tue, 21 Jul 2015 13:55:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXz5-0005Dj-79; Tue, 21 Jul 2015 13:53:27 +0000 Received: from mail-wi0-x22e.google.com ([2a00:1450:400c:c05::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXxy-0004h6-Nc for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2015 13:52:19 +0000 Received: by wibxm9 with SMTP id xm9so57878974wib.1 for ; Tue, 21 Jul 2015 06:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=OXZsfq6qnZLQyawgs4a0VYah32HrzVIyGXecN4v4YE0=; b=kKD+MphcXf9jSiYbc0dXGM7vN9ULYi/T2GfQQUQQEWlTg9PLoSbfx4lkT4pFoWE9p1 yCLN8xX1DnLm1ykgsl0zijNaXXq+u445XpG4Q3Iyo8ANicryk2F2C6/vl6eMeZsxd8C+ NZpnugxXYnWD7wQTvVzPKP39DjuHO22p1MYvdUd2WtP9D1YF4kVx+bPFPZ7P5Ka3q/PF DqzULOtDANiyskDXFTNad8IFJpJonj6BsHqwZFYXBVLdkQRWN8fZoIPrKjVII1fEO7AC zWVCzZU6FthDQOKdqeJwhvIvdMfwfIrxLDZzzUog0SaVPmvt6kSCk1MwSibZ1Q7mqtlh 28ag== X-Received: by 10.180.81.106 with SMTP id z10mr30407205wix.22.1437486717072; Tue, 21 Jul 2015 06:51:57 -0700 (PDT) Received: from cizrna.lan ([109.72.12.178]) by smtp.gmail.com with ESMTPSA id pf4sm37172056wjb.23.2015.07.21.06.51.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 06:51:56 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [RFC PATCH 06/16] Add DEVM_CLOCK() Date: Tue, 21 Jul 2015 15:50:48 +0200 Message-Id: <1437486658-28365-7-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> References: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150721_065218_960771_9C12E076 X-CRM114-Status: GOOD ( 11.74 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Tomeu Vizoso , Stephen Warren , "Rafael J. Wysocki" , Mark Brown , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Tomeu Vizoso --- drivers/clk/clk.c | 13 +++++++++++++ include/linux/clk.h | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 1b5fe3da6b55..b51b54846284 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2705,6 +2705,19 @@ void devm_clk_unregister(struct device *dev, struct clk *clk) } EXPORT_SYMBOL_GPL(devm_clk_unregister); +int devm_acquire_clock(struct device *dev, + const struct devm_resource *resource) +{ + struct clk **clkp = dev_get_drvdata(dev) + resource->offset; + + *clkp = devm_clk_get(dev, resource->name); + if (IS_ERR(*clkp)) + return PTR_ERR(*clkp); + + return 0; +} +EXPORT_SYMBOL_GPL(devm_acquire_clock); + /* * clkdev helpers */ diff --git a/include/linux/clk.h b/include/linux/clk.h index 0df4a51e1a78..1084776efc28 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -17,6 +17,7 @@ #include struct device; +struct devm_resource; struct clk; @@ -138,6 +139,15 @@ int clk_get_phase(struct clk *clk); */ bool clk_is_match(const struct clk *p, const struct clk *q); +int devm_acquire_clock(struct device *dev, + const struct devm_resource *resource); + +#define DEVM_CLOCK(_struct, _member, _name) { \ + .initfunc = devm_acquire_clock, \ + .offset = offsetof_t(struct _struct, _member, struct clk *), \ + .name = _name, \ +} + #else static inline long clk_get_accuracy(struct clk *clk)