From patchwork Fri Jul 21 09:40:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 705180 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39792EB64DC for ; Fri, 21 Jul 2023 09:41:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231270AbjGUJlb (ORCPT ); Fri, 21 Jul 2023 05:41:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbjGUJl2 (ORCPT ); Fri, 21 Jul 2023 05:41:28 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74096F0 for ; Fri, 21 Jul 2023 02:41:23 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-666e3b15370so1244632b3a.0 for ; Fri, 21 Jul 2023 02:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689932483; x=1690537283; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Fj8dA1DktttqIwOcB9+fhQ+T0lm3kSZr4JIH2/qzqQA=; b=ppSdeh1tc7/xXjxPCMvsSLzFw8TMUJ+nxHU66ilqA2uJIXDHmUOzyl4Jhi3/j3Xxkn bfZ9i1cASnTa6Yxxl+HjKVYqZiVFA8lTf45yyrSB82n+lGi4ucYK86AjQwwnI3NAL1gc GCVmCtXOjB1m8QAo63HIFFGB6JNi4DTzyY7AYQ09GWX/PtG2JgDmxbUtMpZKYuQGUTFa IK9CQ6hNGTlmVIwjvsYyzE5+2fQpNDBZTEKESutobnEaknXcJf1MXkJsifXubACig7YY XMIfHP/45X5v3I6GkyI23Zf8bkcFIyc6ULojKi8BtpAi3D2RAYyj3SY39FOZmJEZ9VsX 0HZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689932483; x=1690537283; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fj8dA1DktttqIwOcB9+fhQ+T0lm3kSZr4JIH2/qzqQA=; b=GSkj46C7l7X9C6y9YrwqmPUM53mSe1HquMJxSKDGPLa7xRP+CpFMxvFySkBiHjYC7F adFkvGPWMr/xnZzs6+2UnYsLfJgF5GT9RD05UIvNMh2lruToMTgQei78BzGQzthLJc/D PHLbWl8Ti7AbvEAzdzIMYlr6wEAsyp9XriAaE4kyEu2OSv4g0qQ2pNpml3CnzRgFh4Sc AMqrjn9p1GYxldM1SZ/T/JabBImVQVzEOyklPYcnVXEnB6ssgaewzdqwmwn676QDCE4i 4HAuK+d49RYQEaSvy/k1rGlNRTQQoWRrSeJWQi2/RqIyFO1c1wkGyihfeOBoRnfOQhKS zP5w== X-Gm-Message-State: ABy/qLaect8wY5GKgAPLMMekt1kwalrTNvPTMGtV5OFFmYDigkU2L7jF CnS1TG7Htk3lRFXr3wMHHt7beA== X-Google-Smtp-Source: APBJJlE+Z+Q/a/hBNzBPrnIj9DIFZ6m3Wrxijt1nY+kqHYntfPBiUWs0s1pC4fNMKmMdjmCEHnjM1A== X-Received: by 2002:a05:6a20:b715:b0:130:661c:613d with SMTP id fg21-20020a056a20b71500b00130661c613dmr1069627pzb.5.1689932482813; Fri, 21 Jul 2023 02:41:22 -0700 (PDT) Received: from localhost ([122.172.87.195]) by smtp.gmail.com with ESMTPSA id j26-20020a62e91a000000b00682ad247e5fsm2634011pfh.179.2023.07.21.02.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 02:41:22 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Manivannan Sadhasivam , linux-kernel@vger.kernel.org Subject: [PATCH 4/6] OPP: Add dev_pm_opp_find_freq_exact_indexed() Date: Fri, 21 Jul 2023 15:10:57 +0530 Message-Id: <852a47c0e7a795bdf6424519ab7fadfdeb5b4a3c.1689932341.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The indexed version of the API is added for other floor and ceil, add the same for exact as well for completeness. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 28 ++++++++++++++++++++++++++++ include/linux/pm_opp.h | 11 +++++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 00638d40353f..7b1d5724b3d8 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -648,6 +648,34 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, } EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact); +/** + * dev_pm_opp_find_freq_exact_indexed() - Search for an exact freq for the + * clock corresponding to the index + * @dev: Device for which we do this operation + * @freq: frequency to search for + * @index: Clock index + * @available: true/false - match for available opp + * + * Search for the matching exact OPP for the clock corresponding to the + * specified index from a starting freq for a device. + * + * Return: matching *opp , else returns ERR_PTR in case of error and should be + * handled using IS_ERR. Error return values can be: + * EINVAL: for bad pointer + * ERANGE: no match found for search + * ENODEV: if device not found in list of registered devices + * + * The callers are required to call dev_pm_opp_put() for the returned OPP after + * use. + */ +struct dev_pm_opp * +dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, + u32 index, bool available) +{ + return _find_key_exact(dev, freq, index, available, _read_freq, NULL); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact_indexed); + static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table, unsigned long *freq) { diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index a13a1705df57..23e4e4eaaa42 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -124,6 +124,10 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, bool available); +struct dev_pm_opp * +dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, + u32 index, bool available); + struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq); @@ -268,6 +272,13 @@ static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, return ERR_PTR(-EOPNOTSUPP); } +static inline struct dev_pm_opp * +dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, + u32 index, bool available) +{ + return ERR_PTR(-EOPNOTSUPP); +} + static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq) {