From patchwork Tue Nov 13 11:55:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10680375 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 AA577139B for ; Tue, 13 Nov 2018 11:56:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94BA029FF2 for ; Tue, 13 Nov 2018 11:56:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87CA62A6AF; Tue, 13 Nov 2018 11:56:34 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 5490B29FF2 for ; Tue, 13 Nov 2018 11:56:33 +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=S5QkwvOngfcHkuMK1z7i/6Y3XiY7hv0EnC3MQMWPQbo=; b=WMGy6AvKJMCitX dtmSyW+7pCNYzE/t9f+Lc1QnGPIkocsiANxkl7HtH+Qvt8fEcl9iD6bX+JpkCmIW2M4Dal66Ljf4L Ov4VQanh7bAaNr2vLaozdF/wkFLMWovYo7BNvrTsSGKPWLYoYOJhI3hhf1sOowt8iX8Bv4vGwXq7u /1DV2lm+tkoDjyuxH9JqZ1Pv0v9hgYZ4EyKTdYHhzyGmyx2q8Sobs91cvalbKJsWwhqDoI4p514jo t9996gdBoQbS5LHuISbpx/EWolDXbjP8eR1fvWztbqQhOT9pyXXr0rnO3tOztSjJX4FtDw5O75HeI eiVVUL2dySBKriv7bPmQ==; 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 1gMXJ1-0002BH-5B; Tue, 13 Nov 2018 11:56:31 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXIz-0002An-1N for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 11:56:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=i+KZ9+62AmBi6LwLI4MDe8trUcZvmkQ3tsEjwOIjYlM=; b=oXie0zvcyH8tuRV+cK+AYE49a LElxQM+i/tdYxYt3AW7vIOFUdwCwZZZr323r83bj2af57e21TQEmMABcnTxXBm7lGwmlgh63H4BiF MJ6UltzM+Yy7Rvr3HWno78jvKtwtxJBxAgmoaB8Cu0qEG2tIY8Ln7shIh3AyR9aXwwYK/D1p8/9sa shYwpOqzr1DlqJHFmtTQugWVq5B1GF8d0dNfEjiZauWkpllW/wa5RfGEWiVxozB340Gb37r5H0ixe xxjU0iPwQQzD7461OwaU7bbJyNoLZwjS0eoop3BXg985pKrSgRscUB0hviJuC4bRh69YHXIkwwhcq GwL36Kh0Q==; Received: from mail-lj1-f193.google.com ([209.85.208.193]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXIw-00044T-3o for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 11:56:27 +0000 Received: by mail-lj1-f193.google.com with SMTP id x85-v6so10567068ljb.2 for ; Tue, 13 Nov 2018 03:56:14 -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=i+KZ9+62AmBi6LwLI4MDe8trUcZvmkQ3tsEjwOIjYlM=; b=m0kE1jUiFW7wGWVuFk3kCZoH6KlUT2iKAEBvInnrA73HL3LgFol442WS1nuxdSJFR5 +Fa5dm5qt3F6Rnw0NZdSq0UjU1ZfBdT9vkHYo7V4C8gHKI44kaTEYNkXy/00cRHyggbl xD1teAnhWN77kWazvMuXqcFQD3GZeeWGamNXiRCVhJezCcJEl9PQWWyO0lNDA8fw5Zfo X5jnIHu621w/7o6+JIaXXYqMEZwIRGwhDg60HmWnYD3VPfepIf+JzkIdkE8PSnOW9WTP 01yI3jJrRFlkIVY4Ris1ytcLsyTP3JhfenM3L4KEl+le5QQkJDBhzwU+1gnUpCW0XSo4 Ji2Q== X-Gm-Message-State: AGRZ1gJLcoG1GZd9l/FWPZYYmhPo2BhAZOacz6F5UOfNc4gnJAt+QTvp jiDHrSHQoQw2/Y8cc0AtiUA= X-Google-Smtp-Source: AJdET5dfVzgYUBkrPtM5r2r6qpEmSu6H9Is6ip9ppRrEfzXHkTxavCxRb0mE6ov5syKqPOzB79t/uQ== X-Received: by 2002:a2e:8187:: with SMTP id e7-v6mr2955037ljg.50.1542110172456; Tue, 13 Nov 2018 03:56:12 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id c14sm3423949lfb.40.2018.11.13.03.56.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 03:56:11 -0800 (PST) Date: Tue, 13 Nov 2018 13:55:58 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com Subject: [PATCH v4 1/8] clk: clkdev/of_clk - add managed lookup and provider registrations 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-20181113_065626_198452_55C5DF27 X-CRM114-Status: GOOD ( 28.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: linux-doc@vger.kernel.org, Michael Turquette , Daniel Kurtz , Sebastian Reichel , David Brown , Lee Jones , linux-clk@vger.kernel.org, Rob Herring , Jonathan Corbet , Andrey Smirnov , "Rafael J. Wysocki" , Russell King , Krzysztof Kozlowski , Chanwoo Choi , Andy Gross , Huang Shijie , Guenter Roeck , Bartlomiej Zolnierkiewicz , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Matti Vaittinen , linux-kernel@vger.kernel.org, Akshu Agrawal 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. Also 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 | 3 + drivers/clk/clk.c | 28 ++++++-- drivers/clk/clkdev.c | 122 ++++++++++++++++++++++++++-------- include/linux/clk-provider.h | 11 +++ include/linux/clkdev.h | 4 ++ 5 files changed, 136 insertions(+), 32 deletions(-) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 43681ca0837f..fac63760b01c 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -238,6 +238,9 @@ 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() + devm_clk_release_clkdev() DMA dmaenginem_async_device_register() diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index af011974d4ec..9bb921eb90f6 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,10 +3906,9 @@ 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); + *ptr = of_node; + ret = of_clk_add_hw_provider(of_node, get, data); if (!ret) { - *ptr = np; devres_add(dev, ptr); } else { devres_free(ptr); @@ -3917,8 +3916,25 @@ int devm_of_clk_add_hw_provider(struct device *dev, return ret; } +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); +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 diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 9ab3db8b3988..f6100b6e06fd 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/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( 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 Nov 13 11:57: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: 10680387 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 9BDCB13BF for ; Tue, 13 Nov 2018 11:57:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87E8029FE1 for ; Tue, 13 Nov 2018 11:57:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B0B029FF2; Tue, 13 Nov 2018 11:57: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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 815A029FE1 for ; Tue, 13 Nov 2018 11:57: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=sIi/llkjppitL2PnFr19iFLJfrAZLczbs981OSu9R+s=; b=Mpa6r43Vfs9JRn 72YHlpESw3uQc9g1wjJHygFf5f+u98YW9Dh4OgkeUsuVFUvdbyodghnczH4wo5UqurHbSCnxlLFTc HGjXkTYcMCR1xupN6IMs/qzve/DcqW4uYPgi1F6otInPSavJql5e2idLh4zRIcM+VYfc44aM+5g2o YUP542gtyFvb7Knv6rvhKaBUktuFOD34G5H6e328wwZQwQU3wew81XSSyxaOYaJPMXLrkH4KbJgyU 53LbnQ2+W7xOiIUdU0yabNoH61tAgyzQNt5DIoEChu30vZ7dYKurD/U5YrkC8yW4Uz6DAU0f9IIR0 c89AF/+Q2Kbbggq2pTCA==; 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 1gMXKJ-0003Wq-Dy; Tue, 13 Nov 2018 11:57:51 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXKH-0003WG-RK for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 11:57:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fJ06/MEsQS8wIywHorlvQqUqrYoodnmIZrcXjxSdJq0=; b=q+G6pzn2O5NHHSqkVrHLjlIx4 2nuI+OIZ/PhkN9snYgL885ly+trdoahd/7DpKYsx6VW1ZCYmSlbhTHoiYKNfh53V0Ea5m/8lfGQI/ nszlfmRhHE0CGUJrLuSMEhLfANzM9j4lecYlDan3piw+x9zkKAZ5LYjseZ596RK4ManDaWG1zn+iP l14DN5G6Bhmc6Yn3wPDtD3ozGcCo57rchjWimux6S8QuAQUxHiSodtuVmIdRIuN7zZY22PIATYK7b WCBwGrR4aguSDqWULT2t30SKlXVJejp3yk/hlT4EwwEbG92bexFFTRs+16IepdTb6/aRs80T9yHYB MhWfApxJQ==; Received: from mail-lj1-f195.google.com ([209.85.208.195]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXKD-00046g-8e for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 11:57:47 +0000 Received: by mail-lj1-f195.google.com with SMTP id l15-v6so2352092lja.9 for ; Tue, 13 Nov 2018 03:57: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=fJ06/MEsQS8wIywHorlvQqUqrYoodnmIZrcXjxSdJq0=; b=PksblGNuDlk8316JxlpUEZNngzXzhqXgNG/EAefk2On4MgEe/XvrgS0ATHqwubrg+P nqs9HX7G4nhBwN+kCzvsGve/PWsMAQiNi9+DjhE7Hhl8maqigyyv2kDsgXe5yNqLY25z B/GWxWEoMV/aJk627zEI5gjP9K7bD/lI0DrNLfdBXGpETTvtrJc+6fFbbD6N+mUJxN4K JpS0i/Tzp8T9zGa64ZjAKj0eSReMAuFYyrNsU7kRPpFOHoVea+2I/TNc1XovVrP/3zVW 7KUhSJU1+6ctoKAKbqvWUO9KmpGFBigu22bwUMvcJHY9DL3ROQYLOIGZFZ6cfDfWu7aG Dpow== X-Gm-Message-State: AGRZ1gLfcfp5xUWyEByEs+eC2NfStp6Ww8yW6Bp1lmHaMSF+xif7X3HH /T+mk3HKAJ0mO+ePQFsLhpM= X-Google-Smtp-Source: AJdET5dPbccSJIhU4ykGo/7sZ/6SWA6kO+vJeerN5LGWL5sFshLw+a7sE+sfVQzxYkAhfiqGWuVZ6Q== X-Received: by 2002:a2e:8099:: with SMTP id i25-v6mr3224659ljg.174.1542110253613; Tue, 13 Nov 2018 03:57:33 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id f18-v6sm3745263ljf.36.2018.11.13.03.57.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 03:57:33 -0800 (PST) Date: Tue, 13 Nov 2018 13:57:17 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com Subject: [PATCH v4 2/8] 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-20181113_065745_364349_7E06F9F6 X-CRM114-Status: GOOD ( 18.46 ) 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: linux-doc@vger.kernel.org, Michael Turquette , Daniel Kurtz , Sebastian Reichel , David Brown , Lee Jones , linux-clk@vger.kernel.org, Rob Herring , Jonathan Corbet , Andrey Smirnov , "Rafael J. Wysocki" , Russell King , Krzysztof Kozlowski , Chanwoo Choi , Andy Gross , Huang Shijie , Guenter Roeck , Bartlomiej Zolnierkiewicz , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Matti Vaittinen , linux-kernel@vger.kernel.org, Akshu Agrawal 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 Tue Nov 13 11:59:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10680395 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 6605913BF for ; Tue, 13 Nov 2018 11:59:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50A1129F3D for ; Tue, 13 Nov 2018 11:59:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 426CD29F91; Tue, 13 Nov 2018 11:59: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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 E7DA729F3D for ; Tue, 13 Nov 2018 11:59: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=ZTyGt0mvMjK1Vc WMoZO/YskH6CXtiyuBoYpjfVvS4rn+yi9JVs1RfI2zkzQe4YrehvS93qJ1kCaSicQ0cnvHUmNSf3I 8HzhLSuMLwWsIFvKPswPE3kxtGjIUAZUZNkrBeDapnbWUp92UuMsjdWhZmZ17Rw1fZ0qRUZaj2vCW 83t+OnXStOnqs3jjQR6wS61fjTcZnYnXVGzyeAKAYNOwACjh+Koch8OR6RBta8jiCXByMszwysB8A 3npoJCE7o0AoKREHv1wPvxSKJPtPbXfDN7rNuubzvteb5r0x0R9ZqB8N02QAb+xJKkVFtcoaR5Tgc FLPLetOzH7b9jNU6NdsQ==; 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 1gMXMH-0003rJ-MY; Tue, 13 Nov 2018 11:59:53 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXMF-0003rC-RV for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 11:59:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4fWmEQHDymzQumdk/aytbyrz8Sfb7MJtwS0fcAz0+8Q=; b=jCkfC6aW7VDxfxy/y8Qd0PIHX G7yRTcJIQbqMoSfqCzn3XfbMoBXWMy+OPb4IR9DDgt2HnTU5RZ8Wgp5K6K2tHpOWWEbEvq8WyC516 zZk23Ysdahu5JS3MZd8SmM1FJT17F7+9/S4t6XUpq7P4MIzB13uPriJihZHQsP/G4oKg6epNMj3id GADAEQlXPs603kVvtuKxBDYzBprXaYgGMKmi1OkVOHQVNQmf8F3CgOEUDIKpFcjZn/F06vYhDb5dQ ICJAv2+ewNPCS3hCexDrv98OC7LTv1+wuOCZdIgipz7sxn80BNnHBaGN1ORfAv0ryEydwmmLSySTi kdUIR5Nfw==; Received: from mail-lf1-f65.google.com ([209.85.167.65]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXMD-0001nc-4P for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 11:59:50 +0000 Received: by mail-lf1-f65.google.com with SMTP id p86so8611870lfg.5 for ; Tue, 13 Nov 2018 03:59: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=sEY212eHg6xA1HMaZMW7mZdThcXoShD13kUedykhB01lo8QAcwCI0cwgFzt3ZoI/pC MT7kufMcA7IXZJQV8vAOHaEAhHNdFVC/SPE6I5cbV9/fkehnlD8qnRJeMWtIjQ0snaWZ NxTOflfKDswD8/tGHLxRRwsWSY0v3zyA9qfxqAiqPsQUoRKYAeU1ubbKCdqMqMQHMh+3 YhubKMq3NzH8yg83YRTR7WW9QORuiIajUGl02ylJ+KIarY+8D3JBW9/du1T4FexuWkJ9 ehlJxYBBKOivzaNQW7l7e0NnZUPNHaabJGs1jO0SHTRc0ZCh/YGYLIiHWcuoXHaGoq0n 6ISA== X-Gm-Message-State: AGRZ1gJrng7FxI/a5dlqKR09dBJ/lAsH6UJqvXKe4koYBWhnov04HX/Q vXNhsBslvcMGBlqBLA96+uQ5iYQE8sA= X-Google-Smtp-Source: AJdET5eY5Y8Z+Wd+y8qQgdrwaMKb79bzHHDnnpRZ/qJOEzRVVyE3QH6UbsC9cFbqs3Ab3FvcXvg1Fg== X-Received: by 2002:a19:d5:: with SMTP id 204mr2618716lfa.116.1542110377098; Tue, 13 Nov 2018 03:59:37 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id g73-v6sm3518209lje.24.2018.11.13.03.59.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 03:59:36 -0800 (PST) Date: Tue, 13 Nov 2018 13:59:27 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com Subject: [PATCH v4 3/8] 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181113_115949_166432_383C3FDC X-CRM114-Status: GOOD ( 15.45 ) 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: linux-doc@vger.kernel.org, Michael Turquette , Daniel Kurtz , Sebastian Reichel , David Brown , Lee Jones , linux-clk@vger.kernel.org, Rob Herring , Jonathan Corbet , Andrey Smirnov , "Rafael J. Wysocki" , Russell King , Krzysztof Kozlowski , Chanwoo Choi , Andy Gross , Huang Shijie , Guenter Roeck , Bartlomiej Zolnierkiewicz , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Matti Vaittinen , linux-kernel@vger.kernel.org, Akshu Agrawal 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 Tue Nov 13 12:00:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10680401 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 149DE139B for ; Tue, 13 Nov 2018 12:00:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0043E29FB6 for ; Tue, 13 Nov 2018 12:00:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E840229FBF; Tue, 13 Nov 2018 12:00:49 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 93B5C29FB6 for ; Tue, 13 Nov 2018 12:00: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=/QpH8HecrNR1pLzLREtiGkpldbGFuuAbIQrkjJyF/58=; b=jHO2etxkjsbEFX CM769ihkcNKR2fwPUdKaHIGALYhNaW3P8+22svJ3oN1AHHnA4hf4X62HhEPLxddL9gy7zFY1eRU1d 6x6z0koHeGbEaCmG3Wa015Bv6p1qyz+x0VQToJ5a1/qMDwb1ErcyIqIH9z3gLoRP1zi3k2ZzdcrdN SUpB8B0vPc8nmYnaw0IHhiJ5ExvIGpanXrpGyqWObUB9ygEADBzRuzKtlLEZAWO/48QNS3u0VTZUy mAMGeZjr548iBOp5lnJvtjg2b1Dt3Q1Of0bVmdAeclEIcgD3s99CUuGa1ruXBYK7sGLtpRmdTCrfj DA/L2yMVCvExPbepvJOg==; 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 1gMXNB-0005UL-3O; Tue, 13 Nov 2018 12:00:49 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXN9-0005UD-Sn for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 12:00:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GkHc1XDfS2zAEG1O6tNrzFVGgOycf/0Y3wU3cQalzu0=; b=XLHiDjUF0ESs8/6c72XZvF9Ni f63dajySXuRlq2OeQUSawVHTQ7pJ1+DP84VywanRg9Lf8CP7Bfm5FQUOhdFub9iLA/3PO8df7DW0J BwzWgh4lbtFL+8ivTmOAhBkZG/Ja6pDzOv+0aQ4TucAzNDcZKH47frV3/Wcz+WnCpOqC8y1rw0NZm nANwBjqii9QdGXuubHjUEslzEsMPhslunsBTPUNWgf7BIk1ySx3zFqZdBsewzAGhp+sP9+jnd1Sbb I3ncUH789Hwr5DfP1q4SeU89soFu0VrwypdaqgEFyMNYhHfYLOUEGrtMe77X0m7Gi2/c5iu2UhYtY vAXJ+RzoQ==; Received: from mail-lf1-f67.google.com ([209.85.167.67]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXN7-0004Al-DT for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 12:00:46 +0000 Received: by mail-lf1-f67.google.com with SMTP id n18so8612136lfh.6 for ; Tue, 13 Nov 2018 04:00: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=GkHc1XDfS2zAEG1O6tNrzFVGgOycf/0Y3wU3cQalzu0=; b=ugiawY1NkVB1XTZcC1zVXUOS2dLatGtH4XxJM3f7rpyWjh3Epi/8sWl9guk6gzrVMX 7tG3JQBK10XM0NoxeVmQEq0FgK+hE5VV2wQfvXCrAfBXNkRK8OFk6WCKce8OnkOUbcTX 9T/BRF3p32IxPgkO4exCdNSLSxQqYn09IxIlYYeC6S8wHnQ2RRYHtuQq9uir+Rh1LQRh XwFUmDKyR5NSn+x1poVG0L97vgyOnoxz3WQOVRzCByAzbe3uJrYrNiHO2QAyUXWZOZs1 tpsOajLe24Ao7Y0pPIpVU5bk+zZyJZgUZ8FAmN5i2jim+Oj3nNGcN5fIeURX3Aam+wGO kkNQ== X-Gm-Message-State: AGRZ1gIrkfjwBtQAcc4xOZTkfaBLWm9wIMbI1/6Jg5Y0ahpR7im+JPPE iYlGHTosLLiHozl1W6PtwMc= X-Google-Smtp-Source: AJdET5fOIQiRXuBMYXnLuVnYwmroVFeBZiYR4GD6cOcs23DQeoIaoqxLi7kkCGtpTFX+3+gD23QBTQ== X-Received: by 2002:a19:24c6:: with SMTP id k189mr2921256lfk.77.1542110433382; Tue, 13 Nov 2018 04:00:33 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id p186sm3426622lfd.83.2018.11.13.04.00.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 04:00:32 -0800 (PST) Date: Tue, 13 Nov 2018 14:00:19 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com Subject: [PATCH v4 4/8] clk: clk-hi655x: Free of_provider at remove Message-ID: <4948a0a312c7b7b4149376d1b6eff26c99d29ccf.1542107769.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-20181113_070045_473186_14427AC6 X-CRM114-Status: GOOD ( 17.88 ) 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: linux-doc@vger.kernel.org, Michael Turquette , Daniel Kurtz , Sebastian Reichel , David Brown , Lee Jones , linux-clk@vger.kernel.org, Rob Herring , Jonathan Corbet , Andrey Smirnov , "Rafael J. Wysocki" , Russell King , Krzysztof Kozlowski , Chanwoo Choi , Andy Gross , Huang Shijie , Guenter Roeck , Bartlomiej Zolnierkiewicz , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Matti Vaittinen , linux-kernel@vger.kernel.org, Akshu Agrawal 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 Tue Nov 13 12:00: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: 10680407 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 CEA6C139B for ; Tue, 13 Nov 2018 12:01:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B832129FF2 for ; Tue, 13 Nov 2018 12:01:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A80A729FBF; Tue, 13 Nov 2018 12:01:25 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 5193229FBF for ; Tue, 13 Nov 2018 12:01:25 +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=CXOCb2NESYFtiM 3uB6ytP8Wd3pfSRkbsXVDGYZazaPlSdT+71f/zHcw+A3cl/FaCvBv3bCuOZC6rZ4Kt+kfSsOzIldO xEDNWlBZklCJTL18xQOevaP+x/UpWK4ZK071GkF3wQk7KAvqV4NpaeJ73mCoI7qDIiYnH+21I28oP rFD9Mmwg+a6n8QgIjbKpkMN2gZC9Ixh6K3NctiY0tmOGMtudfRoO47Hy42VcgHX1pNnFSuBWzN+8j h7mG19imeOC14BPKyW0z/j8qAgwihaKtDt9th082GUZz1bsIZtSsdUjmwXj5V7UGTYzJqlc5eKbG0 JNfPOv97fpKQ9Sr4soLg==; 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 1gMXNj-0005pr-9p; Tue, 13 Nov 2018 12:01:23 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXNh-0005pZ-LH for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 12:01:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4b7mWWvbRMSl/BrY6BXSv/3823MeAc6TDJ2DxbTG2QU=; b=2XMlLR2s8sP/SBIjQESf6c2tb fnanWpL6Iq5H5JzWdpKL+iH9H8Mfl4HOgnyLogJp2U1iRru6TIENgahABDf8IX2R05aQ3q8PNeqFE J0NTWKrBR2PePjDatGCHHcNBVDylolsfXl9IlZJRhP8sjhZ63jnaGC7DiEztKFY2EEgPrDk40kpPG neiWU22BeMefNvxkD+Jac4KGkD457nnltHCaR8be1ShKi3yRCyE9XZuYEmvdY0lTzwlUIWbylOL7u F6otyO9O8ZA6QUK+fD3n5Dj0dOjxA6gzKB12CSUWGVAmEYYYmT6m6JGCmTme+IVy8Aia9wro/DdfE hxsU+B3Cw==; Received: from mail-lj1-f194.google.com ([209.85.208.194]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXNa-0004C1-5Y for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 12:01:19 +0000 Received: by mail-lj1-f194.google.com with SMTP id u6-v6so10583378ljd.1 for ; Tue, 13 Nov 2018 04:01: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=4b7mWWvbRMSl/BrY6BXSv/3823MeAc6TDJ2DxbTG2QU=; b=PVKshiMHJsQynUNsh4RmUzCuJ616rqPiDHZiY4nOLkLAntoum6qSnhRutcYrXPN5F2 sCVFeAAf8H1i2Gp+vzZEXGhWk45vXDFdOYYHF0MGp3F2RXNAG/Mv0BXDQ1h7D3BvdhYe iUuX9P5AsmBccaobl6ROB/UhiVko1LHXp6yGnqkNtpDPKH5d/jmWS3OmNvs5rL1H7Ib/ gnyyHW5OVTGrqB8bzl0F1ka02KvnB8IaseP9Nw+ifQAnQxAUQeerGi/tHuVI1rAowI6U laXVJ9UZFQ2Y7QLmtBQGm/1gCyGpuJK/HQ4/n6pmQdvZUtr1ZKzivcBgyyy/Ir2Jga58 f8cQ== X-Gm-Message-State: AGRZ1gIQIRvRuS5vsB8IrTIKyLzCSjuHt79HnK/Qk1jrOi+FzqIwAuWm HJEkWYzD83O2fFkEkPlj9CA= X-Google-Smtp-Source: AJdET5ffbiuIZOU9/qFylZpeIpZWfVwNaAtJyzaMhL4O3x6I/l/Phk1LIDh0Gl929CUhQS1HCZMXLw== X-Received: by 2002:a2e:20f:: with SMTP id 15-v6mr3022060ljc.172.1542110462379; Tue, 13 Nov 2018 04:01:02 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id m77sm1777280lfg.3.2018.11.13.04.01.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 04:01:01 -0800 (PST) Date: Tue, 13 Nov 2018 14:00:53 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com Subject: [PATCH v4 5/8] 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-20181113_070114_251057_C1BC349F X-CRM114-Status: GOOD ( 17.32 ) 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: linux-doc@vger.kernel.org, Michael Turquette , Daniel Kurtz , Sebastian Reichel , David Brown , Lee Jones , linux-clk@vger.kernel.org, Rob Herring , Jonathan Corbet , Andrey Smirnov , "Rafael J. Wysocki" , Russell King , Krzysztof Kozlowski , Chanwoo Choi , Andy Gross , Huang Shijie , Guenter Roeck , Bartlomiej Zolnierkiewicz , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Matti Vaittinen , linux-kernel@vger.kernel.org, Akshu Agrawal 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 Tue Nov 13 12:01:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10680417 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 AFBE9139B for ; Tue, 13 Nov 2018 12:02:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ACED29FF2 for ; Tue, 13 Nov 2018 12:02:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CC3C2A00A; Tue, 13 Nov 2018 12:02: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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 2B4D629FF2 for ; Tue, 13 Nov 2018 12:02:12 +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=M3Mpdm7MLJWydf KENX5sYnLXUjh0WWuZHlcic9DXpV1DZpD87ib4avhPigbVEIywndvDscv9ZSn0v1WIxXZUnHC81Wx by8j87XWmLFjvuKMRgOV6nbENgmdt8UOBHRydSBWAQAvprDKwxV6dM7NmPfyIjrcuV9MCN6bi59jA 1DilyDbJsKC126egbwt14Vqe4lQ8ROl0ZP6xESiUP99DQl1Y/qWeuh8OobnNRKXWjYc6mGRmHgjg6 vo9wq0MFAKZudkbU7uwPaAEmqGtI0ht4qeIREt0zRwnbw5fHyjTf/B7k0CZa9StSsELmRUFeBTElT inOleVnyWCravxa1xjDA==; 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 1gMXOU-0006bZ-DG; Tue, 13 Nov 2018 12:02:10 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXOS-0006ZU-FY for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 12:02:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Eg2ufM9FdHFhTVDmxheR3tr+ip3I7Xl4uZ2RuWzUJVA=; b=CtbL4mJ7ii6QzwdXcHsenzMB6 QiLjZpFizkUPwniOyrS8GRCrWTMt1pXggENbfMU9veskN7Grm2OvwGc7KCzG60F1gPzoPoS9LHys9 GB1l3ZzkzZwvKRHo04sJqgeU/3ilxU1XEDwVMzG5eyzWqS/8IWt+19N4YUd/KG2U99VJIjp28x15d O+ETcz0vVAKAlhJyBpM51Pc/K79j+FOQqariWZt2uPOKXRrQZfx/fzdNXNzPPtQWRkTQpFS2hLEdf d2lIQeFJTVt2FR63XhHXc1nHuAE4If7CdttNux10h/xyTBLLPYTiAAOls5A46nj6lneKZNhrP92eG LE9RxrqIA==; Received: from mail-lj1-f194.google.com ([209.85.208.194]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXOL-0004Dx-Aq for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 12:02:06 +0000 Received: by mail-lj1-f194.google.com with SMTP id t9-v6so10572007ljh.6 for ; Tue, 13 Nov 2018 04:01:51 -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=ixv5BbQU5P2rD1eNein+us2AIC2/XP6LFSG1Zs4+h4HDdN6BV5Wz4VxgIqh8XHI8/X fZdWirl7sF4oCpKAHnutTQi86n+allV8EUuJXBj/pPVJX0bPo9yQQHO9pG+aY99tzC/9 xgkLFex5BKmlLTEkqhnqkg9QyhaQ86KMKXrdJby63WvnqY3UPzZG0hJM7HCLv3LmRNgX LFNNto/E5X7kc/m6ilD6ol6wmKqiwXZVQcssQpPl2zEDXFaigiCl4rzS5dAqvVKGOXiR vs/gPfJFyQn1pA1k3169dcb+C5P2yqMXQTyjlmn/R2Pv66qlIFqo7wJuNFxKMX0x2vXn /Ezw== X-Gm-Message-State: AGRZ1gKrjN8QK7LvN+XgnTI6AHGUjsiszEeVdY1BtiStZ4+mYVTBdR0G cUuewBdiJwNZhbp0CD6WwE4= X-Google-Smtp-Source: AJdET5eiZpJm78DDRAbNNrgPNoDh/5Ee9eTpHn/cx6mX1G4R3MmmTqs07oz3ukMBdLA0oRfOmCYlCA== X-Received: by 2002:a2e:4819:: with SMTP id v25-v6mr3261176lja.2.1542110509761; Tue, 13 Nov 2018 04:01:49 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id x24-v6sm3844320ljc.54.2018.11.13.04.01.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 04:01:49 -0800 (PST) Date: Tue, 13 Nov 2018 14:01:36 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com Subject: [PATCH v4 6/8] 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-20181113_070201_422615_29E0D326 X-CRM114-Status: GOOD ( 15.93 ) 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: linux-doc@vger.kernel.org, Michael Turquette , Daniel Kurtz , Sebastian Reichel , David Brown , Lee Jones , linux-clk@vger.kernel.org, Rob Herring , Jonathan Corbet , Andrey Smirnov , "Rafael J. Wysocki" , Russell King , Krzysztof Kozlowski , Chanwoo Choi , Andy Gross , Huang Shijie , Guenter Roeck , Bartlomiej Zolnierkiewicz , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Matti Vaittinen , linux-kernel@vger.kernel.org, Akshu Agrawal 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 Tue Nov 13 12:02:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10680423 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 194D0139B for ; Tue, 13 Nov 2018 12:02:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05EA52A00A for ; Tue, 13 Nov 2018 12:02:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC7C62A34B; Tue, 13 Nov 2018 12:02:40 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 CBEA32A00A for ; Tue, 13 Nov 2018 12:02:39 +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=X3LXaOlj7WtMTv 4Gkk9bkQcp6ihPRYmJ0w2NIy2R5lHt2c7iwTwRw4EqiZPJMkMr289054GJReuqL0rlyi0wK8AZdwE jl7ZRl8qAJu7lrUBvEicgTYFh8Bx6cC6p6Lm3qVinMoxQtVbSTCdaysqp+Yy6nZ1Oynj5YoKHJAV2 nDa4AYgagFRGzz4rmTj0CTPAfglnFX+2iDnahxWn+rFkwmTF2c43CbDMu4nsTcB2r/oeXyRf6y+Y+ +0tbQ9nhC7mFScW+Fcs6590pSpuhVoNf6jXknOEHgBTapXp2hRHyh6Lynr80JivbAKjMTaKB7HH6O Ndvbfhz+/QQ3gn8XkfBQ==; 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 1gMXOw-0006tk-7q; Tue, 13 Nov 2018 12:02:38 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXOu-0006tK-O6 for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 12:02:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=abc15EH5GKVAESf+iqe1waxzU2AmezuL+i/+AhHeQPw=; b=nHZ9RSmZOB/TB4bVD+JFX1naK gOudyoBEEOdbMAP0Psy54BR7SYLYFZKYyo9oX6wdbXsYIvF9nBAMFcquXibPVFwpTzypPOvzsE+7b hM/H88B9ieDX8LLJr8Ot7L4yexuzX3p8LaAAy1+8YtBA5dRrAhYay/JYJVC0FuVL3HrpRLNmJJueg +JlvamlOFcLXhvdvp2SfyeKi5zz6RDkJXzZT4XZTwvTYCwI2YR90vOK8DaXzGtoeBaSHnPrRcqQW1 4yQMX66uWI6Lga/hfzpI8qgP/tLY1mYSBxuRlXw4JJ7e0Njl/oYv+f9WmWGfw3W2GLT4L4v/FGUth WJpnx1EUQ==; Received: from mail-lf1-f66.google.com ([209.85.167.66]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXOr-0001yJ-TZ for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 12:02:35 +0000 Received: by mail-lf1-f66.google.com with SMTP id e26so6826670lfc.2 for ; Tue, 13 Nov 2018 04:02:23 -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=D5F44jbz3yujAZfk9hPla918oGW9L8x0G5C5j2AkKG5wUTJJAy1HzhumMKpA8Hyxr1 VVbWmzq7vGh0YbAOp5vM6YKvtIWmMC0Z2GnXRQF8M/p1AugAwNes5tMmR1NsQyS6NG7p qJrH+uo2i6OHp4QH56NlSnzFSGmbAPVcCb25ZjMp1RwBGXsyRHwxb6YriuFJSaKstNAn Z/2nrsjLdvmiuFYCFJy7il0rQp1toWC9lbqNtXx/PB4t43MqciNNEryttrvWQrhoZ+Wv 04qqSeePBDkqUsxmNuPWNzaHdLOkoW8aGJGQosjHN8koKZr2HpGJIiHjoyzoi2eFYAdB uxGg== X-Gm-Message-State: AGRZ1gJGHW/L5Ip69UyhAe8gVWIIgnwxFqs/aWmEU5bP3g84EGwu1bEP DXbSfseCt1X9rcmM5qSvstE= X-Google-Smtp-Source: AJdET5deTnRKacmN4Mj4CjKvCjxsnI+cbuAlUfIHA0kFbAMfopiwxDr6P3HwSYiDw+gDMZivP9++lQ== X-Received: by 2002:a19:4ed9:: with SMTP id u86mr2672645lfk.78.1542110542832; Tue, 13 Nov 2018 04:02:22 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id s20sm3256161lfb.51.2018.11.13.04.02.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 04:02:22 -0800 (PST) Date: Tue, 13 Nov 2018 14:02:14 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com Subject: [PATCH v4 7/8] clk: apcs-msm8916: simplify probe cleanup by using devm Message-ID: <1acfe5a48b9277c863f2d5d0ba8015167632be70.1542107769.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-20181113_120233_951537_F4FF754E X-CRM114-Status: GOOD ( 16.18 ) 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: linux-doc@vger.kernel.org, Michael Turquette , Daniel Kurtz , Sebastian Reichel , David Brown , Lee Jones , linux-clk@vger.kernel.org, Rob Herring , Jonathan Corbet , Andrey Smirnov , "Rafael J. Wysocki" , Russell King , Krzysztof Kozlowski , Chanwoo Choi , Andy Gross , Huang Shijie , Guenter Roeck , Bartlomiej Zolnierkiewicz , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Matti Vaittinen , linux-kernel@vger.kernel.org, Akshu Agrawal 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 Tue Nov 13 12:03:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10680429 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 678BD14DB for ; Tue, 13 Nov 2018 12:04:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51DF02A4F3 for ; Tue, 13 Nov 2018 12:04:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 438E02A506; Tue, 13 Nov 2018 12:04:32 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 15F602A4F3 for ; Tue, 13 Nov 2018 12:04:31 +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=/wPZzqaKJf9/l9NOHAwp8LX+n6aE/WCNVG0DEbzQY6w=; b=VTx1xLqw7xXSd3 bg3ndF3oZ9K961dFPYyCjSIQGDWiOAgCQzW+b1JXk0WP+xT6SXgM1GP7sZzZ8TzQ98tyUXd+LRmgZ /8BW5/IAucsB+tSBJ5wLDey63MvmugxXlx/VLgyCUG0JH03G2g07j6SlWu3+yLQvODIAurdpnNok/ bkhQhitt7b8QKxlEsnBeyNZpAh64dUjJmPCSOwcgaA5efFpGMaTN4Cv0eFbYEYdJQkE4P32TaNLxs np0crg41tdElnVLWjs49XgY+Buzmi9kUTvTGq0r3PrTGD9K2TUaXLbY1ZrWg+nQZHPWvOqANu/Yyf 3AqGK7XL1PeazRfgGhAw==; 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 1gMXQj-0007M5-7P; Tue, 13 Nov 2018 12:04:29 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXQg-0007IM-Sc for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 12:04:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RImRPMxGiDv5vU62yzigGgRR9BAH/S5Qm/3HbD/fkag=; b=tpQ/O7chZpCEOju4U0zm6pacW IRhiPn0DnbrXz3QxTZHATJLFK7RhqrjH9DJrMAexfojOU0EVSPvcW+oIatEWHrQ8JaGv/4vFKMX4o MR2WErEfrhsWlIk4weyJhPhuce219rPX1H3kzczfBSapurteXJ910TxDJCNXeTIhDVwRZTK+jijiD ABW9khTvSCN+vjUrhjP1KYCcVeyNu/qP0osUVSy/iz33YJzWXG+PPE9RNxYuYTGBzgh/y79o5HHMI Se/NqTaDEBYRyylFd/o2qCA6vrb4jWIo7nEqwEFvtnl2igJ16aagkNbfT0ZlaGVDlrFWwNuHNTY84 9ADKsvUpQ==; Received: from mail-lj1-f195.google.com ([209.85.208.195]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXQZ-0004HT-GR for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 12:04:25 +0000 Received: by mail-lj1-f195.google.com with SMTP id l15-v6so2370045lja.9 for ; Tue, 13 Nov 2018 04:04: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=RImRPMxGiDv5vU62yzigGgRR9BAH/S5Qm/3HbD/fkag=; b=ajCwm7SsFdcDTTOxw2DKHtKKiIZuzMycbWxfL9dNC2xEoYM0NNFq2kvieWj/i3e2/+ pzK31o2GsNmDjEWB0JlFtbmM32+j+v+jgsrU8YEJmdZmx6GSD8trPB02cmjfs2iamAK8 EuCKIjsFGyPg2NdF8E/aDFRq6GJ40fClYVygH8teVx3f44NvrUDYj/fhQzPIf1ADiAcv wGnJHL4b3M+cvJbthncls2StI+rY0DRSHWwpYfOjNKuPSqzk4i2cCW1aP3mx5/J7I4Je RdSUy2V37JhAKJinOaMccDVky+l79MHz328jFoEboswDl7REWLWx8BKLnsWMzWghvoH0 iFeQ== X-Gm-Message-State: AGRZ1gIX34ZTpWQLQV4HxRO43/aMb/FL1Jof3DFZ4ps32h5F7+yPntxU K0UlBxPL/1GJhJqTd5Pb0Pc= X-Google-Smtp-Source: AJdET5cC4i998KEUcHfE5HnUebd1JCTKHlAAnG4fmkJTYn2CM265UAt9GiNuJpMeB5durbm4RvfLUg== X-Received: by 2002:a2e:2c02:: with SMTP id s2-v6mr3029104ljs.118.1542110647607; Tue, 13 Nov 2018 04:04:07 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id h3sm1737611lfj.25.2018.11.13.04.04.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 04:04:05 -0800 (PST) Date: Tue, 13 Nov 2018 14:03:51 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com Subject: [PATCH v4 8/8] clk: bd718x7: Initial support for ROHM bd71837/bd71847 PMIC clock Message-ID: <0b9b9c9555706c512f21e6105e3e2b67e0a0172f.1542107769.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-20181113_070419_582289_44DC2BA0 X-CRM114-Status: GOOD ( 26.55 ) 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: linux-doc@vger.kernel.org, Michael Turquette , Daniel Kurtz , Sebastian Reichel , David Brown , Lee Jones , linux-clk@vger.kernel.org, Rob Herring , Jonathan Corbet , Andrey Smirnov , "Rafael J. Wysocki" , Russell King , Krzysztof Kozlowski , Chanwoo Choi , Andy Gross , Huang Shijie , Guenter Roeck , Bartlomiej Zolnierkiewicz , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Matti Vaittinen , linux-kernel@vger.kernel.org, Akshu Agrawal 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. 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");