From patchwork Mon Dec 3 12:17:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10709411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA3F314BD for ; Mon, 3 Dec 2018 12:18:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D46CE2B51E for ; Mon, 3 Dec 2018 12:18:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6BFB2B523; Mon, 3 Dec 2018 12:18:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3C0D12B51E for ; Mon, 3 Dec 2018 12:18:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1hg/TlDyJuyB71qBdvhUaX1scRbP1VN3lhqHzNXAY2k=; b=A4oVvKY4d1OpWX GL2r4moFdcvBOvnVPrA7Pqi6VRuM1Azrpf5bbmuFslBe4+LvdUJ0eoo/WKG+AjpS1s2SmtebW3HTM IhZcj1rHxcEt+Tv2djdtCPe9v7zZHYLVGdsX15H7TLm2MoMkpIMnQ5+4yoV0i/pgFa1aojVuyhrz9 bNw24LMYl54bh4xkzJ5ZB6a4NUljwGWvdwzqt0Nd9EW7DWxqPK/JXdfeLnL5+vcFNlEudMWvuIwUY TkzDa92EnnNcg0KczypppVDWakY4NVG7FaZe/u4j3KD3xHOLs5n6NEBUF0R91x/Ysy/WzxqF79Jao MefSXksvk+rYtu95vTHg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnBB-0007GU-LX; Mon, 03 Dec 2018 12:18:25 +0000 Received: from mail-lf1-f68.google.com ([209.85.167.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnB8-00074G-0C for linux-arm-kernel@lists.infradead.org; Mon, 03 Dec 2018 12:18:24 +0000 Received: by mail-lf1-f68.google.com with SMTP id p17so8960913lfh.4 for ; Mon, 03 Dec 2018 04:18:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=w4m1/JlFXy+H6P73gFddGHjsLcAn5Y4uuyOJoCi2r3k=; b=PLqaZ2hoPU/zBKRfsI/yKdzO+2XY2B7IdNiVjVI7c7j334oCd9zyjzVymjU256W3EH LzzjnRgvl7t3NfnQ8mtDaQ8CNysow216a+B2epS/6ZKoduNaJqTMAyvRVUPyQ502HFd1 eqJHj2wZYo5u1vMTW7Esq1RgbeF7uV+pSZQcFbv41miJk3ArIatMHwMSVFBJnAXHC0UB lU/Q0cpX9KeXZxWp4u2QAHHAtzbsJn8p6bMoznwnILjOQfgMeEdRCJgB+3fVwsmCE562 rZ1yWDtZ/iZ5g4tanEE7AzFAt9nD6G/1M5K66YLawcERr3BIdfOn7bgLTp8Xcr0RpMY5 ffXA== X-Gm-Message-State: AA+aEWbkFrF1xr6/59bur7JbIGaW3AyRW7MAHPlTIEgCpGEUtijtGsbj srjEOfFnM0ajKQpmr0ljsr4= X-Google-Smtp-Source: AFSGD/V6mHObKB5mLcnDnizgBwluhXfpreZyoRlZwRkMqfQpXL5Va39sEJChpyXc+e39jdqTbdDaIQ== X-Received: by 2002:a19:6719:: with SMTP id b25mr8361226lfc.38.1543839489901; Mon, 03 Dec 2018 04:18:09 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id r29-v6sm2382781ljd.44.2018.12.03.04.18.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 04:18:09 -0800 (PST) Date: Mon, 3 Dec 2018 14:17:56 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v5 1/9] clkdev: add managed clkdev lookup registration Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181203_041822_170124_2B4397B5 X-CRM114-Status: GOOD ( 19.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, lee.jones@linaro.org, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Clkdev registration lacks of managed registration functions and it seems few drivers do not drop clkdev lookups at exit. Add devm_clk_hw_register_clkdev and devm_clk_release_clkdev to ease lookup releasing at exit. Signed-off-by: Matti Vaittinen --- Documentation/driver-model/devres.txt | 1 + drivers/clk/clkdev.c | 122 ++++++++++++++++++++++++++-------- include/linux/clkdev.h | 4 ++ 3 files changed, 101 insertions(+), 26 deletions(-) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 43681ca0837f..dbf14326243b 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -238,6 +238,7 @@ CLOCK devm_clk_put() devm_clk_hw_register() devm_of_clk_add_hw_provider() + devm_clk_hw_register_clkdev() DMA dmaenginem_async_device_register() diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 9ab3db8b3988..68a1e55a60d2 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -401,6 +401,25 @@ static struct clk_lookup *__clk_register_clkdev(struct clk_hw *hw, return cl; } +static int do_clk_register_clkdev(struct clk_hw *hw, + struct clk_lookup **cl, const char *con_id, const char *dev_id) +{ + + if (IS_ERR(hw)) + return PTR_ERR(hw); + /* + * Since dev_id can be NULL, and NULL is handled specially, we must + * pass it as either a NULL format string, or with "%s". + */ + if (dev_id) + *cl = __clk_register_clkdev(hw, con_id, "%s", + dev_id); + else + *cl = __clk_register_clkdev(hw, con_id, NULL); + + return *cl ? 0 : -ENOMEM; +} + /** * clk_register_clkdev - register one clock lookup for a struct clk * @clk: struct clk to associate with all clk_lookups @@ -420,20 +439,10 @@ int clk_register_clkdev(struct clk *clk, const char *con_id, { struct clk_lookup *cl; - if (IS_ERR(clk)) - return PTR_ERR(clk); - - /* - * Since dev_id can be NULL, and NULL is handled specially, we must - * pass it as either a NULL format string, or with "%s". - */ - if (dev_id) - cl = __clk_register_clkdev(__clk_get_hw(clk), con_id, "%s", - dev_id); - else - cl = __clk_register_clkdev(__clk_get_hw(clk), con_id, NULL); - - return cl ? 0 : -ENOMEM; + if (!IS_ERR(clk)) + return do_clk_register_clkdev(__clk_get_hw(clk), &cl, con_id, + dev_id); + return PTR_ERR(clk); } EXPORT_SYMBOL(clk_register_clkdev); @@ -456,18 +465,79 @@ int clk_hw_register_clkdev(struct clk_hw *hw, const char *con_id, { struct clk_lookup *cl; - if (IS_ERR(hw)) - return PTR_ERR(hw); + return do_clk_register_clkdev(hw, &cl, con_id, dev_id); +} +EXPORT_SYMBOL(clk_hw_register_clkdev); - /* - * Since dev_id can be NULL, and NULL is handled specially, we must - * pass it as either a NULL format string, or with "%s". - */ - if (dev_id) - cl = __clk_register_clkdev(hw, con_id, "%s", dev_id); - else - cl = __clk_register_clkdev(hw, con_id, NULL); +static void devm_clkdev_release(struct device *dev, void *res) +{ + clkdev_drop(*(struct clk_lookup **)res); +} - return cl ? 0 : -ENOMEM; +static int devm_clk_match_clkdev(struct device *dev, void *res, void *data) +{ + struct clk_lookup **l = res; + + if (!l || !*l) { + WARN_ON(!l || !*l); + return 0; + } + return *l == data; } -EXPORT_SYMBOL(clk_hw_register_clkdev); + +/** + * devm_clk_release_clkdev - Resource managed clkdev lookup release + * @dev: device this lookup is bound + * @con_id: connection ID string on device + * @dev_id: format string describing device name + * + * Drop the clkdev lookup created with devm_clk_hw_register_clkdev. + * Normally this function will not need to be called and the resource + * management code will ensure that the resource is freed. + */ +void devm_clk_release_clkdev(struct device *dev, const char *con_id, + const char *dev_id) +{ + struct clk_lookup *cl; + int rval; + + cl = clk_find(dev_id, con_id); + WARN_ON(!cl); + rval = devres_release(dev, devm_clkdev_release, + devm_clk_match_clkdev, cl); + WARN_ON(rval); +} +EXPORT_SYMBOL(devm_clk_release_clkdev); + +/** + * devm_clk_hw_register_clkdev - managed clk lookup registration for clk_hw + * @dev: device this lookup is bound + * @hw: struct clk_hw to associate with all clk_lookups + * @con_id: connection ID string on device + * @dev_id: format string describing device name + * + * con_id or dev_id may be NULL as a wildcard, just as in the rest of + * clkdev. + * + * To make things easier for mass registration, we detect error clk_hws + * from a previous clk_hw_register_*() call, and return the error code for + * those. This is to permit this function to be called immediately + * after clk_hw_register_*(). + */ +int devm_clk_hw_register_clkdev(struct device *dev, struct clk_hw *hw, + const char *con_id, const char *dev_id) +{ + int rval = -ENOMEM; + struct clk_lookup **cl; + + cl = devres_alloc(devm_clkdev_release, sizeof(*cl), GFP_KERNEL); + if (cl) { + rval = do_clk_register_clkdev(hw, cl, con_id, dev_id); + if (!rval) + devres_add(dev, cl); + else + devres_free(cl); + } + return rval; +} +EXPORT_SYMBOL(devm_clk_hw_register_clkdev); diff --git a/include/linux/clkdev.h b/include/linux/clkdev.h index 4890ff033220..ccb32af5848b 100644 --- a/include/linux/clkdev.h +++ b/include/linux/clkdev.h @@ -52,4 +52,8 @@ int clk_add_alias(const char *, const char *, const char *, struct device *); int clk_register_clkdev(struct clk *, const char *, const char *); int clk_hw_register_clkdev(struct clk_hw *, const char *, const char *); +int devm_clk_hw_register_clkdev(struct device *dev, struct clk_hw *hw, + const char *con_id, const char *dev_id); +void devm_clk_release_clkdev(struct device *dev, const char *con_id, + const char *dev_id); #endif From patchwork Mon Dec 3 12:18:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10709415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87DCD14BD for ; Mon, 3 Dec 2018 12:18:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 730072AFB1 for ; Mon, 3 Dec 2018 12:18:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 654AE2B056; Mon, 3 Dec 2018 12:18:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE9842AFB1 for ; Mon, 3 Dec 2018 12:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=t0Y0XmYIKFkE7miw8HhxUmG9GIjWpuyqHLtgUI9lVdg=; b=cVLJBj/ATLeWb8 rGvjZNjrF4LA5QjtCVCemhHyH7KPC0pbwIjVuerqHBukkTP3BEpCQoaqW0IPKLHQuy+lphnr0wNhF VV9LO8KYfI9F///qp/ZUydUMJqKZtdL85gE9+RcUmsAA67KDROoHz+RpMcAlOyk3qZlPZikfmvLG1 6oPUM/qst8mu+6TkB/qtAd14w2Vxym8c/X4iDkC5gvlDLIqfmR05hxBIotT8L0bDrlnTggL0Vo78Q 7LhI1whrDHmbmpX6qW/d9BDoQA8me+vlPayvzkOxeNBjltZELU0VUw2kXoDraudt+s6/jCbmvscES rEgtco3t5o6aolhoUqsQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnBe-0007Wp-FK; Mon, 03 Dec 2018 12:18:54 +0000 Received: from mail-lj1-f194.google.com ([209.85.208.194]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnBZ-0007TQ-B7 for linux-arm-kernel@lists.infradead.org; Mon, 03 Dec 2018 12:18:52 +0000 Received: by mail-lj1-f194.google.com with SMTP id t9-v6so11137802ljh.6 for ; Mon, 03 Dec 2018 04:18:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VuiEaW0Oj53yp3q4uxN2C3Fqx50TMkjVvsBbGOjHZUY=; b=qJH36OOPvA+8KnXUnn6ZOX6TA93P9hBf/QKGEFe/diremRDjqoEKoRhKHJsYT0j8yi jC6cNc+1Z/ysNZF6J+cRVlA959xBdu4JVmpALzaM49rG7v8msc4YVlJBeG+Sjhyf2XTf 63Fxc8BqWa3AMUR4qHpIkktCNQZIRmwGYU5rC4vhzgOfqKURVFTGg+BgLlJxG3mW1pxH hD+r22EJRnMVRlFnxYBSNYsIi8qwKMzPebBCVyzqyxA3Y66ioq5aWz9OJZBqOfpPCNHp z/t3p5pw4L3AXQcL/VdrW99vJCiTbcsI/adxB80mu/wzQVWpbM6zjyY/OG7PbsKjmqno JsGw== X-Gm-Message-State: AA+aEWaUOk+giEUhG0McxmPgnYTiNUSiR/NfK9GBFq2EYWIEPQ9RCDxh oVMNo8B0+4a2x9yG63FenBo= X-Google-Smtp-Source: AFSGD/XA0By5ECSehpqZO8rpWGHa5fzid7ZDNrkXSvC063FdQgEuCV198/ybPvKkV2wyFX5cxcZkuQ== X-Received: by 2002:a2e:9b52:: with SMTP id o18-v6mr9879341ljj.108.1543839517681; Mon, 03 Dec 2018 04:18:37 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id h85-v6sm2478439ljf.68.2018.12.03.04.18.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 04:18:37 -0800 (PST) Date: Mon, 3 Dec 2018 14:18:24 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v5 2/9] clk: of_clk - add managed provider registrations Message-ID: <72d98b6f8deca66d4182c37669ec4421977922b3.1543837442.git.matti.vaittinen@fi.rohmeurope.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181203_041849_378427_4E0A8A25 X-CRM114-Status: GOOD ( 19.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, lee.jones@linaro.org, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP With MFD devices the clk properties may be contained in MFD (parent) DT node. Current devm_of_clk_add_hw_provider assumes the clk is bound to MFD subdevice not to MFD device (parent). Add devm_of_clk_add_hw_provider_parent to tackle this issue. Signed-off-by: Matti Vaittinen --- Documentation/driver-model/devres.txt | 1 + drivers/clk/clk.c | 65 ++++++++++++++++++++++++++++++----- include/linux/clk-provider.h | 11 ++++++ 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index dbf14326243b..97c9c575b2af 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -238,6 +238,7 @@ CLOCK devm_clk_put() devm_clk_hw_register() devm_of_clk_add_hw_provider() + devm_of_clk_add_parent_hw_provider() devm_clk_hw_register_clkdev() DMA diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index af011974d4ec..30beb60bd8f9 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3893,12 +3893,12 @@ static void devm_of_clk_release_provider(struct device *dev, void *res) of_clk_del_provider(*(struct device_node **)res); } -int devm_of_clk_add_hw_provider(struct device *dev, +static int __devm_of_clk_add_hw_provider(struct device *dev, struct clk_hw *(*get)(struct of_phandle_args *clkspec, void *data), - void *data) + struct device_node *of_node, void *data) { - struct device_node **ptr, *np; + struct device_node **ptr; int ret; ptr = devres_alloc(devm_of_clk_release_provider, sizeof(*ptr), @@ -3906,19 +3906,62 @@ int devm_of_clk_add_hw_provider(struct device *dev, if (!ptr) return -ENOMEM; - np = dev->of_node; - ret = of_clk_add_hw_provider(np, get, data); - if (!ret) { - *ptr = np; + *ptr = of_node; + ret = of_clk_add_hw_provider(of_node, get, data); + if (!ret) devres_add(dev, ptr); - } else { + else devres_free(ptr); - } return ret; } + +/** + * devm_of_clk_add_hw_provider() - Managed clk provider node registration + * @dev: Device acting as the clock provider. Used for DT node and lifetime. + * @get: callback for decoding clk_hw + * @data: context pointer for @get callback. + * + * Returns 0 on success or an errno on failure. + * + * Registers clock provider for given device's node. Provider is automatically + * released at device exit. + */ +int devm_of_clk_add_hw_provider(struct device *dev, + struct clk_hw *(*get)(struct of_phandle_args *clkspec, + void *data), + void *data) +{ + return __devm_of_clk_add_hw_provider(dev, get, dev->of_node, data); +} EXPORT_SYMBOL_GPL(devm_of_clk_add_hw_provider); +/** + * devm_of_clk_add_parent_hw_provider() - Managed clk provider node registration + * @dev: Device acting as the clock provider. Provider's DT node is parent node. + * @get: callback for decoding clk_hw + * @data: context pointer for @get callback. + * + * Returns 0 on success or an errno on failure. + * + * Registers clock provider for given device's parent node. Usable in cases + * where it really is the parent node that contains the provider information. + * Typical use-cases are MFD devices where the MFD sub-device is handling + * actual clock HW but the MFD node (parent) is containing the clock + * information. + * + * Provider is automatically released at device exit. + */ +int devm_of_clk_add_parent_hw_provider(struct device *dev, + struct clk_hw *(*get)(struct of_phandle_args *clkspec, + void *data), + void *data) +{ + return __devm_of_clk_add_hw_provider(dev, get, dev->parent->of_node, + data); +} +EXPORT_SYMBOL_GPL(devm_of_clk_add_parent_hw_provider); + /** * of_clk_del_provider() - Remove a previously registered clock provider * @np: Device node pointer associated with clock provider @@ -3950,6 +3993,10 @@ static int devm_clk_provider_match(struct device *dev, void *res, void *data) return *np == data; } +/** + * devm_of_clk_del_provider() - Remove clock provider registered using devm + * @dev: Device to whose lifetime the clock provider was bound + */ void devm_of_clk_del_provider(struct device *dev) { int ret; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 60c51871b04b..a6663f084cf1 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -916,6 +916,10 @@ int devm_of_clk_add_hw_provider(struct device *dev, struct clk_hw *(*get)(struct of_phandle_args *clkspec, void *data), void *data); +int devm_of_clk_add_parent_hw_provider(struct device *dev, + struct clk_hw *(*get)(struct of_phandle_args *clkspec, + void *data), + void *data); void of_clk_del_provider(struct device_node *np); void devm_of_clk_del_provider(struct device *dev); struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, @@ -953,6 +957,13 @@ static inline int devm_of_clk_add_hw_provider(struct device *dev, { return 0; } +static inline int devm_of_clk_add_parent_hw_provider(struct device *dev, + struct clk_hw *(*get)(struct of_phandle_args *clkspec, + void *data), + void *data) +{ + return 0; +} static inline void of_clk_del_provider(struct device_node *np) {} static inline void devm_of_clk_del_provider(struct device *dev) {} static inline struct clk *of_clk_src_simple_get( From patchwork Mon Dec 3 12:19:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10709421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB44414BD for ; Mon, 3 Dec 2018 12:20:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8F992B4DF for ; Mon, 3 Dec 2018 12:20:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D0902B4E3; Mon, 3 Dec 2018 12:20:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D6022B4E2 for ; Mon, 3 Dec 2018 12:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sIi/llkjppitL2PnFr19iFLJfrAZLczbs981OSu9R+s=; b=YqJof057CPZiO0 nf+X74k3fwB5p0WqdgSVKdGAMLkISOL1nd+ED/hsu7ZGkRIvYzgEg4Z6XqgbH6KH3RvFefCBkB52h KjR+Jvz8H4ghzyrdZ1osUnyWh0Kpomn3CB2bT3kw+g0cdgseKkepknEkz8gCZnnh8GIUgjL7bgsNZ NK+BI8tihGWQpvYkYv5NxpKAAhO5VoQMG58DY1VOFbotE8dLMiekAbWU3G775z/zSCu/KRc2ug3gC 9j8iIf6A7JoYIo+ruo9qVCLf1PH0RwGoJ7GE6jVuo2uBbte0ug2h6s8rQ9w2jD7eSxahj5UK3Hx5w 3qU+8hSyVxvmxjlXJN0g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnCu-0000ja-CR; Mon, 03 Dec 2018 12:20:12 +0000 Received: from mail-lf1-f66.google.com ([209.85.167.66]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnCj-00081L-0o for linux-arm-kernel@lists.infradead.org; Mon, 03 Dec 2018 12:20:10 +0000 Received: by mail-lf1-f66.google.com with SMTP id f23so8928226lfc.13 for ; Mon, 03 Dec 2018 04:19:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=fJ06/MEsQS8wIywHorlvQqUqrYoodnmIZrcXjxSdJq0=; b=QYDVnyT7cdqs89C1+UUypR4H0kaBAV59FOKqFIy0+0RAuoRPqIpMJiTDN2tsTSIRx6 RpW0qoRnO4NLJ3rS6RmBAxQftAAlDHNzLvviz4DG7MpFFWwi7jh8ZZvSvWc2FxTVn2PP s/D8rojKGvG7aRim2lmV17KMRO/vuFLCtc7UjEjpAHZeMboS4MhjiHWjo1rqvac/4jMl IB6rGt9OzCSvTBoEH4VRGC0w8RnfUXaKNAJqFwOhbIytVotSfh/SnJHtGJY8V81F2m98 cwCuhZ560XqEpDPTigszMi/JkjzZMF/CyaWbE1S0PjokqF4aaBq/n8hgK3qfXYHAyDJN F3tw== X-Gm-Message-State: AA+aEWaT0orBBTPFLVOV7gC+ID6z/ekto/xWmAL9reMYpEEuqod4174z k2YeeTAZeQCEqYXuXo6cAGg= X-Google-Smtp-Source: AFSGD/WgnRyEklbhrzoAdgtWZ2HOe0X9TsjA1Nq4WBaT2wWTmfqv/XbKXL3exfZ8C1DvNTpyHjbTzQ== X-Received: by 2002:a19:f510:: with SMTP id j16mr8516533lfb.35.1543839588876; Mon, 03 Dec 2018 04:19:48 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id b21sm2309452lfi.7.2018.12.03.04.19.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 04:19:48 -0800 (PST) Date: Mon, 3 Dec 2018 14:19:35 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v5 3/9] clk: clk-max77686: Clean clkdev lookup leak and use devm Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181203_042001_074287_D34F5E27 X-CRM114-Status: GOOD ( 16.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, lee.jones@linaro.org, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP clk-max77686 never clean clkdev lookup at remove. This can cause oops if clk-max77686 is removed and inserted again. Fix leak by using new devm clkdev lookup registration. Simplify also error path by using new devm_of_clk_add_parent_hw_provider. Signed-off-by: Matti Vaittinen Reviewed-by: Krzysztof Kozlowski --- drivers/clk/clk-max77686.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c index 22c937644c93..e65925d5e412 100644 --- a/drivers/clk/clk-max77686.c +++ b/drivers/clk/clk-max77686.c @@ -235,8 +235,9 @@ static int max77686_clk_probe(struct platform_device *pdev) return ret; } - ret = clk_hw_register_clkdev(&max_clk_data->hw, - max_clk_data->clk_idata.name, NULL); + ret = devm_clk_hw_register_clkdev(dev, &max_clk_data->hw, + max_clk_data->clk_idata.name, + NULL); if (ret < 0) { dev_err(dev, "Failed to clkdev register: %d\n", ret); return ret; @@ -244,8 +245,9 @@ static int max77686_clk_probe(struct platform_device *pdev) } if (parent->of_node) { - ret = of_clk_add_hw_provider(parent->of_node, of_clk_max77686_get, - drv_data); + ret = devm_of_clk_add_parent_hw_provider(dev, + of_clk_max77686_get, + drv_data); if (ret < 0) { dev_err(dev, "Failed to register OF clock provider: %d\n", @@ -261,27 +263,11 @@ static int max77686_clk_probe(struct platform_device *pdev) 1 << MAX77802_CLOCK_LOW_JITTER_SHIFT); if (ret < 0) { dev_err(dev, "Failed to config low-jitter: %d\n", ret); - goto remove_of_clk_provider; + return ret; } } return 0; - -remove_of_clk_provider: - if (parent->of_node) - of_clk_del_provider(parent->of_node); - - return ret; -} - -static int max77686_clk_remove(struct platform_device *pdev) -{ - struct device *parent = pdev->dev.parent; - - if (parent->of_node) - of_clk_del_provider(parent->of_node); - - return 0; } static const struct platform_device_id max77686_clk_id[] = { @@ -297,7 +283,6 @@ static struct platform_driver max77686_clk_driver = { .name = "max77686-clk", }, .probe = max77686_clk_probe, - .remove = max77686_clk_remove, .id_table = max77686_clk_id, }; From patchwork Mon Dec 3 12:20:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10709425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 496B113BF for ; Mon, 3 Dec 2018 12:20:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37ACA2B4D5 for ; Mon, 3 Dec 2018 12:20:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B8CE2B4E2; Mon, 3 Dec 2018 12:20:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C2AFC2B4D5 for ; Mon, 3 Dec 2018 12:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8ZP6tsZGTxewNaWC9OBecNMG2ahLcPcbsOwx6HVJi0U=; b=lxinW6K/yAv26V MTZYjcE0qPccaY4N6Orl6fFysBZzsZDskNHnuBM05ThT5adHgFwOFv9oiVn7Z2+m9yqOZ/0ettkg5 2jc9Rb0WwqoAt2gJo3JR97lmBQYx27J4PoLC6qwqTE87LO6upCxTQz3doS40JTba6CktXE31tw1kz 7fYJtFmAZ1O0mC0cBlQYSsvTd1u6oMocnHx02ggRmJzdHFsgGNPYL57xUS/7AYiCg2wq0dnYhxKbC zwzls9qc1NPA6rl5lnlvhfNKd21ExIAgqbV+HtNI/i5hu9PRJv+nHoE9mzbYdcZ57I8D9hvel0n3L UyP5OJO6CDbmPIquhWug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnDa-0001Ts-Ou; Mon, 03 Dec 2018 12:20:54 +0000 Received: from mail-lf1-f65.google.com ([209.85.167.65]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnDV-0001O8-LY for linux-arm-kernel@lists.infradead.org; Mon, 03 Dec 2018 12:20:52 +0000 Received: by mail-lf1-f65.google.com with SMTP id p86so8950525lfg.5 for ; Mon, 03 Dec 2018 04:20:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4fWmEQHDymzQumdk/aytbyrz8Sfb7MJtwS0fcAz0+8Q=; b=atc9K/XTYTP/cxAx9Vip36EgzVJ85Eb29tYX1osDLuF3wU7wNoZniIYLtO6CHWG4YD 3RaYlB2G2T3gj/NHiL34K29jFNtvxHyVWDKTF9JHd1W3aPBI3g4Jjk91xUAZ+tcgvIH7 LEpSxHeD0KGK7bmSO8OUyTCuCwi8aEDvzDxGidpO/anI9xCCd69xT0CNPaoazrhYBk3t 04leuHYDlz6nm2wp2+YizR2hDWeY8NwSSVqZA8D1esxXj5xvnqppFvAULAthyTWMsgIW mJqsiIYZ/4vK3nCs32DheW9cbHTXnuerGsxxfVt1IY87RPjAkixjHWmzl2KrlKfnvMF0 HLxQ== X-Gm-Message-State: AA+aEWbHfvA8Tiqvuzj0CGIW5VwSFGJHYZNgQCBB347Tkft6McvAF8me FGMg+XbirCBtgsPWeplkcMA= X-Google-Smtp-Source: AFSGD/WUn+TU8jWSv6p2bow14ZEV4fNB+5lLXo3ld62urHnH5WLQdIkJ6KONpT1VZAHYGoeTi5pofw== X-Received: by 2002:ac2:4215:: with SMTP id y21mr6230009lfh.6.1543839637235; Mon, 03 Dec 2018 04:20:37 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id z15-v6sm2688556ljb.9.2018.12.03.04.20.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 04:20:36 -0800 (PST) Date: Mon, 3 Dec 2018 14:20:23 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v5 4/9] clk: clk-st: avoid clkdev lookup leak at remove Message-ID: <397a0da87031430a4c50958f99f0b1e35cb01e85.1543837442.git.matti.vaittinen@fi.rohmeurope.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181203_042049_784917_2595ECB9 X-CRM114-Status: GOOD ( 13.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, lee.jones@linaro.org, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm based clkdev lookup registration to avoid leaking lookup structures. Signed-off-by: Matti Vaittinen --- drivers/clk/x86/clk-st.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clk/x86/clk-st.c b/drivers/clk/x86/clk-st.c index 3a0996f2d556..25d4b97aff9b 100644 --- a/drivers/clk/x86/clk-st.c +++ b/drivers/clk/x86/clk-st.c @@ -52,7 +52,8 @@ static int st_clk_probe(struct platform_device *pdev) 0, st_data->base + MISCCLKCNTL1, OSCCLKENB, CLK_GATE_SET_TO_DISABLE, NULL); - clk_hw_register_clkdev(hws[ST_CLK_GATE], "oscout1", NULL); + devm_clk_hw_register_clkdev(&pdev->dev, hws[ST_CLK_GATE], "oscout1", + NULL); return 0; } From patchwork Mon Dec 3 12:20:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10709429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEC5113BF for ; Mon, 3 Dec 2018 12:21:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A80F32B4E2 for ; Mon, 3 Dec 2018 12:21:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97FEA2B4EF; Mon, 3 Dec 2018 12:21:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 99FE62B4E2 for ; Mon, 3 Dec 2018 12:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/QpH8HecrNR1pLzLREtiGkpldbGFuuAbIQrkjJyF/58=; b=NIqfwiP4z8V1u/ SU7/VFRHZstFIcq4uu4dw5l2NtAtKUDP1K90bk9M4VquMIPb816pS1fcZAOq56sK5Ti5RU6vrrDSg L5gTd5NXfUy+VDO+9Xhr9CMv+wWW+T5oMjsxnMeDFuiCpaoR7nRVQAyDsD4FJZ43Jnis20XKL0Awr ngWpBmJkiGtqxjJN+UU8HXtfdpC0lkPWd3PZ/BVWaQu6EoH27Z2KFknJLDds8+c+roxF5fkY7QVb7 XvssR9Wh9Y9/dZDNTa1OqBes8L0c3IGJAmw4RvcNWSr/+H9kTjorZP81ehrsONKHiosFom0MOaJYj bz38tsR5kFOS6u5gB0uA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnE1-0001jt-RJ; Mon, 03 Dec 2018 12:21:21 +0000 Received: from mail-lf1-f67.google.com ([209.85.167.67]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnDz-0001gZ-5G for linux-arm-kernel@lists.infradead.org; Mon, 03 Dec 2018 12:21:20 +0000 Received: by mail-lf1-f67.google.com with SMTP id p6so8959158lfc.1 for ; Mon, 03 Dec 2018 04:21:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GkHc1XDfS2zAEG1O6tNrzFVGgOycf/0Y3wU3cQalzu0=; b=n6MVrYkrWgTfXbQl+iGM/18FnaG2QXNPVW9TXZog3SCX0sG+xgtAw658kFMU7YOMSk qnECYtPdw4tK6k/vMd5UPWzX+skAFnfOhujCgyVt0Ry/aIpUAQBJUv+0aN6cFbDd+11D ymwPIU2OBSyogi9Q1RfSQxD/eE+aGjgdxa3hOUX3dHPIDLgMf+WP+vdPBlPD+A+uAd6x z0UX/Tf3NmW1nx+gYCyo9x0enEnLOWhaa5ml1c4JjfSDem/dNJupiQnsD7vglZ2raKJ8 2BA1FyIVwyLZK28h6CNc6TIM7ZxZRmkx9j/VVJyPo8Cq03wzNPC2V81o6Jrgi4kxrTSO giLg== X-Gm-Message-State: AA+aEWZkD7iaKYIhJqvyjXrOmTE+MhV7NmUzXEq6Wssp6i+VQV9JQQJP l2Fm9gH/HkIGN4BVE1umF2o= X-Google-Smtp-Source: AFSGD/UIhtvqjU6BNrGF0/rqLaJcmiDSDN4ffyuRVXpnM7XbhS2pcD1MTsCxuFekt7tWfH9jmI+vxQ== X-Received: by 2002:a19:cfc6:: with SMTP id f189mr9694002lfg.102.1543839666538; Mon, 03 Dec 2018 04:21:06 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id y81-v6sm2482409lje.30.2018.12.03.04.21.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 04:21:05 -0800 (PST) Date: Mon, 3 Dec 2018 14:20:53 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v5 5/9] clk: clk-hi655x: Free of_provider at remove Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181203_042119_207588_865D1559 X-CRM114-Status: GOOD ( 14.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, lee.jones@linaro.org, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP use devm variant for of_provider registration so provider is freed at exit. Signed-off-by: Matti Vaittinen --- drivers/clk/clk-hi655x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk-hi655x.c b/drivers/clk/clk-hi655x.c index 403a0188634a..394d0109104d 100644 --- a/drivers/clk/clk-hi655x.c +++ b/drivers/clk/clk-hi655x.c @@ -107,8 +107,8 @@ static int hi655x_clk_probe(struct platform_device *pdev) if (ret) return ret; - return of_clk_add_hw_provider(parent->of_node, of_clk_hw_simple_get, - &hi655x_clk->clk_hw); + return devm_of_clk_add_parent_hw_provider(&pdev->dev, + of_clk_hw_simple_get, &hi655x_clk->clk_hw); } static struct platform_driver hi655x_clk_driver = { From patchwork Mon Dec 3 12:21:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10709433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58B1114BD for ; Mon, 3 Dec 2018 12:21:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 466F12B4DF for ; Mon, 3 Dec 2018 12:21:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3847F2B4E3; Mon, 3 Dec 2018 12:21:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BB4A92B4DF for ; Mon, 3 Dec 2018 12:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=u4NgRMFJFa0TfBza8StczUhLEE0Y2X4iOZYPVqRRx4A=; b=QnYWSHv9w+hMwF Kg1bhzrFB4LHiCUrzUvIGhaNq/K7smAeOZ13oB6A2VbtZ6cWoia6xjf+x2tj7Og9yCf0Vm8pqM/pI jpx7zGtw9b2P36ZyB4UYIT0O8h2GeRLWKMOEw5LCiI6vQQQHe2M14WsZ+y233RjWbwZRssmTq+d2v TrHQOGrCqBgBME9vBVPenAH5fzuQw7pM/Exyke4Hc5zRW+uf3JTT4bUFh6c24Dn9w/LVYwvEgGhij 6MoPS8/C+u1QMloPr9FvziaRg3aeP692+dCmydlSLB9wAN/Lp/j8Gtu+k8vm+a68YOC8mTksi3iBH jC+0s4yH4Tyrlczqx9Hw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnEV-000209-1H; Mon, 03 Dec 2018 12:21:51 +0000 Received: from mail-lj1-f194.google.com ([209.85.208.194]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnEP-0001wB-BE for linux-arm-kernel@lists.infradead.org; Mon, 03 Dec 2018 12:21:49 +0000 Received: by mail-lj1-f194.google.com with SMTP id v1-v6so11176724ljd.0 for ; Mon, 03 Dec 2018 04:21:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4b7mWWvbRMSl/BrY6BXSv/3823MeAc6TDJ2DxbTG2QU=; b=UJsRx748nzmqnwrjrFual1Fkef7UEfF83O8HiwyI8QURIq9vhB40Y0DjQTAkcGSwxq H+/sb8TZ7j3FX1BYc7lbhmIl+v5gwkxpsq0lmmX5VZuWCgh5RJglNhCbyXu8TY20hZmv 4Cty8y5/8ED6crZnDSZxlu+ltRFQDBC1eBQffdO9vXsMpFvbg4te0yAVHGfnOhPtoOAI yUgGtpYLT6cxsyWNwTNyinkgzpX2p7SyELcgf67kT+GAKVJFhZ3+mrrAHu8qhWBF4TL2 ZfFHbetzxPSEMCYT+8dd1jYMiCMoUQ2qP33wZhCYtqr++7g7ZiCAyrw6441pivDcc7Ta B7vg== X-Gm-Message-State: AA+aEWalr2VezDE3wRZNzaMWW8H+frjJoVfnjDIMAGRpt7w5uYKqUtea UHPj8gGT15tItUpQxJeYvqs= X-Google-Smtp-Source: AFSGD/VZOB4P9pWpYAL4tvM00SPsFOgaonafy+w5dK2qsmbOv+a6krNl+bqf/YHd2IRdWKxIiv0VFg== X-Received: by 2002:a2e:b1ca:: with SMTP id e10-v6mr10885456lja.16.1543839693623; Mon, 03 Dec 2018 04:21:33 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id h3sm2306510lfj.25.2018.12.03.04.21.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 04:21:32 -0800 (PST) Date: Mon, 3 Dec 2018 14:21:20 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v5 6/9] clk: rk808: use managed version of of_provider registration Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181203_042145_403111_BEC6BF8F X-CRM114-Status: GOOD ( 14.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, lee.jones@linaro.org, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Simplify clean-up for rk808 by using managed version of of_provider registration. Signed-off-by: Matti Vaittinen --- drivers/clk/clk-rk808.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/clk/clk-rk808.c b/drivers/clk/clk-rk808.c index 6461f2820a5b..177340edaae5 100644 --- a/drivers/clk/clk-rk808.c +++ b/drivers/clk/clk-rk808.c @@ -138,23 +138,12 @@ static int rk808_clkout_probe(struct platform_device *pdev) if (ret) return ret; - return of_clk_add_hw_provider(node, of_clk_rk808_get, rk808_clkout); -} - -static int rk808_clkout_remove(struct platform_device *pdev) -{ - struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); - struct i2c_client *client = rk808->i2c; - struct device_node *node = client->dev.of_node; - - of_clk_del_provider(node); - - return 0; + return devm_of_clk_add_parent_hw_provider(&pdev->dev, + of_clk_rk808_get, rk808_clkout); } static struct platform_driver rk808_clkout_driver = { .probe = rk808_clkout_probe, - .remove = rk808_clkout_remove, .driver = { .name = "rk808-clkout", }, From patchwork Mon Dec 3 12:22:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10709441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B29613BF for ; Mon, 3 Dec 2018 12:22:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 498452B4F1 for ; Mon, 3 Dec 2018 12:22:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D8FC2B4F5; Mon, 3 Dec 2018 12:22:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E7E962B4F1 for ; Mon, 3 Dec 2018 12:22:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c9edhVeDphT/J1ySnjVWtvDU7b2Uk/DJK3i30gIfFPw=; b=HNbe1gyL5SDNjN 5xyeH31jjFPbD1+4TsIZ6NRB8Eczawa/9jfCADegBm3pzEigmlbdPceWritRZqBaqo42UU8pzVbMv WPz1cCa1Cwc5e+LpzfAm/xcwfqndCPN5jJGHRflKGdfZAAoo7LCMbantm0u1kO1mV3iH2jk7nbU/n 2s25knPiJ9roPsRXPAk+CCIuOFCDKMRqYPvKU2TDLFjDp29TE5WLBfuNHb5EyLAVSSQyZOrIIOFq7 jo4XLzGE8Ixgl/YXNhtYeZw4eEdEKD46BGVpbXi8lIiVBn2cf9/q4GNV2ErML3zFot4bNud2Gklj7 dKJbrhHVXK/WugBHt3IA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnFP-0002Gs-8w; Mon, 03 Dec 2018 12:22:47 +0000 Received: from mail-lf1-f65.google.com ([209.85.167.65]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnFM-0002G9-IV for linux-arm-kernel@lists.infradead.org; Mon, 03 Dec 2018 12:22:45 +0000 Received: by mail-lf1-f65.google.com with SMTP id n18so8952223lfh.6 for ; Mon, 03 Dec 2018 04:22:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Eg2ufM9FdHFhTVDmxheR3tr+ip3I7Xl4uZ2RuWzUJVA=; b=rAke8b93EUIaYFKwgEl13zALOXmh/JVCYfq90A3HUfqNeunYM4kBhLB6lN634aPJsr L/s57zV7tXtWrmcXgF2yNz+POO+bMyhqIhzH0MlqRWyOe0MHAQVDClEfVSQbhHkGWEvw EdioURiorqp1fx1ett5qlSAQ+mPtrbXfG8zbILZpW9V+kfQ4dMRPr90hdjFzxGgqmFYV dUFnwy34UQ3ayEpV7IwcbqWOf97iaaFgqNizccYP4NN9UayogJVuPfLAELX1u//HG1Kd ZjkVgx9qntZ3TuZ3P6DeaU/60XUZPUzB02unQZxFJPUn/v+mmRou2AS8Dz583cAPa+RB Eubw== X-Gm-Message-State: AA+aEWZvTDbUB7FcV+GlvDLxv3nxDljuDBe1edxnzd6/oSbSzwftmwQQ +faQeXfpTxxgFc7+7IWQbho= X-Google-Smtp-Source: AFSGD/UW/Y17SkEXDYI/3asKglm+pxUJcs8KkBfsyv6BBri5+OgsNM/kNXDc4ufMa+saFjvBX1uM7A== X-Received: by 2002:a19:2395:: with SMTP id j143mr8716004lfj.107.1543839752957; Mon, 03 Dec 2018 04:22:32 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id p91sm2362753lfg.4.2018.12.03.04.22.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 04:22:32 -0800 (PST) Date: Mon, 3 Dec 2018 14:22:17 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v5 7/9] clk: clk-twl6040: Free of_provider at remove Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181203_042244_604994_28E03500 X-CRM114-Status: GOOD ( 13.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, lee.jones@linaro.org, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP use devm variant for of_provider registration so provider is freed at exit. Signed-off-by: Matti Vaittinen Acked-by: Peter Ujfalusi --- drivers/clk/clk-twl6040.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-twl6040.c b/drivers/clk/clk-twl6040.c index 25dfe050ae9f..e9da09453eb2 100644 --- a/drivers/clk/clk-twl6040.c +++ b/drivers/clk/clk-twl6040.c @@ -108,9 +108,8 @@ static int twl6040_pdmclk_probe(struct platform_device *pdev) platform_set_drvdata(pdev, clkdata); - return of_clk_add_hw_provider(pdev->dev.parent->of_node, - of_clk_hw_simple_get, - &clkdata->pdmclk_hw); + return devm_of_clk_add_parent_hw_provider(&pdev->dev, + of_clk_hw_simple_get, &clkdata->pdmclk_hw); } static struct platform_driver twl6040_pdmclk_driver = { From patchwork Mon Dec 3 12:23:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10709447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 337FB14BD for ; Mon, 3 Dec 2018 12:23:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 219F02A346 for ; Mon, 3 Dec 2018 12:23:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 153C32AE22; Mon, 3 Dec 2018 12:23:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C06812A346 for ; Mon, 3 Dec 2018 12:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=B33ZWT5zuTinyNvElgcbzUCxOr81++EezRnYVMmJBQM=; b=EYLQvFR5Tf6gTo fCusnEfQf5vsRVSFwBicXUjtojgI8Lb0BJfUxXz3IBPOPP8OfWbWbmfO+n9HvE2mvFzeSXpx/dZzR LQZQqbjdnAHpxXViOgr9IzkoMAHupHnNmo4Ifx2MEYcsy4xTh5wrVc3TjmNiU4orzIuhJfvGaoQQo ytLmeksFJUHvg2fXqVlm9ipWXQFTsqvaFymWIOTNJhK4ojyuX/7Y9kOCkd40tAeewVwl2QRrmmRdU lGSG5t0554VGyic3oivj+MB5gW6dY52qXdhXpad2bP2Vo3oSVDT1QOHLCtD5qfKIfN8Gduxl6Gsv9 3Wth8mRQJ3+Mo7QBhBCg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnGH-0002d7-CA; Mon, 03 Dec 2018 12:23:41 +0000 Received: from mail-lj1-f195.google.com ([209.85.208.195]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnGE-0002ci-98 for linux-arm-kernel@lists.infradead.org; Mon, 03 Dec 2018 12:23:39 +0000 Received: by mail-lj1-f195.google.com with SMTP id c19-v6so11166059lja.5 for ; Mon, 03 Dec 2018 04:23:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=abc15EH5GKVAESf+iqe1waxzU2AmezuL+i/+AhHeQPw=; b=EFjby3sirqq1v+d8WzgcXL8K0edBYg7G2uAwU0nmXYhMhMPtlFmtXfNg8tZhpPcX5l bU0m154Rt2dQjWldZSy2pfSiu0qgAkUjY0AMbm6toBk56MHCZmLjQPF2NfCbjuahYAnc pJrHC7I1us3Mk27zT7Nl7IdJuDgR9/dGM9wbP4fjTRVLyAbY6A6Cw2fz84heENPm9Pk7 xp+rkJCe9iOeJOeMVmqiH+4nF1v45buMmodfDV01gDav2UjoUDMbOqJixyupmEw22hSs yD3v6ki6EXN2Vk9I8QDbhkopie56/9Xa4MCv35S6XtRo6q3C+4ueoSDgbhZWkZ4k7eRf bprg== X-Gm-Message-State: AA+aEWaYIq11ASvYjbq9ZF/DJMf7b4iBL4S4j9ob+RxP0b+wYKhENVi1 wy0uc7Fa3X2xTetBSuepVVg= X-Google-Smtp-Source: AFSGD/X2P+ECjuWcgLVnhgHsXAS1vsbc//5eO3P+7JAab0Xc3ar+iGOvGZMXA/rBp7IYIV8eZcsaQw== X-Received: by 2002:a2e:6594:: with SMTP id e20-v6mr10729993ljf.123.1543839806395; Mon, 03 Dec 2018 04:23:26 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id q4-v6sm2423194ljb.4.2018.12.03.04.23.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 04:23:25 -0800 (PST) Date: Mon, 3 Dec 2018 14:23:12 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v5 8/9] clk: apcs-msm8916: simplify probe cleanup by using devm Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181203_042338_314409_66B95A89 X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, lee.jones@linaro.org, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP use devm variant for of_provider registration. Signed-off-by: Matti Vaittinen --- drivers/clk/qcom/apcs-msm8916.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/clk/qcom/apcs-msm8916.c b/drivers/clk/qcom/apcs-msm8916.c index b1cc8dbcd327..f4e0c136ab1a 100644 --- a/drivers/clk/qcom/apcs-msm8916.c +++ b/drivers/clk/qcom/apcs-msm8916.c @@ -96,8 +96,8 @@ static int qcom_apcs_msm8916_clk_probe(struct platform_device *pdev) goto err; } - ret = of_clk_add_hw_provider(parent->of_node, of_clk_hw_simple_get, - &a53cc->clkr.hw); + ret = devm_of_clk_add_parent_hw_provider(dev, of_clk_hw_simple_get, + &a53cc->clkr.hw); if (ret) { dev_err(dev, "failed to add clock provider: %d\n", ret); goto err; @@ -118,7 +118,6 @@ static int qcom_apcs_msm8916_clk_remove(struct platform_device *pdev) struct device *parent = pdev->dev.parent; clk_notifier_unregister(a53cc->pclk, &a53cc->clk_nb); - of_clk_del_provider(parent->of_node); return 0; } From patchwork Mon Dec 3 12:23:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10709457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67A9014BD for ; Mon, 3 Dec 2018 12:24:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53FCB2A346 for ; Mon, 3 Dec 2018 12:24:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4651C2B32B; Mon, 3 Dec 2018 12:24:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 476212A346 for ; Mon, 3 Dec 2018 12:24:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/VuToHyTkWGTWXpdIIQdwnPWVoIXQvI4T56hUc95aYM=; b=aFv7SDC4sVKtF4 wgEa8i2FfHDPL1nq6PtLNgJjTNqbFYRG5VZ5Y4thIE4uAVAAViYH+TPajcM0Gj808s656aPlQYOnK Y0keaabLBeJOx4XCtBLk9sMUCWtggZysKJ2yxSFI9/j3mvatlENkZtlASzHfop0P26Aoash7HvHuA Dlz7o/moLH/g83Va+6+6o/RttfsQX5Jt1nDO20VtvntSsa5g5L4cbmlvEbI5Mk3XP9jZccJZHX1bE KOzQJ4ni3VCm3eCSeH4MEi2GUcCNhayf73oOtzoQZmroymYmcqNqHGiHHC/O7zpWQC/sijryruh7g JT+2CurwtejIrmS+r1gA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnGp-0002tE-CQ; Mon, 03 Dec 2018 12:24:15 +0000 Received: from mail-lj1-f193.google.com ([209.85.208.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnGj-0002rx-3i for linux-arm-kernel@lists.infradead.org; Mon, 03 Dec 2018 12:24:13 +0000 Received: by mail-lj1-f193.google.com with SMTP id v1-v6so11183473ljd.0 for ; Mon, 03 Dec 2018 04:23:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=L3IcBOcMebSegDE2suDRtzdIfDfjoFDzHLWatOf7pRc=; b=j8n1TR2edzsHJGnQu1Z6SI8f4f4qaJovqUzYrxRRBWnN/3r/CSLPvMkvGuWdK9WW2y qGm1AjQyybuTzLqNrZnqNcbP6e9A+joalD+bsX5BxoE8vR3xB1xZGrD8cBJPKOLB3XYs nGGKYhaJxgQw4IVqH2odSYKp02Opc1q2Ff99eOCxJRpqzFU6rkUzBieKiZdsYZyRS+Pp rNjttJEsMChR7KEtD3l9uUa2hu3Zv+vHCQwSAjfAESABbtouvfqVBFvzn0+zKTj7/QsS nEVwkipi+fwQxE93pPQ0KgtZoOKbahgk1sC9PqL46FtiuaqJiwiQjUxu13WsFMuGJkOc Fyqw== X-Gm-Message-State: AA+aEWYNmFn+x0pI4bGwh3mZpnQln98e7gf+GNKY6EpXQI9YIFQjl5RS mJRBpkdDZ1UbARMzz1M3NAY= X-Google-Smtp-Source: AFSGD/W+ahtDp3KH0WT3OuHcaqjTmG8XYhWE4G4B62ekVjbHPEE1Vbep23gig1Bmq5eHfclZDz4PuQ== X-Received: by 2002:a2e:8ec8:: with SMTP id e8-v6mr9863359ljl.162.1543839837418; Mon, 03 Dec 2018 04:23:57 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id v5-v6sm2477864lje.78.2018.12.03.04.23.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 04:23:56 -0800 (PST) Date: Mon, 3 Dec 2018 14:23:43 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v5 9/9] clk: bd718x7: Initial support for ROHM bd71837/bd71847 PMIC clock Message-ID: <3bb96772e26833fe121fd99ea53eca616c2955be.1543837442.git.matti.vaittinen@fi.rohmeurope.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181203_042409_148274_88448FAD X-CRM114-Status: GOOD ( 18.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, lee.jones@linaro.org, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ROHM bd71837 and bd71847 contain 32768Hz clock gate. Support the clock using generic clock framework. Note, only bd71837 is tested but bd71847 should be identical what comes to clk parts. Signed-off-by: Matti Vaittinen --- drivers/clk/Kconfig | 7 +++ drivers/clk/Makefile | 1 + drivers/clk/clk-bd718x7.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 drivers/clk/clk-bd718x7.c diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 81cdb4eaca07..2dc12bf75b1b 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -283,6 +283,13 @@ config COMMON_CLK_STM32H7 ---help--- Support for stm32h7 SoC family clocks +config COMMON_CLK_BD718XX + tristate "Clock driver for ROHM BD718x7 PMIC" + depends on MFD_ROHM_BD718XX + help + This driver supports ROHM BD71837 and ROHM BD71847 + PMICs clock gates. + source "drivers/clk/actions/Kconfig" source "drivers/clk/bcm/Kconfig" source "drivers/clk/hisilicon/Kconfig" diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 72be7a38cff1..a47430b387db 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -21,6 +21,7 @@ endif obj-$(CONFIG_MACH_ASM9260) += clk-asm9260.o obj-$(CONFIG_COMMON_CLK_AXI_CLKGEN) += clk-axi-clkgen.o obj-$(CONFIG_ARCH_AXXIA) += clk-axm5516.o +obj-$(CONFIG_COMMON_CLK_BD718XX) += clk-bd718x7.o obj-$(CONFIG_COMMON_CLK_CDCE706) += clk-cdce706.o obj-$(CONFIG_COMMON_CLK_CDCE925) += clk-cdce925.o obj-$(CONFIG_ARCH_CLPS711X) += clk-clps711x.o diff --git a/drivers/clk/clk-bd718x7.c b/drivers/clk/clk-bd718x7.c new file mode 100644 index 000000000000..df5f1068ce8e --- /dev/null +++ b/drivers/clk/clk-bd718x7.c @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 ROHM Semiconductors +// bd71837.c -- ROHM BD71837MWV clock driver + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct bd718xx_clk { + struct clk_hw hw; + u8 reg; + u8 mask; + struct platform_device *pdev; + struct bd718xx *mfd; +}; + +static int bd71837_clk_set(struct clk_hw *hw, int status) +{ + struct bd718xx_clk *c = container_of(hw, struct bd718xx_clk, hw); + + return regmap_update_bits(c->mfd->regmap, c->reg, c->mask, status); +} + +static void bd71837_clk_disable(struct clk_hw *hw) +{ + int rv; + struct bd718xx_clk *c = container_of(hw, struct bd718xx_clk, hw); + + rv = bd71837_clk_set(hw, 0); + if (rv) + dev_dbg(&c->pdev->dev, "Failed to disable 32K clk (%d)\n", rv); +} + +static int bd71837_clk_enable(struct clk_hw *hw) +{ + return bd71837_clk_set(hw, 1); +} + +static int bd71837_clk_is_enabled(struct clk_hw *hw) +{ + int enabled; + int rval; + struct bd718xx_clk *c = container_of(hw, struct bd718xx_clk, hw); + + rval = regmap_read(c->mfd->regmap, c->reg, &enabled); + + if (rval) + return rval; + + return enabled & c->mask; +} + +static const struct clk_ops bd71837_clk_ops = { + .prepare = &bd71837_clk_enable, + .unprepare = &bd71837_clk_disable, + .is_prepared = &bd71837_clk_is_enabled, +}; + +static int bd71837_clk_probe(struct platform_device *pdev) +{ + struct bd718xx_clk *c; + int rval = -ENOMEM; + const char *parent_clk; + struct device *parent = pdev->dev.parent; + struct bd718xx *mfd = dev_get_drvdata(parent); + struct clk_init_data init = { + .name = "bd718xx-32k-out", + .ops = &bd71837_clk_ops, + }; + + c = devm_kzalloc(&pdev->dev, sizeof(*c), GFP_KERNEL); + if (!c) + return -ENOMEM; + + init.num_parents = 1; + parent_clk = of_clk_get_parent_name(parent->of_node, 0); + + init.parent_names = &parent_clk; + if (!parent_clk) { + dev_err(&pdev->dev, "No parent clk found\n"); + return -EINVAL; + } + + c->reg = BD718XX_REG_OUT32K; + c->mask = BD718XX_OUT32K_EN; + c->mfd = mfd; + c->pdev = pdev; + c->hw.init = &init; + + of_property_read_string_index(parent->of_node, + "clock-output-names", 0, &init.name); + + rval = devm_clk_hw_register(&pdev->dev, &c->hw); + if (!rval) { + rval = devm_clk_hw_register_clkdev(&pdev->dev, + &c->hw, init.name, NULL); + if (rval) + dev_warn(&pdev->dev, "Failed to register clkdev\n"); + if (parent->of_node) { + rval = devm_of_clk_add_parent_hw_provider(&pdev->dev, + of_clk_hw_simple_get, &c->hw); + if (rval) + dev_err(&pdev->dev, + "adding clk provider failed\n"); + } + } else { + dev_err(&pdev->dev, "failed to register 32K clk"); + } + + return rval; +} + +static struct platform_driver bd71837_clk = { + .driver = { + .name = "bd718xx-clk", + }, + .probe = bd71837_clk_probe, +}; + +module_platform_driver(bd71837_clk); + +MODULE_AUTHOR("Matti Vaittinen "); +MODULE_DESCRIPTION("BD71837 chip clk driver"); +MODULE_LICENSE("GPL");