From patchwork Wed Jul 28 14:24:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 488840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F7A5C4320A for ; Wed, 28 Jul 2021 14:26:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DEAB60F9C for ; Wed, 28 Jul 2021 14:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236640AbhG1O0m (ORCPT ); Wed, 28 Jul 2021 10:26:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236425AbhG1OZD (ORCPT ); Wed, 28 Jul 2021 10:25:03 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CD36C0613D5 for ; Wed, 28 Jul 2021 07:24:53 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id f12so3338267ljn.1 for ; Wed, 28 Jul 2021 07:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GJaDlSnC/hNhPjnByAZZc7+i+wuzXCs6r81DcH7ZrtQ=; b=oRstao6gbKMmICYaC3SKWepRzcJHA4aEDbhQHTeyGN6rf1b8bh2me+VljUa8FRFrLm uvHpxG2nhxOt9I8zQvpK2HBQSvBv/ErY3sCeYPTexZAVtdmJu78wXqpvk4hfCHv2NWcK FEWoMmbYYiybDd5QcGhnDFlGCF9jzd84ryWCTf4pyocd50ggkSRMd2D8U4LE1HeGbWgE 8YMNOaEvgOyH4rmkr2EBXJ+sSJxxu8qAJECT/L7JqqerdiUWdD7TmyiLeuDIQ+a0KmYt 0YpJulR9+eollRE2a8RM+po6TbHYWv3F1AHnnoqjncdL9SH6xCNUgVOUyOQGf0/dZI53 Djpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GJaDlSnC/hNhPjnByAZZc7+i+wuzXCs6r81DcH7ZrtQ=; b=pAyTGZ9K58lKLqAFg1rZifKfratdy2J0XnLZ3nGo3L8gFJfXRJ8wjT7AVMwzrjUWSq nSR15+NzV0yRt+ISEyr8jL0aqMrw148EEwMsc+4RKLAB612MOLwT70/8hwfEZGJRg41U x2fEApmD73gC7xhqKw2hnmx5w9mLNQgVm69FWiQZmH/V1kUpvYOGr18OekaYhwus1LJ1 Bov5oA/xfbbIlmyifbx1DlSlZSpU9jqscHCur3AXO8gLuVFYmF1hmK6P9ScbdC3QT/iL UtGuaBfQowQugoHPspoqNzUfEK6uDuClVaE90eYtX33F93ieYXALvW5WQi3fg1CuMz+G W6lA== X-Gm-Message-State: AOAM531s/FCco4nKJ0Bxx3hpe9JMAu9S+ZjdiBVVbCtsg1nipHaG8Czd dPu6bF07kC/yQg1STlliDDbnkA== X-Google-Smtp-Source: ABdhPJx682H/mmR+mfH2Y1lEcXI3nATjRem0dqGtzAlXzB8PgkRBrJyjJCXwb4hDvTGS4TIMWPd/0w== X-Received: by 2002:a2e:2ac5:: with SMTP id q188mr93567ljq.168.1627482291321; Wed, 28 Jul 2021 07:24:51 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id h4sm15610lft.184.2021.07.28.07.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 07:24:50 -0700 (PDT) From: Dmitry Baryshkov To: "Rafael J. Wysocki" , Pavel Machek , Greg Kroah-Hartman , Stephen Boyd , Taniya Das , Michael Turquette , Andy Gross , Bjorn Andersson Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 1/5] PM: runtime: add devm_pm_runtime_enable helper Date: Wed, 28 Jul 2021 17:24:41 +0300 Message-Id: <20210728142445.774158-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210728142445.774158-1-dmitry.baryshkov@linaro.org> References: <20210728142445.774158-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add helper function handling typical driver action: call pm_runtime_enable at the probe() time and disable it during remove(). Signed-off-by: Dmitry Baryshkov --- drivers/base/power/runtime.c | 17 +++++++++++++++++ include/linux/pm_runtime.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 8a66eaf731e4..ec94049442b9 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1447,6 +1447,23 @@ void pm_runtime_enable(struct device *dev) } EXPORT_SYMBOL_GPL(pm_runtime_enable); +static void pm_runtime_disable_action(void *data) +{ + pm_runtime_disable(data); +} + +/** + * devm_pm_runtime_enable - devres-enabled version of pm_runtime_enable. + * @dev: Device to handle. + */ +int devm_pm_runtime_enable(struct device *dev) +{ + pm_runtime_enable(dev); + + return devm_add_action_or_reset(dev, pm_runtime_disable_action, dev); +} +EXPORT_SYMBOL_GPL(devm_pm_runtime_enable); + /** * pm_runtime_forbid - Block runtime PM of a device. * @dev: Device to handle. diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index aab8b35e9f8a..222da43b7096 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h @@ -59,6 +59,8 @@ extern void pm_runtime_put_suppliers(struct device *dev); extern void pm_runtime_new_link(struct device *dev); extern void pm_runtime_drop_link(struct device_link *link); +extern int devm_pm_runtime_enable(struct device *dev); + /** * pm_runtime_get_if_in_use - Conditionally bump up runtime PM usage counter. * @dev: Target device. @@ -253,6 +255,8 @@ static inline void __pm_runtime_disable(struct device *dev, bool c) {} static inline void pm_runtime_allow(struct device *dev) {} static inline void pm_runtime_forbid(struct device *dev) {} +static inline int devm_pm_runtime_enable(struct device *dev) { return 0; } + static inline void pm_suspend_ignore_children(struct device *dev, bool enable) {} static inline void pm_runtime_get_noresume(struct device *dev) {} static inline void pm_runtime_put_noidle(struct device *dev) {} From patchwork Wed Jul 28 14:24:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 487909 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp1258332jas; Wed, 28 Jul 2021 07:25:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLTdkpC7vy9IQt+2RUEKrcUqMDdBz82GYzoBlG6TjUaZkbuM8/dv4Vc4TE57TQm4dNA5vy X-Received: by 2002:a02:90cb:: with SMTP id c11mr193772jag.53.1627482317824; Wed, 28 Jul 2021 07:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627482317; cv=none; d=google.com; s=arc-20160816; b=TOMXOrcD/WKtfivI//BUrwd/N3H/pR0BaVeNcUVTWAO9POtC1OHbgR03IcZCJfgeY2 eB+JBwBqZ8IUltda4+rUzzYvggWkZ/jr/mKGJGj0wqC1KXVuYhOXAQetClILxBtHYLvd NAwAvSijPkdIQ6Y34IOdT6wS0P9NrnfIm2cSyILXYkWce7JKY/qoge4mmFJLzXUJKp6A UlGCjd2zsrVXhcqm1MtEfpoevg28EWZdDceZcyXW12KcBUo8gwq9oaMoswq2mD3Vscbc hJYqVf0hJvhByNLzAFrP0WCnOaIvl+RjshsK2JZDeRAG4matzAoATcye93qVeCf1gqvD rg0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R7kGrtZpvotoea9KWR3b5/H2rAVf7kCtopxK8UOkjF0=; b=hNXLOO/MTk9R6ab+OpWFY+GIW4k3nWaTgfb6J7RKdc6oVKFe0uQ/0OEm7VYelU2ahq UERS5DwbsXOi1fLS2aGVl936H8dvBNTEFGmoH/lKxKog2w+r0C1ETZ0C3zDlRJzFq3aT fmNQWknFOTxOZ1PdSL7u77omDMG5BL7YMztEt8NPRZuJv4z/9WjdUQ2bZMXXHcXcbXhX kbhmYVoiXTUpjwFgsrWC/X0yOyESa2tiDdy14+TB8Dxn8cFSezJ8B28XvSSUwuFVzMKv 9C4H7yeG2AW8ASFvbvIaa2jn5q2BJgyk9zVJ/LX0BhxazhSkOodW8vpFCbPryWHjzHBA pyHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D7UW3G6x; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si59582iok.60.2021.07.28.07.25.17; Wed, 28 Jul 2021 07:25:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D7UW3G6x; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235466AbhG1OZO (ORCPT + 17 others); Wed, 28 Jul 2021 10:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236577AbhG1OZH (ORCPT ); Wed, 28 Jul 2021 10:25:07 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFF64C061798 for ; Wed, 28 Jul 2021 07:24:53 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id q2so3312955ljq.5 for ; Wed, 28 Jul 2021 07:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R7kGrtZpvotoea9KWR3b5/H2rAVf7kCtopxK8UOkjF0=; b=D7UW3G6xRCJIJOwUVC6xwjmmg7O3u3ogLLD9rFJc7pyxYO2Q4vxiMo8p89Vd7T6s5C +ZX9xOm6or2iUuWP6Jg+k8a6W0EF1IXu7qBS8xvgl6eO7DRsDDLvrqnbKIYhhs6N5I9J Q+k4omFC6MVxtWCj1WAcAc1eIcW+C7n44YzVr1/Hja2TTV3XKLTuGjOi097yFcvlcUKN WePU7/PJ4yBU/3hpgHfokt6j9aPmZ6cGvx5PMg9FLP1BmnrUxER8mF4wHMGjmF4SkETC L8m+BpV8uLSgD3DZxjI259SQtT+gwrOe6czh/uuz3FlWCPSp5TfYABEkvJC9EZzkZkic XvyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R7kGrtZpvotoea9KWR3b5/H2rAVf7kCtopxK8UOkjF0=; b=aQekTzFR2FPpSaDNxXGiw/FCWaABbg3vxkH82ukW1Jt2WwIcgWV5Ww7GpACAp/WaLj z8LFgYUnKRM8vPe6tYoRFF2YqJ4+YUbTm5HjjuwP8qUHpb+3FkhPM5ym9zv2g7AcvcxA tzw4vujsFeXi3mevw6u8r5wxezPelTHMJV6PuBtEQjFaKlT8CeP0MDhAcK6+LYqHFj+e agCrFFefrt9LMe2ImCvGzPZD+Vh4GlJDJrUV48sGyo6GApy7Nps0kid0cJzJC1r6wJam z2LxUlip1P7w+zF1FROfU4PnuWSk/xUgvpxHayS/FukdFWDDYSnXjKgOikwQYHRA99Gn YWhw== X-Gm-Message-State: AOAM53359o91KGfVNpe1hjTf5ELz4tjGZtUmKtO6MmYe1HPPa9BPp4Op aTPafkenN8nbxf4khaE4uGaC9w== X-Received: by 2002:a2e:b5c9:: with SMTP id g9mr87754ljn.366.1627482292144; Wed, 28 Jul 2021 07:24:52 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id h4sm15610lft.184.2021.07.28.07.24.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 07:24:51 -0700 (PDT) From: Dmitry Baryshkov To: "Rafael J. Wysocki" , Pavel Machek , Greg Kroah-Hartman , Stephen Boyd , Taniya Das , Michael Turquette , Andy Gross , Bjorn Andersson Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 2/5] PM: clk: add devm_pm_clk_create helper Date: Wed, 28 Jul 2021 17:24:42 +0300 Message-Id: <20210728142445.774158-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210728142445.774158-1-dmitry.baryshkov@linaro.org> References: <20210728142445.774158-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add devm_pm_clk_create helper, devres-enabled version of the pm_clk_create(), which will call pm_clk_destroy at the correct time. Signed-off-by: Dmitry Baryshkov --- drivers/base/power/clock_ops.c | 17 +++++++++++++++++ include/linux/pm_clock.h | 5 +++++ 2 files changed, 22 insertions(+) -- 2.30.2 diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c index 0251f3e6e61d..4110c19c08dc 100644 --- a/drivers/base/power/clock_ops.c +++ b/drivers/base/power/clock_ops.c @@ -519,6 +519,23 @@ void pm_clk_destroy(struct device *dev) } EXPORT_SYMBOL_GPL(pm_clk_destroy); +static void pm_clk_destroy_action(void *data) +{ + pm_clk_destroy(data); +} + +int devm_pm_clk_create(struct device *dev) +{ + int ret; + + ret = pm_clk_create(dev); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, pm_clk_destroy_action, dev); +} +EXPORT_SYMBOL_GPL(devm_pm_clk_create); + /** * pm_clk_suspend - Disable clocks in a device's PM clock list. * @dev: Device to disable the clocks for. diff --git a/include/linux/pm_clock.h b/include/linux/pm_clock.h index 8ddc7860e131..ada3a0ab10bf 100644 --- a/include/linux/pm_clock.h +++ b/include/linux/pm_clock.h @@ -47,6 +47,7 @@ extern void pm_clk_remove(struct device *dev, const char *con_id); extern void pm_clk_remove_clk(struct device *dev, struct clk *clk); extern int pm_clk_suspend(struct device *dev); extern int pm_clk_resume(struct device *dev); +extern int devm_pm_clk_create(struct device *dev); #else static inline bool pm_clk_no_clocks(struct device *dev) { @@ -83,6 +84,10 @@ static inline void pm_clk_remove(struct device *dev, const char *con_id) static inline void pm_clk_remove_clk(struct device *dev, struct clk *clk) { } +static inline int devm_pm_clk_create(struct device *dev) +{ + return -EINVAL; +} #endif #ifdef CONFIG_HAVE_CLK From patchwork Wed Jul 28 14:24:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 487912 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp1258462jas; Wed, 28 Jul 2021 07:25:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzM4xQIUOy+i6hKkopj/xlA4e/yczGF/dfrff2c7nLSEGWDU1/F8SShrP0jXUv8GWl3i1n7 X-Received: by 2002:a02:90cb:: with SMTP id c11mr194277jag.53.1627482325877; Wed, 28 Jul 2021 07:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627482325; cv=none; d=google.com; s=arc-20160816; b=ftlwp+Gm0OLI+jrE/jjOb7YzuLRAL4ZxUQTOm3lpKsZNda1kVEz+QUoLeAbAMlFWBl 0JQxlTi0AOUmDYnyOJt1GAc9JVB/3o6QnzJ0faPDRE0w9JHYb3A5VzLM53nx98bkq56T oObRfgCww9jC2RAJn0uagV/pQHamBsv67Frctb3tNdLA6XKQx6kOQFVJ9u/Ry/3PJX+Z 7N8CMg5hES8W5l74xfpHXZ2WyZzejcITgoCvbaDAyexoDCcoiPMPSYXLh39VwMlQ7KeP n1sJs1bvsV9G5H9ZVSNHrrrynwxxhVrtPL+SCv2nHG0Eui5h5uY4cLZ+Eueo3X/uvYM/ z5MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v2Fy/yGaCX8hbu5Oi1QSk2N9k+27AOHOBEBqCYJNREY=; b=fNi9Zr75s3HzYIUES65ZxUj0v1+4K2Yq6xN/GPEQFJdj0dI4nw4TesMZjfN7TZwgFP vkbyDqiu68ALVmYghSmmQRpDA9L+MB2E57o3/l1v1q3RRoniTI5Na2YNBlhZ5mUeXTn9 7lZ+fghI1X7jqF7GWsis6Z/Gsb71ld7+Atkdhmr3wDWIUwnKWXPJMF4ufRttgLXOzstp 5HmJV3xybJVo4Csjh1y0svxncsf33usHOEjDoGhvI1jNikcYDNhBOU9yK0fRpZdH2IYD Y0ht9XwJJBild5m21CW/WlD94xQJTOXFJ2noynQprQdUXKq90s7Ej0XyFdvZ5QfCQWBd Vv4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EmcvNnI3; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si6576991ilq.43.2021.07.28.07.25.25; Wed, 28 Jul 2021 07:25:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EmcvNnI3; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236686AbhG1OZX (ORCPT + 17 others); Wed, 28 Jul 2021 10:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236663AbhG1OZM (ORCPT ); Wed, 28 Jul 2021 10:25:12 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D125C06179C for ; Wed, 28 Jul 2021 07:24:54 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id u3so4282991lff.9 for ; Wed, 28 Jul 2021 07:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v2Fy/yGaCX8hbu5Oi1QSk2N9k+27AOHOBEBqCYJNREY=; b=EmcvNnI3mvn0apdnurT/BjZwaw7s/DFVS225QVmyzkLv0fIUOia4CYxDSvvYOvyPW/ It3r0VKkFHcX+kWO0qfGsBk9XId7WKm6Zbf0MGtkmnOSfFwasar0UCiRLr51gbg5hm/A d7+8RHxq0M4rE02MjGN1A5ekcC1VbF7BgsDDcJ0nqPYTOb3TsF57FUq8gqGDBoZa59b2 Hak4GnGY4/6+bRQP6tJ0QWmo5naxiH7xHL1CsC68ggZPdFsjX3to9Zhe4itachUZt1C1 6ZtShv39So+hkLnjFOYezIJwEonliZHJbZt8zBb5Ey83/9t5QP95ADpOgB44SFpPFz+g gLsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v2Fy/yGaCX8hbu5Oi1QSk2N9k+27AOHOBEBqCYJNREY=; b=hkC7GoNw56wpEz0EsrBkDO4yghsIWNtGwnxTVwk+XhiwXMoqHe0RdJR4TKSXjF8CQT U++BTMGAMTsB4z4SyTD5ektn+/h3SGOgOjwoV65JfBjV8Nt8zl7Jfso5scf4yKQEtJ21 gUyfIVovwMzwqWl/zKlIIrYBkHS9fQj2gvj0R6jHv056NiSfwxt0Tttu+2Mh9yB59OyQ UeKLo32Sf/sC/oJjbAoSSiPwkdXIsckjakJbxCYR2GUSK29EnJYfhnud66BrRu57fJ68 LpNoH99xL2NpfMM2mdXFVOaagLMe19nWQWCYzYJ1XCj0t5cBGKh/w63MZ4HA8X05YlsK XypA== X-Gm-Message-State: AOAM531/Lx1g0Tuvk6X7ywMR5p5MQsFnqj3hO/uu2E5pJP/iyZnSBsfN ZUiGZPNCuhHG7U0wM0CfQbLatg== X-Received: by 2002:a19:5f48:: with SMTP id a8mr21264416lfj.496.1627482292985; Wed, 28 Jul 2021 07:24:52 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id h4sm15610lft.184.2021.07.28.07.24.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 07:24:52 -0700 (PDT) From: Dmitry Baryshkov To: "Rafael J. Wysocki" , Pavel Machek , Greg Kroah-Hartman , Stephen Boyd , Taniya Das , Michael Turquette , Andy Gross , Bjorn Andersson Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 3/5] clk: qcom: use devm_pm_runtime_enable and devm_pm_clk_create Date: Wed, 28 Jul 2021 17:24:43 +0300 Message-Id: <20210728142445.774158-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210728142445.774158-1-dmitry.baryshkov@linaro.org> References: <20210728142445.774158-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Use two new helpers instead of pm_runtime_enable() and pm_clk_create(), removing the need for calling pm_runtime_disable and pm_clk_destroy(). Signed-off-by: Dmitry Baryshkov --- drivers/clk/qcom/camcc-sc7180.c | 25 +++++++++------------ drivers/clk/qcom/lpass-gfm-sm8250.c | 21 ++++++++---------- drivers/clk/qcom/lpasscorecc-sc7180.c | 18 ++------------- drivers/clk/qcom/mss-sc7180.c | 30 +++++++------------------ drivers/clk/qcom/q6sstop-qcs404.c | 32 ++++++++------------------- drivers/clk/qcom/turingcc-qcs404.c | 30 +++++++------------------ 6 files changed, 46 insertions(+), 110 deletions(-) -- 2.30.2 diff --git a/drivers/clk/qcom/camcc-sc7180.c b/drivers/clk/qcom/camcc-sc7180.c index 9bcf2f8ed4de..ce73ee9037cb 100644 --- a/drivers/clk/qcom/camcc-sc7180.c +++ b/drivers/clk/qcom/camcc-sc7180.c @@ -1652,32 +1652,35 @@ static int cam_cc_sc7180_probe(struct platform_device *pdev) struct regmap *regmap; int ret; - pm_runtime_enable(&pdev->dev); - ret = pm_clk_create(&pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); + if (ret < 0) + return ret; + + ret = devm_pm_clk_create(&pdev->dev); if (ret < 0) return ret; ret = pm_clk_add(&pdev->dev, "xo"); if (ret < 0) { dev_err(&pdev->dev, "Failed to acquire XO clock\n"); - goto disable_pm_runtime; + return ret; } ret = pm_clk_add(&pdev->dev, "iface"); if (ret < 0) { dev_err(&pdev->dev, "Failed to acquire iface clock\n"); - goto disable_pm_runtime; + return ret; } ret = pm_runtime_get(&pdev->dev); if (ret) - goto destroy_pm_clk; + return ret; regmap = qcom_cc_map(pdev, &cam_cc_sc7180_desc); if (IS_ERR(regmap)) { ret = PTR_ERR(regmap); pm_runtime_put(&pdev->dev); - goto destroy_pm_clk; + return ret; } clk_fabia_pll_configure(&cam_cc_pll0, regmap, &cam_cc_pll0_config); @@ -1689,18 +1692,10 @@ static int cam_cc_sc7180_probe(struct platform_device *pdev) pm_runtime_put(&pdev->dev); if (ret < 0) { dev_err(&pdev->dev, "Failed to register CAM CC clocks\n"); - goto destroy_pm_clk; + return ret; } return 0; - -destroy_pm_clk: - pm_clk_destroy(&pdev->dev); - -disable_pm_runtime: - pm_runtime_disable(&pdev->dev); - - return ret; } static const struct dev_pm_ops cam_cc_pm_ops = { diff --git a/drivers/clk/qcom/lpass-gfm-sm8250.c b/drivers/clk/qcom/lpass-gfm-sm8250.c index f5e31e692b9b..96f476f24eb2 100644 --- a/drivers/clk/qcom/lpass-gfm-sm8250.c +++ b/drivers/clk/qcom/lpass-gfm-sm8250.c @@ -251,15 +251,18 @@ static int lpass_gfm_clk_driver_probe(struct platform_device *pdev) if (IS_ERR(cc->base)) return PTR_ERR(cc->base); - pm_runtime_enable(dev); - err = pm_clk_create(dev); + err = devm_pm_runtime_enable(dev); if (err) - goto pm_clk_err; + return err; + + err = devm_pm_clk_create(dev); + if (err) + return err; err = of_pm_clk_add_clks(dev); if (err < 0) { dev_dbg(dev, "Failed to get lpass core voting clocks\n"); - goto clk_reg_err; + return err; } for (i = 0; i < data->onecell_data->num; i++) { @@ -273,22 +276,16 @@ static int lpass_gfm_clk_driver_probe(struct platform_device *pdev) err = devm_clk_hw_register(dev, &data->gfm_clks[i]->hw); if (err) - goto clk_reg_err; + return err; } err = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, data->onecell_data); if (err) - goto clk_reg_err; + return err; return 0; - -clk_reg_err: - pm_clk_destroy(dev); -pm_clk_err: - pm_runtime_disable(dev); - return err; } static const struct of_device_id lpass_gfm_clk_match_table[] = { diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c index 2e0ecc38efdd..ac09b7b840ab 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -356,32 +356,18 @@ static const struct qcom_cc_desc lpass_audio_hm_sc7180_desc = { .num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs), }; -static void lpass_pm_runtime_disable(void *data) -{ - pm_runtime_disable(data); -} - -static void lpass_pm_clk_destroy(void *data) -{ - pm_clk_destroy(data); -} - static int lpass_create_pm_clks(struct platform_device *pdev) { int ret; pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 500); - pm_runtime_enable(&pdev->dev); - ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_runtime_disable, &pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); if (ret) return ret; - ret = pm_clk_create(&pdev->dev); - if (ret) - return ret; - ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_clk_destroy, &pdev->dev); + ret = devm_pm_clk_create(&pdev->dev); if (ret) return ret; diff --git a/drivers/clk/qcom/mss-sc7180.c b/drivers/clk/qcom/mss-sc7180.c index 673fa1a4f734..5a1407440662 100644 --- a/drivers/clk/qcom/mss-sc7180.c +++ b/drivers/clk/qcom/mss-sc7180.c @@ -73,36 +73,23 @@ static int mss_sc7180_probe(struct platform_device *pdev) { int ret; - pm_runtime_enable(&pdev->dev); - ret = pm_clk_create(&pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); if (ret) - goto disable_pm_runtime; + return ret; + + ret = devm_pm_clk_create(&pdev->dev); + if (ret) + return ret; ret = pm_clk_add(&pdev->dev, "cfg_ahb"); if (ret < 0) { dev_err(&pdev->dev, "failed to acquire iface clock\n"); - goto destroy_pm_clk; + return ret; } ret = qcom_cc_probe(pdev, &mss_sc7180_desc); if (ret < 0) - goto destroy_pm_clk; - - return 0; - -destroy_pm_clk: - pm_clk_destroy(&pdev->dev); - -disable_pm_runtime: - pm_runtime_disable(&pdev->dev); - - return ret; -} - -static int mss_sc7180_remove(struct platform_device *pdev) -{ - pm_clk_destroy(&pdev->dev); - pm_runtime_disable(&pdev->dev); + return ret; return 0; } @@ -119,7 +106,6 @@ MODULE_DEVICE_TABLE(of, mss_sc7180_match_table); static struct platform_driver mss_sc7180_driver = { .probe = mss_sc7180_probe, - .remove = mss_sc7180_remove, .driver = { .name = "sc7180-mss", .of_match_table = mss_sc7180_match_table, diff --git a/drivers/clk/qcom/q6sstop-qcs404.c b/drivers/clk/qcom/q6sstop-qcs404.c index 723f932fbf7d..507386bee07d 100644 --- a/drivers/clk/qcom/q6sstop-qcs404.c +++ b/drivers/clk/qcom/q6sstop-qcs404.c @@ -159,15 +159,18 @@ static int q6sstopcc_qcs404_probe(struct platform_device *pdev) const struct qcom_cc_desc *desc; int ret; - pm_runtime_enable(&pdev->dev); - ret = pm_clk_create(&pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); if (ret) - goto disable_pm_runtime; + return ret; + + ret = devm_pm_clk_create(&pdev->dev); + if (ret) + return ret; ret = pm_clk_add(&pdev->dev, NULL); if (ret < 0) { dev_err(&pdev->dev, "failed to acquire iface clock\n"); - goto destroy_pm_clk; + return ret; } q6sstop_regmap_config.name = "q6sstop_tcsr"; @@ -175,30 +178,14 @@ static int q6sstopcc_qcs404_probe(struct platform_device *pdev) ret = qcom_cc_probe_by_index(pdev, 1, desc); if (ret) - goto destroy_pm_clk; + return ret; q6sstop_regmap_config.name = "q6sstop_cc"; desc = &q6sstop_qcs404_desc; ret = qcom_cc_probe_by_index(pdev, 0, desc); if (ret) - goto destroy_pm_clk; - - return 0; - -destroy_pm_clk: - pm_clk_destroy(&pdev->dev); - -disable_pm_runtime: - pm_runtime_disable(&pdev->dev); - - return ret; -} - -static int q6sstopcc_qcs404_remove(struct platform_device *pdev) -{ - pm_clk_destroy(&pdev->dev); - pm_runtime_disable(&pdev->dev); + return ret; return 0; } @@ -209,7 +196,6 @@ static const struct dev_pm_ops q6sstopcc_pm_ops = { static struct platform_driver q6sstopcc_qcs404_driver = { .probe = q6sstopcc_qcs404_probe, - .remove = q6sstopcc_qcs404_remove, .driver = { .name = "qcs404-q6sstopcc", .of_match_table = q6sstopcc_qcs404_match_table, diff --git a/drivers/clk/qcom/turingcc-qcs404.c b/drivers/clk/qcom/turingcc-qcs404.c index 4cfbbf5bf4d9..4543bda793f4 100644 --- a/drivers/clk/qcom/turingcc-qcs404.c +++ b/drivers/clk/qcom/turingcc-qcs404.c @@ -110,36 +110,23 @@ static int turingcc_probe(struct platform_device *pdev) { int ret; - pm_runtime_enable(&pdev->dev); - ret = pm_clk_create(&pdev->dev); + ret = devm_pm_runtime_enable(&pdev->dev); if (ret) - goto disable_pm_runtime; + return ret; + + ret = devm_pm_clk_create(&pdev->dev); + if (ret) + return ret; ret = pm_clk_add(&pdev->dev, NULL); if (ret < 0) { dev_err(&pdev->dev, "failed to acquire iface clock\n"); - goto destroy_pm_clk; + return ret; } ret = qcom_cc_probe(pdev, &turingcc_desc); if (ret < 0) - goto destroy_pm_clk; - - return 0; - -destroy_pm_clk: - pm_clk_destroy(&pdev->dev); - -disable_pm_runtime: - pm_runtime_disable(&pdev->dev); - - return ret; -} - -static int turingcc_remove(struct platform_device *pdev) -{ - pm_clk_destroy(&pdev->dev); - pm_runtime_disable(&pdev->dev); + return ret; return 0; } @@ -156,7 +143,6 @@ MODULE_DEVICE_TABLE(of, turingcc_match_table); static struct platform_driver turingcc_driver = { .probe = turingcc_probe, - .remove = turingcc_remove, .driver = { .name = "qcs404-turingcc", .of_match_table = turingcc_match_table, From patchwork Wed Jul 28 14:24:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 487910 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp1258342jas; Wed, 28 Jul 2021 07:25:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmflFPIJEfgHPAtpLCkFpVbaYuB2BbGF60PkDut4yBT70Dei4HSktSW3tWN2lQVcmRuMrm X-Received: by 2002:a6b:7948:: with SMTP id j8mr23397583iop.32.1627482318645; Wed, 28 Jul 2021 07:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627482318; cv=none; d=google.com; s=arc-20160816; b=NXbdNk1ukqGgC5zpr5HnWbCEJqe5yd4H6saww797Ow7IEQqP10Xt5amhgCC0MP0Vv+ XTnBEPbXtj1fZwkcEVnneZ4sEY3Y73LPWQVBsQ6kCY3MQIBuB4o/kl4Yz8qcasE2m7q3 y5mH6S+yjvRrYM7+nUKwWgyFwO0NGfl2eygyey/3D1XNGWN2s2/gH6y/mGkpFGnDkC9U MU+aI61QDJMHNtTQea5/cwXRYSHrx3QOf2BbTynebDFhGhxaTWwfFpKGhwSUt8l4xOjW XIlhGIj55ptri9iYn6Y2+A7e2Y68zhQJE+cwftgG5XvHBOxNeSB+UTthSMrW0hb+7PzE U1GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ORimO8D42kAHhnXfoY653OGm+8ilcZTSD9Rm8q3p1bo=; b=fNjTU72u6PsvB4/CKNWjyQI/pYPErIhIgUIsoTUxqeZZ+ljj/Z2YW05gA3gHEO5Esd z4zbWXAqh1npMzyG3wBmH/kqSIVn50RpQZ7AKcfs26w4orKukIYl3l+Oa63klPHPuskk +UBQXixePcqZWVibQkUny6vrfyuSX8FLlDMZBcc4Nz7s2BIzMK0Kk37d06+cnR35uFOt RJckjwiA9laMRpMyUgjuG4dlXNSTz4cTEChRc26pbqmI9TpZYVXuzGAwVCCAOj06YTF/ eCAxlnom6bOy81r0uk+v8o020+AG6xf/AHBhEQi3ICXY6UGnpvcG/7HeNgE7Rr5lmamU J4ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QJdRABVp; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si59582iok.60.2021.07.28.07.25.18; Wed, 28 Jul 2021 07:25:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QJdRABVp; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235349AbhG1OZQ (ORCPT + 17 others); Wed, 28 Jul 2021 10:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236646AbhG1OZL (ORCPT ); Wed, 28 Jul 2021 10:25:11 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F8D5C0617A1 for ; Wed, 28 Jul 2021 07:24:55 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id x7so3284296ljn.10 for ; Wed, 28 Jul 2021 07:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ORimO8D42kAHhnXfoY653OGm+8ilcZTSD9Rm8q3p1bo=; b=QJdRABVp43c7JWRg8sbdKu6k+iBY7vTqpmXGlj/FeZzkEkG0i2omtElZod1AQGXI+J xVcYDap+fs7EweFwsu5TGdUi+b4kz0H14GE78mjrH+cwSAyJhxf26ZxMCYO0v/D+/kPt p73Cs8lzaG9gsFIorWc4P2FunLeHMpnaVREsNm6j+2URPW65Id04ee0oiY8qxio2CzmZ taYFAte0h2oRGq3fYRMftGNkXj4bxAZYQFGpZXn5fQeL7Bu2ezzJemFEF5o+0dJrZGsz E+WOBQiLRdGamNCkP2YOv9JdXV9kA7AIYSc13BAOiwVt9ddt+haN4UPVrQ0WIOZ10NSb aB1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ORimO8D42kAHhnXfoY653OGm+8ilcZTSD9Rm8q3p1bo=; b=JIFgtnKWXCB/+R+6fhrDyBdyqKhaxmQKMyNMRo7CIoGXqylcpwJvvM4v4V9m9vycG5 RLiuH7h8mWnjKWeEbiUPbUPQSi+bgEvuXCTCX4PusL4csT2Sks2rGJAQ9YdHSCzc70Cc sZyhTY3yhXKgG9seFfXqR+Ab7/EMD1s9WqgTVSqwz3BKYSto8bmTQEZ90bBN8TAJ65zk ygmsEnqg2wxq9FKgFg0e9W7yTvAGPBormRLRQXjtqMK9E6GzC3uNolW/0MiZmSXmrmGR g9DaQcV3MBcw3mDNOOu+HuD5/r0Cxf1+ma5U7FpujME1h4J2Zn/NWsW8ZdoinVeeNg6X p6Yw== X-Gm-Message-State: AOAM530TmbdzvsGjbj0rIMarzWSqlhycnmSiYQPmhvb+lvncVlIp5ARG gCeubpUefbGO2DHkn/BIjA1S0w== X-Received: by 2002:a2e:9605:: with SMTP id v5mr97711ljh.178.1627482293728; Wed, 28 Jul 2021 07:24:53 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id h4sm15610lft.184.2021.07.28.07.24.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 07:24:53 -0700 (PDT) From: Dmitry Baryshkov To: "Rafael J. Wysocki" , Pavel Machek , Greg Kroah-Hartman , Stephen Boyd , Taniya Das , Michael Turquette , Andy Gross , Bjorn Andersson Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 4/5] clk: qcom: use common code for qcom_cc_probe_by_index Date: Wed, 28 Jul 2021 17:24:44 +0300 Message-Id: <20210728142445.774158-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210728142445.774158-1-dmitry.baryshkov@linaro.org> References: <20210728142445.774158-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Rewrite qcom_cc_map and qcom_cc_probe_by_index to use (new) qcom_cc_map_by_index, removing code duplication and opening a way to have more common code in qcom_cc_map*. Signed-off-by: Dmitry Baryshkov --- drivers/clk/qcom/common.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 2.30.2 diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index 60d2a78d1395..ed7c516a597a 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -69,20 +69,26 @@ int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map, u8 src) } EXPORT_SYMBOL_GPL(qcom_find_src_index); -struct regmap * -qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc) +static struct regmap * +qcom_cc_map_by_index(struct platform_device *pdev, const struct qcom_cc_desc *desc, int index) { void __iomem *base; struct resource *res; struct device *dev = &pdev->dev; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + res = platform_get_resource(pdev, IORESOURCE_MEM, index); base = devm_ioremap_resource(dev, res); if (IS_ERR(base)) return ERR_CAST(base); return devm_regmap_init_mmio(dev, base, desc->config); } + +struct regmap * +qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc) +{ + return qcom_cc_map_by_index(pdev, desc, 0); +} EXPORT_SYMBOL_GPL(qcom_cc_map); void @@ -313,15 +319,8 @@ int qcom_cc_probe_by_index(struct platform_device *pdev, int index, const struct qcom_cc_desc *desc) { struct regmap *regmap; - struct resource *res; - void __iomem *base; - - res = platform_get_resource(pdev, IORESOURCE_MEM, index); - base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(base)) - return -ENOMEM; - regmap = devm_regmap_init_mmio(&pdev->dev, base, desc->config); + regmap = qcom_cc_map_by_index(pdev, desc, index); if (IS_ERR(regmap)) return PTR_ERR(regmap); From patchwork Wed Jul 28 14:24:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 488841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6C87C4320E for ; Wed, 28 Jul 2021 14:25:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D202D60EB2 for ; Wed, 28 Jul 2021 14:25:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235427AbhG1OZT (ORCPT ); Wed, 28 Jul 2021 10:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236701AbhG1OZN (ORCPT ); Wed, 28 Jul 2021 10:25:13 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D833C0617B9 for ; Wed, 28 Jul 2021 07:24:56 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id l17so3340663ljn.2 for ; Wed, 28 Jul 2021 07:24:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1UBua13F+A5CHYAXTN2Yvc4txUC3tULAs/8cg48q4YI=; b=usaAQKG9gjs/HixLkYbmV5Vg78JLuU2FwjS5WYkfbd4XmH8nDemPzFjILlRRYV+O9h wHK0WfSnIeUW5ZSr2nDOCQEIdW+dChyBkB3B90V6M4h5+PXZy2CyCphL4TPR5H/G1NmY Xdv6qKScWzIDwuhcuSNTTzYjsvtaVILD1VDm/vslU9KCuz6POPVJz/J9JmkWVMouAXp1 EiXk2929yPlRhAxHScl8EA/IfwjpIfDYC/7bRJYJ9bjwzWygVs2cF/ItKIEufZR3dfNn UosY3By9VQA/lqTIWA/f2zj2IzseVJWSoLaMobWowsxxoU5V7+01wP/tmAQC34qPltL1 9SXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1UBua13F+A5CHYAXTN2Yvc4txUC3tULAs/8cg48q4YI=; b=sD7zapRKX/vbPuSj77zjJdsosPng4O0iLkZKBT+7ekRyHhkv1W6+MTqSfOSyMunKM0 qCMAJMgjYhC0E4V82ZeCO1I6cIFRFKPUhwU9o5cR7wtq6xh73nymR1fIACBF3KEgIiLS 8WnbFuKIP1dkh0ooyo0qeHXEEUcCcbR8/O7tFovrxCIflv2IZOrXOAMnPCoNfZPJdCky xNExtoGSj/7wnFIjqwqjwCLNIRhANWKdeCTZLMsWn3G5lnHiX4497Csn/kW++fMopdR1 UPpp3KHoLnjheEGmMCkf7Z14loocX/z8bMsszUFbX8Cc6ZUi+ZWE6vZrtKChoCWM5YI9 SRuQ== X-Gm-Message-State: AOAM533f0vPZwqcJ7P17GxRdW2FmL0o2kSOFFkmI7KG8zXEp3g6lezrh 1ZLZLNx27sEZ55pX9NEtoP0nLQ== X-Google-Smtp-Source: ABdhPJxn2Z8txgg95TaIucUtPGJPNjcEmX4ILaMTN9aL/eyREY/1WXLyAoMLpCIWmewCNp2ibPE40w== X-Received: by 2002:a05:651c:110f:: with SMTP id d15mr67991ljo.275.1627482294412; Wed, 28 Jul 2021 07:24:54 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id h4sm15610lft.184.2021.07.28.07.24.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 07:24:54 -0700 (PDT) From: Dmitry Baryshkov To: "Rafael J. Wysocki" , Pavel Machek , Greg Kroah-Hartman , Stephen Boyd , Taniya Das , Michael Turquette , Andy Gross , Bjorn Andersson Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 5/5] clk: qcom: move pm_clk functionality into common code Date: Wed, 28 Jul 2021 17:24:45 +0300 Message-Id: <20210728142445.774158-6-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210728142445.774158-1-dmitry.baryshkov@linaro.org> References: <20210728142445.774158-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Several Qualcomm clock controller drivers use pm_clk functionality. Instead of having common code in all the drivers, move the pm_clk handling to the qcom_cc_map/qcom_cc_probe. Signed-off-by: Dmitry Baryshkov --- drivers/clk/qcom/camcc-sc7180.c | 28 +++++++----------- drivers/clk/qcom/common.c | 36 +++++++++++++++++++++++ drivers/clk/qcom/common.h | 17 +++++++++++ drivers/clk/qcom/lpasscorecc-sc7180.c | 41 +++++++++------------------ drivers/clk/qcom/mss-sc7180.c | 31 ++++++-------------- drivers/clk/qcom/q6sstop-qcs404.c | 22 ++++++-------- drivers/clk/qcom/turingcc-qcs404.c | 31 ++++++-------------- 7 files changed, 103 insertions(+), 103 deletions(-) diff --git a/drivers/clk/qcom/camcc-sc7180.c b/drivers/clk/qcom/camcc-sc7180.c index ce73ee9037cb..cb213b8473a5 100644 --- a/drivers/clk/qcom/camcc-sc7180.c +++ b/drivers/clk/qcom/camcc-sc7180.c @@ -1631,8 +1631,16 @@ static const struct regmap_config cam_cc_sc7180_regmap_config = { .fast_io = true, }; +static const char * const cam_cc_sc7180_pm_clks[] = { "xo", "iface" }; + +static const struct qcom_cc_pm cam_cc_sc7180_pm = { + .pm_clks = cam_cc_sc7180_pm_clks, + .num_pm_clks = ARRAY_SIZE(cam_cc_sc7180_pm_clks), +}; + static const struct qcom_cc_desc cam_cc_sc7180_desc = { .config = &cam_cc_sc7180_regmap_config, + .pm = &cam_cc_sc7180_pm, .clk_hws = cam_cc_sc7180_hws, .num_clk_hws = ARRAY_SIZE(cam_cc_sc7180_hws), .clks = cam_cc_sc7180_clocks, @@ -1652,25 +1660,9 @@ static int cam_cc_sc7180_probe(struct platform_device *pdev) struct regmap *regmap; int ret; - ret = devm_pm_runtime_enable(&pdev->dev); - if (ret < 0) - return ret; - - ret = devm_pm_clk_create(&pdev->dev); - if (ret < 0) - return ret; - - ret = pm_clk_add(&pdev->dev, "xo"); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to acquire XO clock\n"); - return ret; - } - - ret = pm_clk_add(&pdev->dev, "iface"); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to acquire iface clock\n"); + ret = qcom_cc_setup_pm(pdev, &cam_cc_sc7180_desc); + if (ret) return ret; - } ret = pm_runtime_get(&pdev->dev); if (ret) diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index ed7c516a597a..def01be085ba 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include #include @@ -307,6 +309,8 @@ int qcom_cc_probe(struct platform_device *pdev, const struct qcom_cc_desc *desc) { struct regmap *regmap; + qcom_cc_setup_pm(pdev, desc); + regmap = qcom_cc_map(pdev, desc); if (IS_ERR(regmap)) return PTR_ERR(regmap); @@ -320,6 +324,8 @@ int qcom_cc_probe_by_index(struct platform_device *pdev, int index, { struct regmap *regmap; + qcom_cc_setup_pm(pdev, desc); + regmap = qcom_cc_map_by_index(pdev, desc, index); if (IS_ERR(regmap)) return PTR_ERR(regmap); @@ -328,4 +334,34 @@ int qcom_cc_probe_by_index(struct platform_device *pdev, int index, } EXPORT_SYMBOL_GPL(qcom_cc_probe_by_index); +int qcom_cc_really_setup_pm(struct platform_device *pdev, const struct qcom_cc_pm *pm) +{ + int ret; + int i; + + if (!pm) + return -EINVAL; + + ret = devm_pm_runtime_enable(&pdev->dev); + if (ret) + return ret; + + if (pm->num_pm_clks) { + ret = devm_pm_clk_create(&pdev->dev); + if (ret) + return ret; + } + + for (i = 0; i < pm->num_pm_clks; i++) { + ret = pm_clk_add(&pdev->dev, pm->pm_clks[i]); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to acquire %s pm clk\n", pm->pm_clks[i]); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_cc_really_setup_pm); + MODULE_LICENSE("GPL v2"); diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h index bb39a7e106d8..ea4394439712 100644 --- a/drivers/clk/qcom/common.h +++ b/drivers/clk/qcom/common.h @@ -19,8 +19,15 @@ struct clk_hw; #define PLL_VOTE_FSM_ENA BIT(20) #define PLL_VOTE_FSM_RESET BIT(21) +/* This can be used from within the qcom_cc_desc or separately */ +struct qcom_cc_pm { + const char *const *pm_clks; + size_t num_pm_clks; +}; + struct qcom_cc_desc { const struct regmap_config *config; + const struct qcom_cc_pm *pm; struct clk_regmap **clks; size_t num_clks; const struct qcom_reset_map *resets; @@ -54,6 +61,16 @@ extern int qcom_cc_register_board_clk(struct device *dev, const char *path, const char *name, unsigned long rate); extern int qcom_cc_register_sleep_clk(struct device *dev); +extern int qcom_cc_really_setup_pm(struct platform_device *pdev, const struct qcom_cc_pm *pm); + +static inline int qcom_cc_setup_pm(struct platform_device *pdev, const struct qcom_cc_desc *desc) +{ + if (!desc->pm) + return 0; + + return qcom_cc_really_setup_pm(pdev, desc->pm); +} + extern struct regmap *qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc); extern int qcom_cc_really_probe(struct platform_device *pdev, diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c index ac09b7b840ab..af1b04615d1d 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -338,8 +338,16 @@ static struct regmap_config lpass_core_cc_sc7180_regmap_config = { .fast_io = true, }; +static const char * const lpass_core_sc7180_pm_clks[] = { "iface" }; + +static const struct qcom_cc_pm lpass_core_sc7180_pm = { + .pm_clks = lpass_core_sc7180_pm_clks, + .num_pm_clks = ARRAY_SIZE(lpass_core_sc7180_pm_clks), +}; + static const struct qcom_cc_desc lpass_core_hm_sc7180_desc = { .config = &lpass_core_cc_sc7180_regmap_config, + .pm = &lpass_core_sc7180_pm, .gdscs = lpass_core_hm_sc7180_gdscs, .num_gdscs = ARRAY_SIZE(lpass_core_hm_sc7180_gdscs), }; @@ -356,35 +364,16 @@ static const struct qcom_cc_desc lpass_audio_hm_sc7180_desc = { .num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs), }; -static int lpass_create_pm_clks(struct platform_device *pdev) -{ - int ret; - - pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_set_autosuspend_delay(&pdev->dev, 500); - - ret = devm_pm_runtime_enable(&pdev->dev); - if (ret) - return ret; - - ret = devm_pm_clk_create(&pdev->dev); - if (ret) - return ret; - - ret = pm_clk_add(&pdev->dev, "iface"); - if (ret < 0) - dev_err(&pdev->dev, "failed to acquire iface clock\n"); - - return ret; -} - static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) { const struct qcom_cc_desc *desc; struct regmap *regmap; int ret; - ret = lpass_create_pm_clks(pdev); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 500); + + ret = qcom_cc_really_setup_pm(pdev, &lpass_core_sc7180_pm); if (ret) return ret; @@ -423,11 +412,9 @@ static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) static int lpass_hm_core_probe(struct platform_device *pdev) { const struct qcom_cc_desc *desc; - int ret; - ret = lpass_create_pm_clks(pdev); - if (ret) - return ret; + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 500); lpass_core_cc_sc7180_regmap_config.name = "lpass_hm_core"; desc = &lpass_core_hm_sc7180_desc; diff --git a/drivers/clk/qcom/mss-sc7180.c b/drivers/clk/qcom/mss-sc7180.c index 5a1407440662..47feca261985 100644 --- a/drivers/clk/qcom/mss-sc7180.c +++ b/drivers/clk/qcom/mss-sc7180.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include @@ -63,35 +62,23 @@ static struct clk_regmap *mss_sc7180_clocks[] = { [MSS_AXI_NAV_CLK] = &mss_axi_nav_clk.clkr, }; +static const char * const mss_sc7180_pm_clks[] = { "cfg_ahb" }; + +static const struct qcom_cc_pm mss_sc7180_pm = { + .pm_clks = mss_sc7180_pm_clks, + .num_pm_clks = ARRAY_SIZE(mss_sc7180_pm_clks), +}; + static const struct qcom_cc_desc mss_sc7180_desc = { .config = &mss_regmap_config, + .pm = &mss_sc7180_pm, .clks = mss_sc7180_clocks, .num_clks = ARRAY_SIZE(mss_sc7180_clocks), }; static int mss_sc7180_probe(struct platform_device *pdev) { - int ret; - - ret = devm_pm_runtime_enable(&pdev->dev); - if (ret) - return ret; - - ret = devm_pm_clk_create(&pdev->dev); - if (ret) - return ret; - - ret = pm_clk_add(&pdev->dev, "cfg_ahb"); - if (ret < 0) { - dev_err(&pdev->dev, "failed to acquire iface clock\n"); - return ret; - } - - ret = qcom_cc_probe(pdev, &mss_sc7180_desc); - if (ret < 0) - return ret; - - return 0; + return qcom_cc_probe(pdev, &mss_sc7180_desc); } static const struct dev_pm_ops mss_sc7180_pm_ops = { diff --git a/drivers/clk/qcom/q6sstop-qcs404.c b/drivers/clk/qcom/q6sstop-qcs404.c index 507386bee07d..e19ee2b047ac 100644 --- a/drivers/clk/qcom/q6sstop-qcs404.c +++ b/drivers/clk/qcom/q6sstop-qcs404.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -117,6 +116,13 @@ static struct regmap_config q6sstop_regmap_config = { .fast_io = true, }; +static const char * const q6sstop_qcs404_pm_clks[] = { NULL }; + +static const struct qcom_cc_pm q6sstop_qcs404_pm = { + .pm_clks = q6sstop_qcs404_pm_clks, + .num_pm_clks = ARRAY_SIZE(q6sstop_qcs404_pm_clks), +}; + static struct clk_regmap *q6sstop_qcs404_clocks[] = { [LCC_AHBFABRIC_CBC_CLK] = &lcc_ahbfabric_cbc_clk.clkr, [LCC_Q6SS_AHBS_CBC_CLK] = &lcc_q6ss_ahbs_cbc_clk.clkr, @@ -159,19 +165,7 @@ static int q6sstopcc_qcs404_probe(struct platform_device *pdev) const struct qcom_cc_desc *desc; int ret; - ret = devm_pm_runtime_enable(&pdev->dev); - if (ret) - return ret; - - ret = devm_pm_clk_create(&pdev->dev); - if (ret) - return ret; - - ret = pm_clk_add(&pdev->dev, NULL); - if (ret < 0) { - dev_err(&pdev->dev, "failed to acquire iface clock\n"); - return ret; - } + ret = qcom_cc_really_setup_pm(pdev, &q6sstop_qcs404_pm); q6sstop_regmap_config.name = "q6sstop_tcsr"; desc = &tcsr_qcs404_desc; diff --git a/drivers/clk/qcom/turingcc-qcs404.c b/drivers/clk/qcom/turingcc-qcs404.c index 4543bda793f4..a2ac9e6da13c 100644 --- a/drivers/clk/qcom/turingcc-qcs404.c +++ b/drivers/clk/qcom/turingcc-qcs404.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -100,35 +99,23 @@ static const struct regmap_config turingcc_regmap_config = { .fast_io = true, }; +static const char * const turingcc_pm_clks[] = { NULL }; + +static const struct qcom_cc_pm turingcc_pm = { + .pm_clks = turingcc_pm_clks, + .num_pm_clks = ARRAY_SIZE(turingcc_pm_clks), +}; + static const struct qcom_cc_desc turingcc_desc = { .config = &turingcc_regmap_config, + .pm = &turingcc_pm, .clks = turingcc_clocks, .num_clks = ARRAY_SIZE(turingcc_clocks), }; static int turingcc_probe(struct platform_device *pdev) { - int ret; - - ret = devm_pm_runtime_enable(&pdev->dev); - if (ret) - return ret; - - ret = devm_pm_clk_create(&pdev->dev); - if (ret) - return ret; - - ret = pm_clk_add(&pdev->dev, NULL); - if (ret < 0) { - dev_err(&pdev->dev, "failed to acquire iface clock\n"); - return ret; - } - - ret = qcom_cc_probe(pdev, &turingcc_desc); - if (ret < 0) - return ret; - - return 0; + return qcom_cc_probe(pdev, &turingcc_desc); } static const struct dev_pm_ops turingcc_pm_ops = {