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: 487913 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp1259601jas; Wed, 28 Jul 2021 07:26:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwygT4Q0aaJE4T4OgUc0c4l3sHg+3u4j5n77XAHd5zJZ/XNymaUtA5rreMUe3OdQXWKmgWi X-Received: by 2002:a5d:9eda:: with SMTP id a26mr24172784ioe.166.1627482403240; Wed, 28 Jul 2021 07:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627482403; cv=none; d=google.com; s=arc-20160816; b=Y/02h94TrAlnQpxcsCL6rMG/29DFqoxCTqm3DMgojIj5FcthylbCjmBKlJookLUE6r 5LeIxnHw7uZZncak/IiyRyY3ApIaKhMbzsq84z0gebBRCEAqbQzrDKcGqUswj0S2iGvC 6O9eFxNMHys/0/b4zdLzG2Ys225qOYg9xZJGDCUp/s51gDKk9oUZPrAvmwLer0FUvN7L If8DDSKms9F+1mHqC4JNwjTAhfze2jtCFk9YOkAbZTwQ+14a9dTTJ2PUKkkhJEOBHvHJ YNCAQ4v/wpGMCphxr3yW1eqjoKsXqF6iJ37hy8nPjtjpCyAlUKNyDfjyVcqE89j52KjU Lzhg== 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=GJaDlSnC/hNhPjnByAZZc7+i+wuzXCs6r81DcH7ZrtQ=; b=ehJHNocamTepZpTwvsHSraDs6DvvOU19PEZUXyqCL1r2Q7Z+w/XkaufJwGUQlP2mwv NypDiIsfl9o3tbeJdOWPrMEMDC51KE0VURpQMqofZim8fd3T64yOYD+gcZ9yNTc4OAuK /hHD5BOsjUrle8Ah3bM0gJcUrjA2Co6ZZy16/KiauogDDQ41qLafBvQWQ4+x0xQh+zlo yxiF+ublNMhrM8P97GF7xrcf+zgYNDcKIexgrSWXP867q0cVASI6gjL3MYod8jIOkiCz xoAEGeTC24qXKIDB2yln7pbFb6XzcqkDsEyZ/I/+YEu5y8S/VYRv7Ap2dIW7LZzKHiRT phnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oRstao6g; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 v5si67256jan.37.2021.07.28.07.26.42; Wed, 28 Jul 2021 07:26:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-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=oRstao6g; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S236731AbhG1O0m (ORCPT + 8 others); Wed, 28 Jul 2021 10:26:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236473AbhG1OZH (ORCPT ); Wed, 28 Jul 2021 10:25:07 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 140BCC061796 for ; Wed, 28 Jul 2021 07:24:53 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id q2so3312869ljq.5 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=k4+duOGDCSmhly6ko5GH6tCckk6xrOnWOSRjBBOA4jksqt/rIBSjPFi8Dg5wuX/W/t kn23jaP/zOkkjt3esJHJkfKgGhcD1CcZEX2RIYadwKi16lsOGy8FG+4/34s075gj7djw ncdZR0gjk905eKKthnPJ5f7CqIw9ref9belv4OmBlm9AiA1pAPM1TXj6oVhHYS3+T1W3 xDcX9peiXfnKyKBBSNiiffuAmEU+gFunoQy7IUPy6kH/DUs3W6H6vrmIx4CBg5DaH60a 1nFEVPwGH4Hfg5cbEySJ2MHUxp0RSDkgzoZPXlOG98SpnDxXPwYN4HEm6s+RrQh3DlMc pk6A== X-Gm-Message-State: AOAM530RgfF65YT6gRFc7c9LcxpGptechzM9LAyB49QvecpBzixJnB2i iccCVPWicJd4eHAnU7oP16w3JA== 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-pm@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(+) -- 2.30.2 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: 489072 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 89AAEC4320E 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 75F1660F02 for ; Wed, 28 Jul 2021 14:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236425AbhG1O0m (ORCPT ); Wed, 28 Jul 2021 10:26:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236603AbhG1OZJ (ORCPT ); Wed, 28 Jul 2021 10:25:09 -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 E02A7C06179A for ; Wed, 28 Jul 2021 07:24:53 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id b21so3261781ljo.13 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=JIx6njJsb4+8uHwJk68I+5edub6l8EXo+SLqrL1+1wJA3aiI1xC7mEkTzpBnM71Cr2 07YZpuYdb1Ey3FB4r/4O5hINZinBmcbh0C2d4ZbWC0H8jNc8K87dvk3AYXdgZAVxUym1 w+ojIk0bqcDd6haEnnhtpU5Byy9J80Ilbfscnbv+QuFIwvAPP4nBcW8xU93deeJ5t41a 15BMBzEGnGtqHTA/AH8XNGoo4EAdSRHfwM8n5/hTDo8DYfzl7Nh/ajNW3q9d2Bh/P3F+ 0NsydB+/wwSao9CTQwOX5t/ClBbsdQDFU0tfW7tbxnEAxfWlXvUC/vU0PgBWZpEl4zJb 8SmA== X-Gm-Message-State: AOAM5327Kc+ceweRnpVI3unpOyplPiwMc28TLGZ2WW0Jik1z68JIoCcc J1FCHiAoefc5KodkHkUE388G0A== X-Google-Smtp-Source: ABdhPJxDzZVK2OU9Yfswy9HaaN71Lce2nNvA5IhpPE0C3KinQRcIfFKCkc8XZf87f/3cwxFbrhKprA== 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-pm@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(+) 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: 489073 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 598C8C4338F for ; Wed, 28 Jul 2021 14:25:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45FBC60F45 for ; Wed, 28 Jul 2021 14:25:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236701AbhG1OZX (ORCPT ); Wed, 28 Jul 2021 10:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236672AbhG1OZM (ORCPT ); Wed, 28 Jul 2021 10:25:12 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70D82C0617A4 for ; Wed, 28 Jul 2021 07:24:55 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id y34so4304714lfa.8 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=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=jTcjADB6gFK+gSEQZqVx/d/6yWAR+9v4CkHX+W4YAqUdIWLbeFW4yQgR8WDHePdusx 7IpNKSfEl/l6pNWL52VMsFpRcG0jHo5dYAH+k6arWhO5rbhgeguskZG3S8HqqWonyR8g 1PR4j6JsgRE2LOOIkSI8HEfWGZGWBr6TYKj+tNApHRsrkwWRsr5fIUu3HKyJDygFiXb9 I9umjnARgucdx1950zabboHHmvG3BAlJa0kNFQ9NP6xRVu5LU7kZjTfd7ijfrym0fHiv RWNwqPxOKwe4gstrHvkcXMuI7xaMMpctD046aV9IQPw4x9hq6rJhJI0E6/FKgS1rXcYt P+rw== X-Gm-Message-State: AOAM530SphJ85nCVgjKZTYdZzlrzZvaYAEgwVcarYaF+E/FtGl6xBcwt BbWWN8XDetyidYOb5KmFNT8NKg== X-Google-Smtp-Source: ABdhPJzFzWkjEijr37gKgpfAu8uj8Yc0XT+TBrYgea/4sQv/sOp8tzDQkh1SfMlkuc3Rra5F/pbcfA== 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-pm@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(-) 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: 488316 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 8F09CC04FE3 for ; Wed, 28 Jul 2021 14:25:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78C5460EB2 for ; Wed, 28 Jul 2021 14:25:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236809AbhG1OZ0 (ORCPT ); Wed, 28 Jul 2021 10:25:26 -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 S236667AbhG1OZM (ORCPT ); Wed, 28 Jul 2021 10:25:12 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FDD9C0617A2 for ; Wed, 28 Jul 2021 07:24:55 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id h9so3290996ljq.8 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=Ab14O7H9oZ/K0IKAX9pLVrBnWnCHfNgJqq2ybEqg10F3qAUS6Vyplf3qqwPCKlz3Ny RFKMtdLGNOECxeRKH2XYXkwJGLG5G5qQB9Mxp+GqpUc7Bv2cPqBqiXzTIB5Crr540x3o jof0KVEEjrAPi5MevmZc0PKv605tVOZv8HHbtreg59k3q6HguhWmZO5XetZsIlFOVGPI wLFs2oUr3pK2MIm9K/tLagHu7gTDYbhEfzEJSxptJOaIaIVpnvoSavM8cU1TzCYuWjda 9qDBlhS3Q/NEE9IaW1D4yBWdKOIHc5DCzWa/L6BgKFmJWk5W+YEwd+qWl4C4WCqaqIFG fcng== X-Gm-Message-State: AOAM532s2/Drp6Ss/DKRqql6Lbgi440C7T3SyIUvuQNhvCX+yn3EqGj1 OIycayxnFY55gIYHDoFqPeTlog== X-Google-Smtp-Source: ABdhPJyeHeYmfbX0mRutc4wBGIzl3E+3k3LZVsC7Z0deZwgnV/53DecPXbUtBDHZbzjGmXyhXbm+uw== 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-pm@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(-) 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: 487911 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp1258442jas; Wed, 28 Jul 2021 07:25:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+AT2bZs5QFZwi5jMcKm2A1isw5aoDuY+vx3Kju40Gcwn5EjtGSWbqj8appLc+xxNxjvbI X-Received: by 2002:a5e:a908:: with SMTP id c8mr23753359iod.116.1627482324861; Wed, 28 Jul 2021 07:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627482324; cv=none; d=google.com; s=arc-20160816; b=ARnqiRHE4e7oDoPOZJH4xAvawah9AJjBnDzyGOKo6Tl8Uuh76cQAFKX2WEzPeiLqPN UmuWmQ0j3vYb/gIHq8HbOjAiSMCTKFSsdmZb8wMywGuecPy+ZvqcHOEzkWyWwbvN7o9c lM+Gqf+5nnpkmSHW76KNYlnpzTsjCKMFbyj5+c87TNXf9jgSVLh2pkEadLWEdB4xiDIv R7f0KLB7KSvc8g9w0Icg0Lyj/YjLUJGS86pMrAs5YCo0nrRw8mWcPXiO/hpFhqcMbETm YxpCo6P2GedtqOfnlZk5P0OqDinKIRbhr8JkV1/+e1MjJSbE3Q91giACfZsPAA1OA15t r/aA== 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=1UBua13F+A5CHYAXTN2Yvc4txUC3tULAs/8cg48q4YI=; b=pFoPJTO4a7b2Jw8NTX1FrKDJzMqECkGGTja1OCYZNGcbt7Dktpft1LZxj0/mRcGoej i7q53wekQlK+oS4sdbthqi60u6FVJTfappnK58s9iv0H1lUYrl2b4I6QosTd+sH97+xp kVUGeQxw9CAjGPEHC4vv+FRGlPQqtsH1g5DiZGY9iKYcY7RFlMi157ATmi9I9EbDpBn4 +Xlqx+vScq/cxoQ5el4jGxQbdB4i7WG58LIQVVYX9RAufyr7S8KQJbSN70k+kK32Kfmh zkPhUcvIS64fKq3jNY7JmJkUeRuYm+CL8Z4thyrPk3x8R2Z2BL8WI90oNi/uIt7NsK2N 1yOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=usaAQKG9; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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.24; Wed, 28 Jul 2021 07:25:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-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=usaAQKG9; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S236745AbhG1OZU (ORCPT + 8 others); Wed, 28 Jul 2021 10:25:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236686AbhG1OZM (ORCPT ); Wed, 28 Jul 2021 10:25:12 -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 2D7E8C0617B1 for ; Wed, 28 Jul 2021 07:24:56 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id f12so3338598ljn.1 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=TZrTMcf4rahxPv/bWETFMLiszrn93dpC13cUOE4NwBbccn0Rb+82NZSQBuPwmaD1c8 MJcAlAO7CBbOs2mn4UvQXGrXdsJRKyWSqEiZRYk93SeY0BLaqLfLFuZhx9Ugu0XK4vy6 yAkXKBZ3r6wwX7WiRr9SHNekWPulnaF/s5AX+llW4SI+gyEq2DH7RjXYtX5hkH12hpa+ N0rWw4siuQAR7ZuqskMNVEJIu8XsCOKAiMMpVz80m5fFJC9Ck20NP0p5ooc4fqGaTyuh 6olOfXls2LbuPXqPZLKZPbe/9K/fEriON9lNx8xLpti93/rduuL5G2FVRoapV1k9VE5f i6oA== X-Gm-Message-State: AOAM531OidzVEf+elmhnh/tQq/k8IiclxK5b8cl3NRakW4qXD6P0fKpc Zw5ov+zyE6rqBK4ptGtVFOWcHQ== 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-pm@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(-) -- 2.30.2 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 = {