From patchwork Tue Dec 4 11:33:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10711563 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 ED28414E2 for ; Tue, 4 Dec 2018 11:33:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8E6E2B3A1 for ; Tue, 4 Dec 2018 11:33:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9AA42B705; Tue, 4 Dec 2018 11:33: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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99A212B3A1 for ; Tue, 4 Dec 2018 11:33:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726324AbeLDLdU (ORCPT ); Tue, 4 Dec 2018 06:33:20 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33358 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbeLDLdT (ORCPT ); Tue, 4 Dec 2018 06:33:19 -0500 Received: by mail-lj1-f195.google.com with SMTP id v1-v6so14582842ljd.0; Tue, 04 Dec 2018 03:33:16 -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=XpsSi0+yUp3jaVjKpWoYffPxMgxENs/oMkn95BNj54M=; b=CD9y504UVSHnNp2Y4t+at9ItaMhcBklL073pbn+EyT1w8H4UfAPaPrELnG5vA1lp/Z 6WxuNeZMH6//0iTaAudVEAVTo4zrHiOM8foV2dA9D1Q0K/fWSKVEbl86Zgw+MC+hHEDf hy5kxLp91TkNB3rw4niBLGdumKivOF/6wC9hFqNMopCZIfb+pW2Gud+sV6/FpSQIkycj 3xS//C/ZtDmtcp480OoCrWbQzYNy9byg/NbUF46YpuSz6DC09BGu8DicBB3+p9SsL7Os 78B8uNW38sz0Mw5DDeBYPvBKuUg0VvSaTheAS1HWvoqAncvexF+wiIqwcUEhit/11xEm 8iIw== X-Gm-Message-State: AA+aEWbuGhixT6iFlYhgXuSIaVvvlu1Q2E71YecuHPwZKgqGISwT9T64 bwTPvek468M1Ck7qZXGgcJI= X-Google-Smtp-Source: AFSGD/WPkBvSBuMZP3N2oL0/t5DVoibuBAbwXir6P0FkHm8sgEfBuH5XYSGFdlWjDq5IHDTVmojpIg== X-Received: by 2002:a2e:4c0a:: with SMTP id z10-v6mr12482029lja.85.1543923194867; Tue, 04 Dec 2018 03:33:14 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id k11-v6sm3067694ljk.40.2018.12.04.03.33.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:33:14 -0800 (PST) Date: Tue, 4 Dec 2018 13:33:01 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Cc: mturquette@baylibre.com, sboyd@kernel.org, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, linux@armlinux.org.uk, andy.gross@linaro.org, david.brown@linaro.org, pavel@ucw.cz, andrew.smirnov@gmail.com, pombredanne@nexb.com, sjhuang@iluvatar.ai, akshu.agrawal@amd.com, djkurtz@chromium.org, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 01/10] clkdev: add managed clkdev lookup registration Message-ID: <5a1ce8dabda1994a050ed0b9095b3df1c4c2895f.1543922403.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) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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 | 111 +++++++++++++++++++++++++++------- include/linux/clkdev.h | 4 ++ 3 files changed, 93 insertions(+), 23 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..4621f8a91fc0 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -401,6 +401,23 @@ 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 @@ -423,17 +440,8 @@ int clk_register_clkdev(struct clk *clk, const char *con_id, 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; + return do_clk_register_clkdev(__clk_get_hw(clk), &cl, con_id, + dev_id); } EXPORT_SYMBOL(clk_register_clkdev); @@ -456,18 +464,75 @@ 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; + + 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 Tue Dec 4 11:33:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10711567 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 EC931109C for ; Tue, 4 Dec 2018 11:34:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D730C2B72B for ; Tue, 4 Dec 2018 11:34:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C56B92B734; Tue, 4 Dec 2018 11:34:07 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 684AC2B72B for ; Tue, 4 Dec 2018 11:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726205AbeLDLeG (ORCPT ); Tue, 4 Dec 2018 06:34:06 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:42082 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbeLDLeG (ORCPT ); Tue, 4 Dec 2018 06:34:06 -0500 Received: by mail-lj1-f194.google.com with SMTP id l15-v6so14565813lja.9; Tue, 04 Dec 2018 03:34:03 -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=D9Xfj5O6TrPCZ4XAaumYQKAYYnZ79yMVJdwXxt1b5i0=; b=gTpKOWLMz+5nBpvh2F7P6C3vmb1PCq192jz2R6YgdKjMWCo6OSbt7hVnfv8+6ttEYI dvT3DLDkm9L2ejMiE2LbMDD6fJNT9QBxdXhGgPCcpDhJuhSScVKw0n8RqG10U3741z7V YdegiJITFagVzSfuFHMQV0xb1J3A60Gqs8/VMYfoyke8PPLsgBFJrxwvoqhSurG8DZFz /CBqiU3HlVFS2m0ZYlKf7AGcv7HEo5NS5Tpdn3WCh8yZRWnpGmgGjWlZGsEQVLW7v9ZT Pft0WxPeczt6AyOABl7uR2Esb9gY/LTNE/yPrRheyBCDzz9GMQ6J198P4hdhZ0kMvvfc AquA== X-Gm-Message-State: AA+aEWbRUEdrM0MzeSjpldSPBHAYsWsyIalVYBqzzG+v0zB/EV3Zat6k yHm6rYC3peqyPzN/MxJJjGY= X-Google-Smtp-Source: AFSGD/VfpVRI6uMyQNhr/c9FW6Ywud7OWk+oS7nf1VGsTMoPXyA5RaDpG1w+CiC52xYvr7CdcOSZ2Q== X-Received: by 2002:a2e:88cf:: with SMTP id a15-v6mr12336777ljk.76.1543923242641; Tue, 04 Dec 2018 03:34:02 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id g70-v6sm3120443ljg.92.2018.12.04.03.34.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:34:01 -0800 (PST) Date: Tue, 4 Dec 2018 13:33:48 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Cc: mturquette@baylibre.com, sboyd@kernel.org, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, linux@armlinux.org.uk, andy.gross@linaro.org, david.brown@linaro.org, pavel@ucw.cz, andrew.smirnov@gmail.com, pombredanne@nexb.com, sjhuang@iluvatar.ai, akshu.agrawal@amd.com, djkurtz@chromium.org, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 02/10] clk: Add kerneldoc to managed of-provider interfaces Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Document the devm_of_clk_del_provider and the devm_of_clk_add_hw_provider functions. Signed-off-by: Matti Vaittinen --- drivers/clk/clk.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index af011974d4ec..78c90913f987 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3893,6 +3893,17 @@ static void devm_of_clk_release_provider(struct device *dev, void *res) of_clk_del_provider(*(struct device_node **)res); } +/** + * 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), @@ -3950,6 +3961,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; From patchwork Tue Dec 4 11:34: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: 10711571 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 830C4109C for ; Tue, 4 Dec 2018 11:35:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 720EC2A4CD for ; Tue, 4 Dec 2018 11:35:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62E2F2B72C; Tue, 4 Dec 2018 11:35:11 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F26232A4CD for ; Tue, 4 Dec 2018 11:35:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726199AbeLDLfK (ORCPT ); Tue, 4 Dec 2018 06:35:10 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:34854 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726169AbeLDLfK (ORCPT ); Tue, 4 Dec 2018 06:35:10 -0500 Received: by mail-lf1-f66.google.com with SMTP id e26so11701176lfc.2; Tue, 04 Dec 2018 03:35:07 -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=0RckClGYQ+6fUhKznGresT7KY8caowujFh1vtX39WAg=; b=Cfoyrhw/Sjo8DLR3e6Bk7+EJBEsV3RnUg3xurnHafdH+h5f0PVqg25Dh10y+Wsrc60 LRamfuN+z9ttv2mjDeVxhgjxIFxmOOlJNU4VJz9AsJ+43GEMAd2yGXNtQN/5YHbcBWv7 xqMCMt8yh/gfTO1TaKp2sO9vW53ajp8kdwz4eRs3tB+NxlaYhHzdHBjuOHtoVSeKjBRF 0VSnWFFLAo0Ig3Tu+vaV1CovPokjWo/QCGEZJv/Lx8NDTcaiXX/EUW4GA5H1M80py8dP yJHtPCd+K3gfiQgxNJ2JyjJnl3SMjhRAPNAM1VcmGPXNg0G5VP/TcQNvfPdJY14OHEts yvUA== X-Gm-Message-State: AA+aEWbNujN5H11Wx9VFC+MUpPGFT8sGmhLjFtnbkb9srWk1rRrx1VyB zKe+WAGFvcDZKaOWHqKS2Rg= X-Google-Smtp-Source: AFSGD/UgenwKc3SIhW9D1jJ9m5flJIPZI+ng3DCVvFo6WFolegTKyZfQr7vyCVs8/MQiK0k8Dg08+g== X-Received: by 2002:a19:6a13:: with SMTP id u19mr11029739lfu.46.1543923306734; Tue, 04 Dec 2018 03:35:06 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id f11sm2937781lfi.12.2018.12.04.03.35.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:35:06 -0800 (PST) Date: Tue, 4 Dec 2018 13:34:53 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Cc: mturquette@baylibre.com, sboyd@kernel.org, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, linux@armlinux.org.uk, andy.gross@linaro.org, david.brown@linaro.org, pavel@ucw.cz, andrew.smirnov@gmail.com, pombredanne@nexb.com, sjhuang@iluvatar.ai, akshu.agrawal@amd.com, djkurtz@chromium.org, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 03/10] clk: of-provider: look at parent if registered device has no provider info Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It seems to be usual for MFD devices that the created 'clock sub-device' do not have own DT node. The clock provider information is usually in the main device node which is owned by the MFD device. Change the devm variant of clk of-provider registration to check the parent device node if given device has no own node or if the node does not contain the #clock-cells property. In such case use the parent node if it contains the #clock-cells. Signed-off-by: Matti Vaittinen --- drivers/clk/clk.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 78c90913f987..66dc7c1483d7 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3893,6 +3893,11 @@ static void devm_of_clk_release_provider(struct device *dev, void *res) of_clk_del_provider(*(struct device_node **)res); } +static int of_is_clk_provider(struct device_node *np) +{ + return !!of_find_property(np, "#clock-cells", NULL); +} + /** * devm_of_clk_add_hw_provider() - Managed clk provider node registration * @dev: Device acting as the clock provider. Used for DT node and lifetime. @@ -3901,8 +3906,11 @@ static void devm_of_clk_release_provider(struct device *dev, void *res) * * Returns 0 on success or an errno on failure. * - * Registers clock provider for given device's node. Provider is automatically - * released at device exit. + * Registers clock provider for given device's node. If the device has no DT + * node or if the device node lacks of clock provider information (#clock-cells) + * then the parent device's node is scanned for this information. If parent node + * has the #clock-cells then it is used in registration. 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, @@ -3912,12 +3920,17 @@ int devm_of_clk_add_hw_provider(struct device *dev, struct device_node **ptr, *np; int ret; + np = dev->of_node; + + if (!of_is_clk_provider(dev->of_node)) + if (of_is_clk_provider(dev->parent->of_node)) + np = dev->parent->of_node; + ptr = devres_alloc(devm_of_clk_release_provider, sizeof(*ptr), GFP_KERNEL); if (!ptr) return -ENOMEM; - np = dev->of_node; ret = of_clk_add_hw_provider(np, get, data); if (!ret) { *ptr = np; @@ -3968,9 +3981,15 @@ static int devm_clk_provider_match(struct device *dev, void *res, void *data) void devm_of_clk_del_provider(struct device *dev) { int ret; + struct device_node *np; + + np = dev->of_node; + if (!of_is_clk_provider(dev->of_node)) + if (of_is_clk_provider(dev->parent->of_node)) + np = dev->parent->of_node; ret = devres_release(dev, devm_of_clk_release_provider, - devm_clk_provider_match, dev->of_node); + devm_clk_provider_match, np); WARN_ON(ret); } From patchwork Tue Dec 4 11:35:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10711575 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 0B1E614E2 for ; Tue, 4 Dec 2018 11:36:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF8AF2B72C for ; Tue, 4 Dec 2018 11:36:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3AAF2B763; Tue, 4 Dec 2018 11:36:12 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EBC32B734 for ; Tue, 4 Dec 2018 11:36:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725767AbeLDLgM (ORCPT ); Tue, 4 Dec 2018 06:36:12 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:46851 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725910AbeLDLgM (ORCPT ); Tue, 4 Dec 2018 06:36:12 -0500 Received: by mail-lf1-f68.google.com with SMTP id f23so11663210lfc.13; Tue, 04 Dec 2018 03:36: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=OMDW0BBEob281Ew2OkowKuqON5GnzN6B7Aw/Pih2LVk=; b=j5SUW/lFcN6fWrjOWSOb9TMG9WM+dwnVFSLO3NQxlyolQ/+9q8YE/vFHXURBw3Im2E NzYzE9qrhOpcchfsM2dDKdPCt+Cud5vMY2B436IkmJVJ/bfxkw5d18EFwv+7me5JqRNA r6OPeIMNv+Pjoq2n6N36w5Kh/ULJNT/fD59DfJAzkn55EGJ1Yw7vlJ7INUZ8Dx7GF1wf qatUblrmunsmWVOCRcUSSPeKov2P/ZOwPsgGKl9wI7h7rqI0NZm/RbifHF93bLRyQHdW e7XglVly+UApb0u9YrZ7ouqW4Rnve7E+rtqwVBOlUd90biyA8TzdkcjiREYQIZARDkid OnDw== X-Gm-Message-State: AA+aEWaBHCpUWr43RTBrr1+bnvf1fMbP2Y37aFkNDGP0IejQTshrYUE9 i3O1tAqJaKu6Ht+p0zS0mx4= X-Google-Smtp-Source: AFSGD/WcGn4UOdUXoiEFJFp1gk/+VJnPX6XF/xdRrHNWCYk2XW10C7I3CIDk3QLQS2zpJI16OeMN6Q== X-Received: by 2002:a19:4e59:: with SMTP id c86mr12231019lfb.132.1543923367575; Tue, 04 Dec 2018 03:36:07 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id k11-v6sm3069000ljk.40.2018.12.04.03.36.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:36:06 -0800 (PST) Date: Tue, 4 Dec 2018 13:35:52 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Cc: mturquette@baylibre.com, sboyd@kernel.org, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, linux@armlinux.org.uk, andy.gross@linaro.org, david.brown@linaro.org, pavel@ucw.cz, andrew.smirnov@gmail.com, pombredanne@nexb.com, sjhuang@iluvatar.ai, akshu.agrawal@amd.com, djkurtz@chromium.org, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 04/10] clk: clk-max77686: Clean clkdev lookup leak and use devm Message-ID: <41eb57e80f1a8bcd5e48e1d0b86859c5aae61d2e.1543922403.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) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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_hw_provider. Signed-off-by: Matti Vaittinen Reviewed-by: Krzysztof Kozlowski --- drivers/clk/clk-max77686.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c index 22c937644c93..3727d5472450 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,8 @@ 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_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 +262,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 +282,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 Tue Dec 4 11:37:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10711579 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 DB13E109C for ; Tue, 4 Dec 2018 11:37:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C784B2A4CD for ; Tue, 4 Dec 2018 11:37:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B81972B734; Tue, 4 Dec 2018 11:37:13 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A0A62A4CD for ; Tue, 4 Dec 2018 11:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725863AbeLDLhM (ORCPT ); Tue, 4 Dec 2018 06:37:12 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:34985 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725910AbeLDLhM (ORCPT ); Tue, 4 Dec 2018 06:37:12 -0500 Received: by mail-lf1-f65.google.com with SMTP id e26so11705603lfc.2; Tue, 04 Dec 2018 03:37:10 -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=IPaANYg+BKvew3Ns6tmkF9qat1yGp0JhQQkX999AOmA=; b=pBMnYmwxRiv4Vf19MH3ryEOWLpdRoLpNigecyhwemoRDPR61T3t8x7CHhm6iDLnHWb H9bit1uLyI52SlXk+ICEBVLbWUkNnZju3N9qCqENkxzfKDjA20oK4muLYdBJZOgHrK3r 0TdS85z2m9Y6JxIPHMwtryM5K+ByLVFJcDh5u9CYP5uKeRObreO5T5fsi3b6loUdy7xY 3jUag0SgvwXOffwzfHIVOqpGjxxxgjHUuQMYO8kCTMTwcM20UrJTyrZdldGK9nvrr4Sl HcGKmd1xIbOVu2W5R4F4C4YhHAYdCi8sM5pcPOtLFJ6PRLVpXtrhBI2AZzcqdCY/tgFt pn/w== X-Gm-Message-State: AA+aEWYkU1I1Hye5W/Oj527gHhG2MLktcfrxG9el9GU2ZKyzZmzleW7V +dNuSFCa+v2KQ/x4OFfaqYA= X-Google-Smtp-Source: AFSGD/Vp5vXzXS4X9QTXmNF5hhCzfpnIqUNuj24oPKEvSrTWjEa04sxBZOR8RlzvO3cj6YwgW26BQQ== X-Received: by 2002:a19:db4a:: with SMTP id s71mr11966423lfg.36.1543923428923; Tue, 04 Dec 2018 03:37:08 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id a20-v6sm3086214ljf.28.2018.12.04.03.37.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:37:08 -0800 (PST) Date: Tue, 4 Dec 2018 13:37:01 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Cc: mturquette@baylibre.com, sboyd@kernel.org, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, linux@armlinux.org.uk, andy.gross@linaro.org, david.brown@linaro.org, pavel@ucw.cz, andrew.smirnov@gmail.com, pombredanne@nexb.com, sjhuang@iluvatar.ai, akshu.agrawal@amd.com, djkurtz@chromium.org, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 05/10] clk: clk-st: avoid clkdev lookup leak at remove Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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 Tue Dec 4 11:37:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10711583 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 8738E14E2 for ; Tue, 4 Dec 2018 11:37:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75F7A2B72C for ; Tue, 4 Dec 2018 11:37:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A11A2B763; Tue, 4 Dec 2018 11:37:48 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 218DE2B72C for ; Tue, 4 Dec 2018 11:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726064AbeLDLhr (ORCPT ); Tue, 4 Dec 2018 06:37:47 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:41519 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbeLDLhr (ORCPT ); Tue, 4 Dec 2018 06:37:47 -0500 Received: by mail-lf1-f67.google.com with SMTP id c16so11680106lfj.8; Tue, 04 Dec 2018 03:37:43 -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=GIzu5TM0Q0ij7JdKvBe/DIJ+uIu2SF/SLoojaqBlAkU=; b=RyqV9Z03vqlN4CknqIenGR8taN64AhmVmIJ92jl8mvuM01DyfADekBG3OwxwnFpzK1 m+lf/wJv+Ftu9GYK8JC8REzZwA8WIkwjJ9UYes0n5hMq0o5lBiWTr2K/Xk499xXJXuTB ixqFTtH7wX3FuQ71g+2JyiQ1+EINUwarYZ1dRb+Ai17hBGcpqvers5N4N4eIw37bR7xK C2QWzzQNIo3Z9PPFKS1d2t+PxoddJVrSWjvfjAJWI9FZeWiq4QJyql3koNGGUNK298C4 eYb+0q3FbCrwqF1qMM5PMUaTpGPbDS2samqMJKF6KasySFxZJPf6tpbbzvXSoZ2yVawC d7ig== X-Gm-Message-State: AA+aEWYpGhSWVDGSUkiKJf1UW9UD1WSeatKQk4y9gG/gvGsoxd6yCi0c ged8ubKIG5GdntdxRKaW46w= X-Google-Smtp-Source: AFSGD/VViV3CLRN5jn1QfIg3yeByA6Pca3qlmf7TgBZw3CGSaVwAwPUi2LOC5/ENoK1+9KOlr9U1dA== X-Received: by 2002:a19:5402:: with SMTP id i2mr11152848lfb.128.1543923462510; Tue, 04 Dec 2018 03:37:42 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id e94sm2935609lfi.23.2018.12.04.03.37.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:37:41 -0800 (PST) Date: Tue, 4 Dec 2018 13:37:29 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Cc: mturquette@baylibre.com, sboyd@kernel.org, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, linux@armlinux.org.uk, andy.gross@linaro.org, david.brown@linaro.org, pavel@ucw.cz, andrew.smirnov@gmail.com, pombredanne@nexb.com, sjhuang@iluvatar.ai, akshu.agrawal@amd.com, djkurtz@chromium.org, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 06/10] clk: clk-hi655x: Free of_provider at remove Message-ID: <90cd96112ca1ade6bff3b58989e290ae3def59e2.1543922403.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) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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..a0de3315df2e 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_hw_provider(&pdev->dev, of_clk_hw_simple_get, + &hi655x_clk->clk_hw); } static struct platform_driver hi655x_clk_driver = { From patchwork Tue Dec 4 11:38:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10711587 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 59871109C for ; Tue, 4 Dec 2018 11:38:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4945E2A4CD for ; Tue, 4 Dec 2018 11:38:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C1A72B734; Tue, 4 Dec 2018 11:38:20 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD79B2A4CD for ; Tue, 4 Dec 2018 11:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726199AbeLDLiT (ORCPT ); Tue, 4 Dec 2018 06:38:19 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:46402 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbeLDLiT (ORCPT ); Tue, 4 Dec 2018 06:38:19 -0500 Received: by mail-lj1-f196.google.com with SMTP id v15-v6so14551622ljh.13; Tue, 04 Dec 2018 03:38:16 -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=s0eoIBAlLdqa/lK+b31yZx/TLpcNisuF7h28Wa3I9ec=; b=MKDSkbvW8KHe+xmTHPgG098Pwj741OzNCQw0m7Lax9z0W5m2H4aL8jFW7YMwaEOPkf urqjlh0FJfZS0ZcupqsLkt/97c6rGU0s2PJfTEsjQMVz60cY33GAhazbeB3hIDNN9zHW rzTG3r5UcRzhkcheDXg26vTfDL66jQHUdw+PRyhXMeTRQn8wwyci13VOfV5FeU7Qivcq 3PrC7dkXBqF7OwwS2ehmUtA+pujzAdC/mgeoDTYcuhreJTFxqvi7UHpfg45TzBgkgYxn bpyqCq+CYOeqF5Z+6w5+RCmE6f1Kvu+mcPugl8z1ztyes7TeYofqIsbYhwywjj76PXlf vvqg== X-Gm-Message-State: AA+aEWYnEY+oQ/MRMdjKhn5xR1wLordxhf4WQTY7PL+DZbAkaAyLuHXk eJ6G5QWt5eyqljSTx+Eh2mw= X-Google-Smtp-Source: AFSGD/Uvsg6v6MNTQzmy8FcIl7zel0Oo0WeO1tgPHUa42MfR8TPjKSMum2kB50pJjhclNHQStDf3VA== X-Received: by 2002:a2e:880a:: with SMTP id x10-v6mr13737293ljh.174.1543923495868; Tue, 04 Dec 2018 03:38:15 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id q21-v6sm3068085ljc.5.2018.12.04.03.38.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:38:15 -0800 (PST) Date: Tue, 4 Dec 2018 13:38:03 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Cc: mturquette@baylibre.com, sboyd@kernel.org, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, linux@armlinux.org.uk, andy.gross@linaro.org, david.brown@linaro.org, pavel@ucw.cz, andrew.smirnov@gmail.com, pombredanne@nexb.com, sjhuang@iluvatar.ai, akshu.agrawal@amd.com, djkurtz@chromium.org, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 07/10] 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) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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..8d90bdf5b946 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_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 Tue Dec 4 11:38:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10711591 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 77A8F14E2 for ; Tue, 4 Dec 2018 11:38:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 654E42A47B for ; Tue, 4 Dec 2018 11:38:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 556852A4E0; Tue, 4 Dec 2018 11:38:51 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA8BD2A47B for ; Tue, 4 Dec 2018 11:38:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726202AbeLDLiu (ORCPT ); Tue, 4 Dec 2018 06:38:50 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:38680 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbeLDLiu (ORCPT ); Tue, 4 Dec 2018 06:38:50 -0500 Received: by mail-lf1-f68.google.com with SMTP id p86so11690840lfg.5; Tue, 04 Dec 2018 03:38:47 -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=ZdU1eWJ3OUe0zNYgDLJWqUhZGKZPNEOFUSCmMYIOKrc=; b=c0jI+G7hKLqa9FgSnytfLASjE8AwIPgnyYMCpGmDhcJBEhxLi1XvuRwC5Cke+HrlRk dqxGTq9YPQjy9ZOjmR7RKoF9/141jxB7lhgW08hGRRfo611tFuCohdjltc9ExrcaTyGv Yw6qh0Gdtd2j8xRESFmc5JqWmxa2uoOQCIEFZoGdEV5/+n62rnB8LHkkzRrpWPwn8jYb jfazT91P2N2NpB5MINqyvgvJo2qZa0L9G+Wv7XyV2cOktls3eK3bLGMmw1hH0LhMRHUw 8U2IdesNl/kHOFxEzvP2SQPpaUa/inP0tcD0DhYKM8d71Yymk3KgJkPOk+7OPCoj0SeN qfOQ== X-Gm-Message-State: AA+aEWZ7mXynpF6v+EcOGYnQvYx/YYzyDXqBSdi1r/4eI2JLhOV+XTXs pqEZR1vN+DhMuGbXNlusBDE= X-Google-Smtp-Source: AFSGD/V1xPO8IerCWDRq/eowaUVH5Dlt/SrQkU+0AKRmpC8SX2ZuRWhXGwxxjPIdY1NB+9b4oHQB5Q== X-Received: by 2002:a19:22c2:: with SMTP id i185mr8364473lfi.2.1543923526355; Tue, 04 Dec 2018 03:38:46 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id r27-v6sm3146758lja.65.2018.12.04.03.38.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:38:45 -0800 (PST) Date: Tue, 4 Dec 2018 13:38:32 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Cc: mturquette@baylibre.com, sboyd@kernel.org, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, linux@armlinux.org.uk, andy.gross@linaro.org, david.brown@linaro.org, pavel@ucw.cz, andrew.smirnov@gmail.com, pombredanne@nexb.com, sjhuang@iluvatar.ai, akshu.agrawal@amd.com, djkurtz@chromium.org, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 08/10] 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) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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..ea846f77750b 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_hw_provider(&pdev->dev, of_clk_hw_simple_get, + &clkdata->pdmclk_hw); } static struct platform_driver twl6040_pdmclk_driver = { From patchwork Tue Dec 4 11:39:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10711595 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 CDC8614BD for ; Tue, 4 Dec 2018 11:39:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF2582A77F for ; Tue, 4 Dec 2018 11:39:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0CEA2A7A8; Tue, 4 Dec 2018 11:39: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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 539BD2A77F for ; Tue, 4 Dec 2018 11:39:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725769AbeLDLjX (ORCPT ); Tue, 4 Dec 2018 06:39:23 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45924 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbeLDLjX (ORCPT ); Tue, 4 Dec 2018 06:39:23 -0500 Received: by mail-lf1-f66.google.com with SMTP id b20so11667792lfa.12; Tue, 04 Dec 2018 03:39:20 -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=cNeaSJewQo7AXSXmTlRQsr8ytveIkz3c28c/Of06XVA=; b=B1qmM2cSoLmCk1A5YAQ5F4Vm9YkKxz3we2bnsOoSva0HDTXbv7I0T3vwx7/p+YW5ro jS2gzchDgvf6haotS8n87BL/varFs0/coa/ihEJIMpRExTbnWvDnfl0vQLsowxx0KZ/h uAeUyMQgCdOmWZyDblAAqQVq0dpGLuvjztsIFcDq8tqCN9M0bxxDribrYpWAMsii23k5 BkxgXn7tT+oFHMgZM5gCt+FdINTi47YZkyfWUF/lKb9kWzNdgT69/1qADquwqLKCSpqU s6jVFVfuSQhfqAawq9z7rWIUccwKZetqzD7GPoA+qGlE/l5aVphpQV28c7090Y+Ow/66 YnhQ== X-Gm-Message-State: AA+aEWaQkuAOoqSAyHGGZVitUM0XdVjdhJQxQ2CVW2azbNpi50/nz+Jb kKyM/dbubfro0ybXDg+rw4M= X-Google-Smtp-Source: AFSGD/WGPbXiwSzE4jKPtOlbYWM67fnnrX8eiQEaP9mRC9t2UdhES4t4nq388kSaR7O2DigQrVo5hg== X-Received: by 2002:a19:22c2:: with SMTP id i185mr8365647lfi.2.1543923559787; Tue, 04 Dec 2018 03:39:19 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id d15-v6sm3078114lja.38.2018.12.04.03.39.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:39:19 -0800 (PST) Date: Tue, 4 Dec 2018 13:39:06 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Cc: mturquette@baylibre.com, sboyd@kernel.org, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, linux@armlinux.org.uk, andy.gross@linaro.org, david.brown@linaro.org, pavel@ucw.cz, andrew.smirnov@gmail.com, pombredanne@nexb.com, sjhuang@iluvatar.ai, akshu.agrawal@amd.com, djkurtz@chromium.org, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 09/10] clk: apcs-msm8916: simplify probe cleanup by using devm Message-ID: <1c73fcc1dcb63aa0e5c65492692658a9e74f3c2d.1543922403.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) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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..caa9b0d53d68 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_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 Tue Dec 4 11:39:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10711599 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 4284617D5 for ; Tue, 4 Dec 2018 11:39:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 318DC2A79E for ; Tue, 4 Dec 2018 11:39:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 243912A7C5; Tue, 4 Dec 2018 11:39: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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90B412A79E for ; Tue, 4 Dec 2018 11:39:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726152AbeLDLjz (ORCPT ); Tue, 4 Dec 2018 06:39:55 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45125 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbeLDLjz (ORCPT ); Tue, 4 Dec 2018 06:39:55 -0500 Received: by mail-lj1-f194.google.com with SMTP id s5-v6so14562551ljd.12; Tue, 04 Dec 2018 03:39:52 -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=Ai2EXp5GxvS/XTr9/6JJwFxk1UDo6UDucvIq5Od3QTc=; b=Blm2PgfypJuaticdd54Dc5vus2QCT9Cmyz2abSAHQTQNyr+R+kR5fDNSWzWww4dc5y 161Nf/bVFatf4G1nWvSWPGqhJm+Lj3MC5zBVJRLyql7xBFv4JmAI2ud6hU1LTW62xo5d +I7gz842i0CIyejfNb1cr0hBXSKk2is2NtEGmH1iounRi5BeURv7bQsvwOdjIFQvW1fA xIWDsaB/qFBGwt4soGXHyLsJwN3jmH4YIXbFMypYsqN+WbkF5Ms9o2vhOKpjAsIhhCv3 c5Way93nIdJ0DauUsi2f3hmTRtrwDGtp0TjrSP6oBhsdUS/vIp+UmE2vE1ELVKug/WXG bLhw== X-Gm-Message-State: AA+aEWY11gyvSdBywgeoFKrCld17P9gHAi3t6gNalXCZmatq9uCamd+Z E9Q84iFMZmm2X9TrEkLo7FTz1UOonrA= X-Google-Smtp-Source: AFSGD/XNqB9kMhc+OeBl5seLM3c21DGqtktYvKxNK4gpoRJTvcrNOYA6RtLflBjI9sCeYZCx3Xh8mg== X-Received: by 2002:a2e:3012:: with SMTP id w18-v6mr12533153ljw.75.1543923591387; Tue, 04 Dec 2018 03:39:51 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id b20sm2873339lfj.61.2018.12.04.03.39.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:39:50 -0800 (PST) Date: Tue, 4 Dec 2018 13:39:38 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Cc: mturquette@baylibre.com, sboyd@kernel.org, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, linux@armlinux.org.uk, andy.gross@linaro.org, david.brown@linaro.org, pavel@ucw.cz, andrew.smirnov@gmail.com, pombredanne@nexb.com, sjhuang@iluvatar.ai, akshu.agrawal@amd.com, djkurtz@chromium.org, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 10/10] clk: bd718x7: Initial support for ROHM bd71837/bd71847 PMIC clock Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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..d486859526ed --- /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_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");