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: 10711565 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 42C42109C for ; Tue, 4 Dec 2018 11:33:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29C8228D4F for ; Tue, 4 Dec 2018 11:33:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C35428F54; Tue, 4 Dec 2018 11:33:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A094128D4F for ; Tue, 4 Dec 2018 11:33:38 +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=Z0ARYMw+oLBLc9oVtIgRAuLbpkjn1V528aeVQA3kCfc=; b=fIab8R2tSzrEy7 Ji223xiJaBNSVMC2iEsfEY/hCww5HRBkao2Hmefu0T0d1uu71i43iE1WqBmW+vxj+c7jnU97cSF39 UH0cON4wXt+3FjEM4pF+VfRfCkNI0Pu+D/0zXkf8ln/SEl1scTIjUOr8yYMExRA3+GilaqPRHLC9e jp8Pg4yP/FXYN8v2VdFwLvr2NPGTqltgKyP7MS0HLus9DOvAcaMUMNZl/t/O6wrMgygrEkGSQUvll ylVgeHdljeKFhYjfbneCugCZ2NV7L64J9DzN+zff39CM/jU+PQ6T2jgl7VP5AfEyRaq80lF8+eLYn h9c6jxzM2JQubx+Mk26A==; 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 1gU8xG-00083U-BM; Tue, 04 Dec 2018 11:33:30 +0000 Received: from mail-lj1-f196.google.com ([209.85.208.196]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU8xC-0007vo-SL for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:33:28 +0000 Received: by mail-lj1-f196.google.com with SMTP id l15-v6so14563575lja.9 for ; 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=CSOZhx6vA+V/EVgJgTs4FwMz/MO4UDigeqKKKiuW0a7CFMY0c8cbH5y3BSCFOL0dZX 97APKipCI4OKRAgpTmAvVBZoeKF0aeyKC3gJO/WhbOnUTqUh4WN21cyXc8beopBiMFGH 4eM39JFe7foiXu+YuFVKZAhoqyKMFZM6w+HZQzz6ng2eznZp/xiH+PUTJoGoUgES56dv 0ER670TKehA6iaLjm3YOtwgXvk09tkD4839qm6YXv75g5MxVVqSXdxaXNsfjwOfKxpHU XklClt0p8fE3Pie27kvJlXMqctzErG0nbamHDOUnr44wccFIdALQWc/WzeQ4Kdf+V7uz 2LXw== X-Gm-Message-State: AA+aEWYWgSPlGF74YNJXOF90hTqVnaNoacq0Uj47//1MOwtbFxjI9Kv2 mM8M8qxbWglVANfKVV1xGPU= 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_033326_965828_E9B65808 X-CRM114-Status: GOOD ( 18.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: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Clkdev registration lacks of managed registration functions and it seems few drivers do not drop clkdev lookups at exit. Add devm_clk_hw_register_clkdev and devm_clk_release_clkdev to ease lookup releasing at exit. Signed-off-by: Matti Vaittinen --- Documentation/driver-model/devres.txt | 1 + drivers/clk/clkdev.c | 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: 10711569 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 734F4109C for ; Tue, 4 Dec 2018 11:34:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61B902B753 for ; Tue, 4 Dec 2018 11:34:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 555422B774; Tue, 4 Dec 2018 11:34: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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 048E32B753 for ; Tue, 4 Dec 2018 11:34: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=7M9GztSHik7x7Fbsg/CiZA8A83lRM9Cr6vAFnZXtaOs=; b=slY6oRgGSlTEWF wHLmoJYrlNt7v8V7IGblSiQQjhMXQqncOZqA5wFw0B8P7szLqKB2I0/HdUh0bVQqMfQN8nn3B1b0Q UA0IspbTN8P8QSHNVhNFAHELqY6AsCg0Pw/6hVhAmCE99RR+HKWTamprVk2f1HCwpcSLNwp/s4v/W y/ZP09UF8E0Iurn2gdKL/tl4DMJSU3SG6ydYZxQQG6AaNwUW/qiX6fT7zos7L86apJpSUeAApPUoW UGpc8jB5xUIkTBP8+35I5O8q3qCy8S3kD/O5JF2L6nsXRKue13VZpTACw8/zm5CnTyIjHxQdX0Z+l T9EMDSEtqYNiOvuPF4ZA==; 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 1gU8y1-0008Qh-86; Tue, 04 Dec 2018 11:34:17 +0000 Received: from mail-lj1-f196.google.com ([209.85.208.196]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU8xy-0008Pg-5q for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:34:15 +0000 Received: by mail-lj1-f196.google.com with SMTP id v1-v6so14585078ljd.0 for ; Tue, 04 Dec 2018 03:34:04 -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=lX9DTqI0lFwRJjTYm4D82p9qDRjeJNGuGRdmJT6ChNu4haNce06vZ5mlsIb1RvbEMW iOQi+WD11UyL+QEsZfC2QIHx+DXwk/hrNVzkWHJgB7qjhIzznUyilPzxsStiNeIzyR/e yVUhbplJrqZv67GkuLI6yY75V4VYE4B/7t6PGO9kFPQ+XTJfdG2ag54dpP9isZ6wvlPk KE40auFEysyXOD7hnBnesAusWb9k304lY/EYKxeZgoJEOgmPPVuofztflORHg90nCZTM EnixBzvyk81pj/xCGDmMAt00yZjXrvDYFGF7Rk4Uo31GICdT4o8drf3ufhuLk9x8hXx9 c14g== X-Gm-Message-State: AA+aEWZ/ujqVPIrHvrJAuJKCnQo+Q1z2TYxNJLWABONxdVx3PF606GKN EOJpXE8xvjzjCtRci5RAMVs= 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_033414_213115_0D0780A7 X-CRM114-Status: GOOD ( 12.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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: 10711573 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 3502D14E2 for ; Tue, 4 Dec 2018 11:35:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 237302A4CD for ; Tue, 4 Dec 2018 11:35:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16ED22B72C; Tue, 4 Dec 2018 11:35:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 15E9A2A4CD for ; Tue, 4 Dec 2018 11:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xTu7PW5xa6y/JvFSEAwe9011BgmRGAY2Rj0J+E5/yIs=; b=VielMhzWEHlTgt bj14p3/CclR7LoE7hh6lKFz9IYZFeMEqoU4zN4S2MdVQjBfMeosNr3PLNPSLtaVDuGPz9G5mXvwzh 9haQNmvn9CaZk8J98U1XHl5HW5EOsPojNuo4vaFoIkSN1UPAY7dukSAr0BB1h1QfCdLgWrhh4ZLF4 zkHNvi4lDKKkPc2DqsLKDdZY+3Oh2eb1amnQkJlkhwJKqHa1m51DyviRJ+Itm0ocdqH1aJ37pneD6 iZNcYdyczBjVS6TiGuuBECtvn5ZJZx13+1GrXLpv+oPAA7B0Yju1cSeEe3/vR6sJO9IWagIfBTI0Y A47mSD2lpz2nkS+xv97w==; 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 1gU8z7-0001YR-4L; Tue, 04 Dec 2018 11:35:25 +0000 Received: from mail-lf1-f66.google.com ([209.85.167.66]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU8z0-00019A-Ci for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:35:23 +0000 Received: by mail-lf1-f66.google.com with SMTP id a16so11693058lfg.3 for ; Tue, 04 Dec 2018 03:35: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=0RckClGYQ+6fUhKznGresT7KY8caowujFh1vtX39WAg=; b=Y8I0KELimJPmFTKYRqc2Wl2KjOj0fx83BV/07MDbGifDtqkGen+D/YmAJvQOWsdySp La6eSDMvY2ysJmEe3gmo3uFbJ6uULjuPOsCOTMcei2lZyfL/AYNCaSD4Y0QyDcpn6rkc /JJXtxBv6hP0yfFbd6BlNLufZBLbnriC60rAGakpP5yFLajzMl7eoeIvkuYs6cvpScC/ 3FmLYjPMBMo94bxEgrhERR8sV5jZpl1FxkRoahR6FmofJwvZCnvIeDHJPhqYjSBpuyNt AGUKESQZiCGbno7QiW4mxC+xVjdAjBYS4bgWOLXMvpGYyvIjxuxUQWRY01hV0+e2d/mv dFmA== X-Gm-Message-State: AA+aEWbkJvqVFjObBTlFow2Ofa/L29bZV80rs78aAR7/SfDYBDaBZ6OG DFDixwBmyWfUML2k87RF1GA= 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_033518_431433_5F499891 X-CRM114-Status: GOOD ( 18.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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: 10711577 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 42810109C for ; Tue, 4 Dec 2018 11:36:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C8B92A4CD for ; Tue, 4 Dec 2018 11:36:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E2112B72C; Tue, 4 Dec 2018 11:36:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C9DA82A4CD for ; Tue, 4 Dec 2018 11:36:32 +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=zvLZ4C+IMVDDUKQ/zl/LZzgyKQq/7/4hTB6Az7djFus=; b=KibGbMrBlVsD2t jWaiRD/8ZC05u8+a/QHfAsgd02d0SVc2Z1oQ857SMhks/77x0P1uN/J8wPFzW+yTGyJRV5TLkP+xw kX8TGxL2bLeg4B6LcSCMj6u5tBpal5XSFqeU9KP8u0Qz9MB3OMMMrqxRDG/DhxAKeWpf9EwkC0bqs WeMTyIVLhafIRUI/jINPYFauB7tZMTcK3nKJXDcyYkpeI2dDc4wubTH+fzDjTsJWe+EzdvzZHq6hy qfxB6F/k+9bPNjSTOjNnplrfHKqnLavN72PNIzCQoTpt8uck5474mvls2bM/A4qXDdFYPvv/18wqN 5hlFG8Q+3Sv7Ic9uXi6w==; 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 1gU903-0001tK-3n; Tue, 04 Dec 2018 11:36:23 +0000 Received: from mail-lf1-f65.google.com ([209.85.167.65]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU8zz-0001s6-Ce for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:36:21 +0000 Received: by mail-lf1-f65.google.com with SMTP id a16so11695169lfg.3 for ; Tue, 04 Dec 2018 03:36:09 -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=Nw7MWraioXrvFaJ9i0tHAzQID8aqJQC3exGyg5tNHzZXywJE85eLhN2G8E3oQWpjJR 6F3h7Ywj11dLarBY2J6tSji090UcxbifPeshA1ipZbXTp5j6w8MPM+bBcX/+Ihu8TGiC +Wni4m5M9Rz54ewmRB+4n/IzHXMyr/sYP74HNDk3BHPhxycv9F0CP32hucvkp/EnPEfD nqceFI9GQCYCV0U5jtUT5QCVXsIzWTPaazZKpwNc2lMPHNl6FQK9QMaUoJddnBVg7j7s L6mOWxBFLWzihOD8309w+7hld8RjKptSWv4oyUGh5Mwf3RhahxxAbLgN5iM0gbk+4x4l 26eg== X-Gm-Message-State: AA+aEWaibVjiBLPQEjS1ozHQhc1922/r7AnI5cHpV+aYFT53FOXgoIo2 joSolgKfwazDIv3cHmWGcMY= 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_033619_433430_2C7E842A X-CRM114-Status: GOOD ( 15.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP clk-max77686 never clean clkdev lookup at remove. This can cause oops if clk-max77686 is removed and inserted again. Fix leak by using new devm clkdev lookup registration. Simplify also error path by using new devm_of_clk_add_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: 10711581 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 5D4C1109C for ; Tue, 4 Dec 2018 11:37:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B3172A4CD for ; Tue, 4 Dec 2018 11:37:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E64B2B734; Tue, 4 Dec 2018 11:37: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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B79AA2A4CD for ; Tue, 4 Dec 2018 11:37: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=Bj85HQydJjcE2NdNkr71FsMX1jdknW/AWvhC2H1lUUA=; b=UKUuFlHdRMVG1Q zWG2Zw8jHbkuD46wBHpOPfYCmOwjGIqbaYwEqf6amvWd5+2LEZLpynVF6wZiZ3vPVfk5N1sy7oFd8 mrDwpu2MG7YLRYvv9M3k5c1ZrcgQ7epSgjLr/l6wvKa4VVsAIu1zOSIbv/hSYVX3xlwAty6J2pAZ7 8sF+WuQ5uWO49o3/Lyy1Ai2CIsrh7lgxd78V6qdMNV5/04OXVlsEj3SeDt4fJuMlAx2+ZHruRZIZ0 ewryTpSiHpH/1BMwt6wvaRuaXJWOqfbL9QPV/fs45tMo1cl2QlBYb+O76Y1cLdgC5gUeG4FeQIeK0 NCpDXlZSNFwU7RiLcvWw==; 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 1gU912-0002VB-09; Tue, 04 Dec 2018 11:37:24 +0000 Received: from mail-lf1-f68.google.com ([209.85.167.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU90y-0002U4-Sn for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:37:22 +0000 Received: by mail-lf1-f68.google.com with SMTP id i26so11705738lfc.0 for ; 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=He630TzMXpyQD3+hUzpGkY9SWvlwHNU49oq75UwbKBGq6IkzdjA1oKY5kE409+9dRF C9PrFMT+oWIjPxsNV67hO6sLTF3B9/fwq3qQ+oFEEq6oF7GxxFHr1Ze0eIHq08V0yJQk pAaNfr8u320WtZv8zBlvSyAxU00VNX7cib141UIjUibhF1L/KXX5BurbecXBHOaVkuLT 8lw6VQU5D4/Smdd0gDUkPOOoH+GkmJmpCSn53ySwaGOmfwX7Acsays2slTxOyvh1X1Po 4tCUiL4VZh8my0eNLu1+fmPgOamPIKodf6wnPRB6FkfZehN+rOcUX/pYMnwlcsJSM6FW BqrQ== X-Gm-Message-State: AA+aEWbTJ44l7XJQzMIc6K02d0Lpa85yYFTb8wwRPYztiiTAqcGE9Vo3 LpkD00YF8h2k2gqlC1d/jOE= 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_033720_953737_7235F8AE X-CRM114-Status: GOOD ( 13.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm based clkdev lookup registration to avoid leaking lookup structures. Signed-off-by: Matti Vaittinen --- drivers/clk/x86/clk-st.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clk/x86/clk-st.c b/drivers/clk/x86/clk-st.c index 3a0996f2d556..25d4b97aff9b 100644 --- a/drivers/clk/x86/clk-st.c +++ b/drivers/clk/x86/clk-st.c @@ -52,7 +52,8 @@ static int st_clk_probe(struct platform_device *pdev) 0, st_data->base + MISCCLKCNTL1, OSCCLKENB, CLK_GATE_SET_TO_DISABLE, NULL); - clk_hw_register_clkdev(hws[ST_CLK_GATE], "oscout1", NULL); + devm_clk_hw_register_clkdev(&pdev->dev, hws[ST_CLK_GATE], "oscout1", + NULL); return 0; } From patchwork 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: 10711585 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 020AD14E2 for ; Tue, 4 Dec 2018 11:38:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4C682B72C for ; Tue, 4 Dec 2018 11:38:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7CFD2B763; Tue, 4 Dec 2018 11:38:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8D6762B72C for ; Tue, 4 Dec 2018 11:38:03 +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=9dZ5jyX6cNArBHYQq6Pd5LZjNOiqbOZVibpaqjLTz7s=; b=Tu4XaZolzK9rkk s9WTZrOqIHpCJIU5pRw+wVi21hlWMSGIzOwrekVKKmKwoKEqkUYoOh8qmyU9GuDdFDBAeMaFiPKng yc1CElpaHqvHNp/ynf0HZXu1NwkoXA5oRvy+9T5c6Elo+g5SFPrXxkTkLUfCYo2liHbty+JgnE1+w yPzMoHPam/HavuZCOpOt2xKoF8ahlX0K3Fo9gdfuWhrFfwmF5K9wV9Ve89nH3xhTdDU756orA0DuU BWDFGfp0/dVwpFNRCLSPxoZaJQjZx5koW+wJLxJSdciSrp0gth5vkh4zsZ+hHXfPOnMIzOZ9AMZeU GS9UexuA3gIa6m0Y+SYw==; 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 1gU91Y-0002mt-Qh; Tue, 04 Dec 2018 11:37:56 +0000 Received: from mail-lf1-f68.google.com ([209.85.167.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU91W-0002lL-1C for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:37:55 +0000 Received: by mail-lf1-f68.google.com with SMTP id p86so11688516lfg.5 for ; 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=BmR9QGS6lKKmLRR/99GR3eWN4Lg3X2E05YVKWEp/Vn6RwcsiSe+hQMX5joY0Bct9d6 tD/q5AcBSBgywkqNOBvon30YlEzIh673w8uwObnuHXFmrHYWtSQVkMimRFIZfjG7pY4p tYVnUrWmZOUgxd/KqT67+Zlp3j/Fby6Mo0QVuSjvEXV51Bz7wqr3Uvksm0fYR/oFwmBa Hg0gBIfcrPNT7XgVqRZ6ODDvsOmSiLU8sbrhiZz7e4M4vMxVrfKJgeov9ripz9t+SGNq k+Nd6+AR9LltSVHEXpGpCRUJvKSefOAaFtVG+qkpVjko7b2oZ/qEBCnysom1o458g/iA md1g== X-Gm-Message-State: AA+aEWZgPQ+qUlH7NP1zsGQo1Aj6jGTrHYIV60jW+A/fLnJI5o1n/Cy9 LrEY2OtIFTEu/LoM6FNJQLE= 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_033754_071402_52AD943C X-CRM114-Status: GOOD ( 13.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP use devm variant for of_provider registration so provider is freed at exit. Signed-off-by: Matti Vaittinen --- drivers/clk/clk-hi655x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk-hi655x.c b/drivers/clk/clk-hi655x.c index 403a0188634a..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: 10711589 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 F22DD14BD for ; Tue, 4 Dec 2018 11:38:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0E6B2B72C for ; Tue, 4 Dec 2018 11:38:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D42D52B763; Tue, 4 Dec 2018 11:38: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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 873B42B72C for ; Tue, 4 Dec 2018 11:38:34 +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=S4z0qVCEppAPNm9Km2GpWN4oi37aen+nIdRjdjTMTx4=; b=ApQN8M+HvlmJGt kPNLHQ/maHZxAeK3qTGteokoh+fjrpKg7n3qX8WpdfwdOjhv8EXGZgNj85mLvdMz1ICWy+o5fmCew czxWa28VvjF+6Qa/9vYBpbtPyTUB5bUoEpvk3iCXmhrMpttTUIt0PJhNrT+ELMm0FdofLf39TWsjZ GFS+8od0BrnqPVFomgWUVkfBPv8fbjGa86R+EmwHsk4xDJkn84191/eAYDiJho9kBg160CWPiRPaH 0+SqfHPJ4HZPvifX/5WIzdJUxEfmAFkd2LJk+X0+7d6fLi/mjXrGAb1ifCLRxPVqJdaSzyH4RKyBh QtchdTjVsZwNaUNZoV1Q==; 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 1gU929-00039P-RO; Tue, 04 Dec 2018 11:38:33 +0000 Received: from mail-lj1-f193.google.com ([209.85.208.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU923-00035v-LI for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:38:31 +0000 Received: by mail-lj1-f193.google.com with SMTP id e5-v6so14603427lja.4 for ; Tue, 04 Dec 2018 03:38:17 -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=NohyG44iqVPxcVAxuUhrTvIx3kGX+sHfSH7m0DJuuhkG3IvHccH/kDc+YJXma4LNBV QRq64ZfNNCRKT1CHeGcCf2Pk0ETseHV814KJOFvbL1vO0feZPFaXxWKpF7+XZPeWV76Y Zs7jyx0r7Z7o4lNgL1L2KLmSUBAOg2yYvv44S62BGEj5egy5GYeWeMpEmPrYUO1UQUIB PrvFA7pwlUVYXrDXH7vwqyeaWSwBvck8UpzsaPMbhVQz+JJrrTUbgd+jtdQOLyYGftOj JfIv5d9ZXdw/w28Bso91JFIMt8DY78yS5nLs2h42Kt/Cpm+ZajikW/ONhq3oh3flSRaF EXRQ== X-Gm-Message-State: AA+aEWbsqUECAQHFfrhpzDfMfyyLVZPSDRFlYo4FTt+BR8KmfltxHDjK D00+JJuWttLR0G6ZVGNIbu7Cw1t++YY= 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_033827_805913_40E2639E X-CRM114-Status: GOOD ( 13.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Simplify clean-up for rk808 by using managed version of of_provider registration. Signed-off-by: Matti Vaittinen --- drivers/clk/clk-rk808.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/clk/clk-rk808.c b/drivers/clk/clk-rk808.c index 6461f2820a5b..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: 10711593 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 A574014BD for ; Tue, 4 Dec 2018 11:39:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92F672A77F for ; Tue, 4 Dec 2018 11:39:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 870C22A7A8; Tue, 4 Dec 2018 11:39:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3C5452A77F for ; Tue, 4 Dec 2018 11:39:08 +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=F9BqDwba0lDLVcrlVz2hZCyuF6TNE3jBMD4ubrjkZ/E=; b=eb5paXArm6dvHa 0uVIlAeeHgEgCay1ydiSnuRdkZ9LED5D26eRyTJaGSC9YFxjMMFiK54Tgz/YoxEIuIj58vU8KsD7M OhDlGzF7LqDRpHv9Ph/ktruizSOcPuUM94dIVhKiUucPTTUyV4kTMDbAJ81dlPMAy11PvCwqwTDW7 Y8LA9f3UNIF43H4RN56LXmptsdMXWfuLNazdpyuhgyrYZcWQ1ZP5cWx1f2Jw7cyIf8eT2obm00Ucx aK3kSXoQb1TRitxB2TpBarz+AgH2t5Ir8TMmoiOJVdidT3X87NMX9gZ495Fanxb0C9OolpJcKe1T1 MtwUNEtL1wLhb5cAC2EA==; 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 1gU92b-0003Q8-RG; Tue, 04 Dec 2018 11:39:01 +0000 Received: from mail-lf1-f66.google.com ([209.85.167.66]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU92Y-0003Mx-0d for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:38:59 +0000 Received: by mail-lf1-f66.google.com with SMTP id e26so11709306lfc.2 for ; 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=jhcSlf7EzBtY+r1zarDIwB5xE4gyhE7mA/sOrhaWhMJyoLX7jVOvR8wJke8exnuts6 UEj73JI7y2sgYsnEaRgtKmwrUlGZt15q2IPoPt/RASdvuS+skMVd1xR3LU37XcV19kTj 3oigF5m0FlASJecV3ebCFOMlF6FAfpiII8SMx+ZWLhivhkCiEBuFFDDYbm+A2dQunueK J1Rp5ar9u8JdBCgNeBtjry9gBYmu2oMqt6VImLFjCTxj1RutHIOkH9w2MkqCUY4areII TinO4FF4z0MWKkRyNtb5fycarKME+vLzpjQREHecmPP0V6xWma+s1sdwx8D185/pt/i6 yq5Q== X-Gm-Message-State: AA+aEWbYwlW6VeYSqjaFd8hUEB/fl8PeVN0T88gOYvFURkd7OIPeANbF SGFczNNcs51U+pDc0obFsAA= 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_033858_048979_D70E2123 X-CRM114-Status: GOOD ( 13.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP use devm variant for of_provider registration so provider is freed at exit. Signed-off-by: Matti Vaittinen Acked-by: Peter Ujfalusi --- drivers/clk/clk-twl6040.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-twl6040.c b/drivers/clk/clk-twl6040.c index 25dfe050ae9f..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: 10711597 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 836F814E2 for ; Tue, 4 Dec 2018 11:39:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 710CB2A7A8 for ; Tue, 4 Dec 2018 11:39:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 628562A7D4; Tue, 4 Dec 2018 11:39:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EFED22A7A8 for ; Tue, 4 Dec 2018 11:39:41 +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=ZVRJk671irnXSEWWQ0IRmNLempcf6DfsLu//rOQf4H4=; b=Ean8ozJswD4uAM 8hR7wa5VyroEADUxVes6IAAs1xvxcSh6WXO8uOkjYrJXxgnBjfn6KXlVCKv6FzD5LBkk3BgFblJXr 4k9vjthyX47M/gTAbPH8GNmJbPH+XXJuDUGZIYKprfOVbXr1Qompl7XauL/5QjcHIbpxhfpKZxQ3r 2YOE6Q3j8IYfgle7ix8ap7NVbQbXvYyPG/GPkGQgSCqAn9RDZcbM5TUkRstAjpBoE3bIwzw4PNaK2 fYZv8i2EYQP8OBuFcpEysdZyXnzCQB1mVHKlOWf70X+J/67vvlsHuAhwMjXOH7wTLmVcGz7ao03tF nVff1qqMjoiKFxqmNhiw==; 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 1gU938-0003lk-Tq; Tue, 04 Dec 2018 11:39:34 +0000 Received: from mail-lf1-f68.google.com ([209.85.167.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU935-0003k9-Dt for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:39:32 +0000 Received: by mail-lf1-f68.google.com with SMTP id f23so11670131lfc.13 for ; Tue, 04 Dec 2018 03:39:21 -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=QiXDmYVQxtW03bx/otluzare4kK/jaQvAcvXtxENDzc0zHuC3CR5H6ZSjUEVX5lOzT COhkYAKOeOQa3ecPZgs2TlEkzDQSf4Pcny3K6KqTnBgJQyueafQRNPszPc3AVHdYFSaw wG2bAfZwAITpfdqIDcL8siW0DpEKLiKZvNtpmmN7AAFpZeUaxNzU0UHRQO9uqVN4tdhC LY35V/zfsIInUPoxAkar2lCn6jEn1LQGscYz8m3Z8cQcoJVLbXduCG9iiqe3/yToiWA7 zgjkwzSxVJChZN2ja2zDZk1yI9dRyiYv/WdBJROywW9iRZPCGsY+F71VfLL5p/9hNinU uvVQ== X-Gm-Message-State: AA+aEWbdYuN7ipf8SNLyay4I/6cv7MIhoR8WRGWUaU1i6ojDl/SdcHXc gtRBDdRI/zHA1YUPRtlwTrgJKLeaJ/A= 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_033931_463699_85443EAB X-CRM114-Status: GOOD ( 13.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP use devm variant for of_provider registration. Signed-off-by: Matti Vaittinen --- drivers/clk/qcom/apcs-msm8916.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/clk/qcom/apcs-msm8916.c b/drivers/clk/qcom/apcs-msm8916.c index b1cc8dbcd327..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: 10711601 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 2E6891923 for ; Tue, 4 Dec 2018 11:40:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A20E2ACDC for ; Tue, 4 Dec 2018 11:40:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D3822AF0A; Tue, 4 Dec 2018 11:40:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 597FC2ACDC for ; Tue, 4 Dec 2018 11:40:11 +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=MvgUv3tdJOpqv41hvDC+bwtFOluIBZN/ZokObHr1KB4=; b=ng/MUrMB++L+dk pJaqoL15s+V2mXLkRBeTGlEPTpmS7F2vBsx7TQ3xB+eG/binnccX4WnyxEE/lQpJhg+mSk7OFqUFo a+niQ92egxo4Of5+7TfdRdzcRdMfULuBcqVNild8P8reW2O8QlLLg6nfqvp8uuTWsOnKZV/JOrkpX K6LBWi9hM4LQ7tbtD1R/CaliK1ainCcpEQMNx08PTRBtc525uRJEZX5QgEhP+IjU/3StlhxX+1Nes B1QCMrvZQXZzj99qYER+6Eik1aRQygCgm0/lAzjdTD+mCTIe6xzaK9uwnXhaHZL7nlHvAC/EHPnLs HGYdwCdsqtLqLi5Ds6Bg==; 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 1gU93h-0004dF-Gq; Tue, 04 Dec 2018 11:40:09 +0000 Received: from mail-lj1-f196.google.com ([209.85.208.196]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU93b-00041H-2A for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:40:07 +0000 Received: by mail-lj1-f196.google.com with SMTP id c19-v6so14586702lja.5 for ; 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=QenHHC0DkQm89aXD1WQgOLU6RFcq4f6gQlK3xtHuVmjYsfW+tdTSyXPbnCPrW5Sx0B 0RFMb2s9Lafzm8AqeTmbrYpKcUxB2ZGidKuQCpontm0SjuWKSB9Jj/qQEbVVas/wAiUT sGoA0yCLmJuH2N0P3fTRo8jjCuuOw7YKJnRxYehXBS1MIQ9RVyJM49uY45ysYCWnd6qM +EwDH3FUoaXjNsZJQGSG9AMk+x7zKn7D0FmnhD1R0s0VP6SkzuVRMajBQfC7Bg+4Kccz +IIrFxtWaECOWgT2/W+oq8KZxBob0MVMB2LwNiq9XNzfFe+GgKpk+mFa0f3AxkHl9ukl 1xag== X-Gm-Message-State: AA+aEWYWhgtfCQJKLhkznaIJez2yXrxcPPmV6MeRV36NiGMcbCLZ3wNP 6pAK4ZJHu0enYDIW2qidhbQ= 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_034003_194957_1826CBCC X-CRM114-Status: GOOD ( 18.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ROHM bd71837 and bd71847 contain 32768Hz clock gate. Support the clock using generic clock framework. Note, only bd71837 is tested but bd71847 should be identical what comes to clk parts. Signed-off-by: Matti Vaittinen --- drivers/clk/Kconfig | 7 +++ drivers/clk/Makefile | 1 + drivers/clk/clk-bd718x7.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 drivers/clk/clk-bd718x7.c diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 81cdb4eaca07..2dc12bf75b1b 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -283,6 +283,13 @@ config COMMON_CLK_STM32H7 ---help--- Support for stm32h7 SoC family clocks +config COMMON_CLK_BD718XX + tristate "Clock driver for ROHM BD718x7 PMIC" + depends on MFD_ROHM_BD718XX + help + This driver supports ROHM BD71837 and ROHM BD71847 + PMICs clock gates. + source "drivers/clk/actions/Kconfig" source "drivers/clk/bcm/Kconfig" source "drivers/clk/hisilicon/Kconfig" diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 72be7a38cff1..a47430b387db 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -21,6 +21,7 @@ endif obj-$(CONFIG_MACH_ASM9260) += clk-asm9260.o obj-$(CONFIG_COMMON_CLK_AXI_CLKGEN) += clk-axi-clkgen.o obj-$(CONFIG_ARCH_AXXIA) += clk-axm5516.o +obj-$(CONFIG_COMMON_CLK_BD718XX) += clk-bd718x7.o obj-$(CONFIG_COMMON_CLK_CDCE706) += clk-cdce706.o obj-$(CONFIG_COMMON_CLK_CDCE925) += clk-cdce925.o obj-$(CONFIG_ARCH_CLPS711X) += clk-clps711x.o diff --git a/drivers/clk/clk-bd718x7.c b/drivers/clk/clk-bd718x7.c new file mode 100644 index 000000000000..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");