From patchwork Fri Jul 21 09:40:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 706021 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 C3109EB64DD for ; Fri, 21 Jul 2023 09:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbjGUJlQ (ORCPT ); Fri, 21 Jul 2023 05:41:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbjGUJlO (ORCPT ); Fri, 21 Jul 2023 05:41:14 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CA57F0 for ; Fri, 21 Jul 2023 02:41:13 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1b89d47ffb6so10390115ad.2 for ; Fri, 21 Jul 2023 02:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689932473; x=1690537273; 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=C6yDwHR8CjSzLvtEor6MI6CE+UiAGOZc12BD4oiDuSo=; b=PdKQDS+1nlXydb+5R8TxjZ7RbKzetxDiuD7HuGUHno/JNfMOM1u+Wugb/3enYlBk0a /yJRnGtbDQsFLP5Vhtcis/4Q0J2RY5Jvk1NWjHcaBmvu/RgtuWqDmAu1uMk4YoeqtNxp iyUHSBJydok2kBv/ryvHmscoax+3oJELdtfRGtyX3zf9qdxnN5E8N6nWLvy4rpkmOT4o hRLSF8TeHyf1FdQgQvchDb/1d+iNwbwiMdFQtZE3BOcPI4Nm2W2XM1aV5U21xenx9YR4 6qLMKQhJBb1JrYhh5dsRcdbVTcrrrhYgSEkDq0I/7XhH7qQUISf3qrSnpBlXHl+RGbS/ /uMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689932473; x=1690537273; 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=C6yDwHR8CjSzLvtEor6MI6CE+UiAGOZc12BD4oiDuSo=; b=eQ67RA1Jwq7y0ivyh3LvSLvV9PRFKrttvKjqzmpjn0lSpew52ATyjnnGCEhD1h1nrd EwZPJif+baytH2t2Hk0/yGnzT+onhcp+ssidnQErYCzMcAQimfFAdauQNhawwKtn9KLA 4gn7mPAymOiT8s2TDVTxLi/E5UeflCeFAwDlhc7vuWKe1b4M/zkKxq6AHcI8WZUtWsOo ZEdGKETToSn6X3eo/+0Vk9w4R5CaXGR9ymKQwSUoRTyQxDoRRJGb59v6urNUDERdLI5/ dKT2HwehponC4vkJMRLmHHcUQOyTO7zCOw0ZDUnxxFjLnT4/ZQ6Xg8whFnZWzy0ICJsL uShA== X-Gm-Message-State: ABy/qLbkeJEw9ZbvumT77989CFtk7WMgON+vR873wDZdZ67/poUgVOSt KWx+JtB2ZTNQQuBRiRdBhCxc9A== X-Google-Smtp-Source: APBJJlHHO7Z+R2tpbCR19q/21EKGqsi2PifbH2YSzzeeHwz2+Q4HfzwBny+9uk4Oi5w4pSHQKKM8lQ== X-Received: by 2002:a17:902:ce84:b0:1b6:ba60:77f0 with SMTP id f4-20020a170902ce8400b001b6ba6077f0mr1347225plg.10.1689932472961; Fri, 21 Jul 2023 02:41:12 -0700 (PDT) Received: from localhost ([122.172.87.195]) by smtp.gmail.com with ESMTPSA id c1-20020a170902d48100b001b895a17429sm2959770plg.280.2023.07.21.02.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 02:41:12 -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 1/6] OPP: Rearrange entries in pm_opp.h Date: Fri, 21 Jul 2023 15:10:54 +0530 Message-Id: <754833b3194c30dad5af0145e25192a8e29521ab.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 Rearrange the helper function declarations / definitions to keep them in order of freq, level and then bw. Signed-off-by: Viresh Kumar --- include/linux/pm_opp.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index dc1fb5890792..3821f50b9b89 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -121,17 +121,19 @@ unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev); 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_floor(struct device *dev, unsigned long *freq); +struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, + unsigned long *freq); + struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, unsigned int level); + struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, unsigned int *level); -struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, - unsigned long *freq); - struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev, unsigned int *bw, int index); @@ -247,32 +249,32 @@ static inline unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev) return 0; } -static inline struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, - unsigned int level) +static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, + unsigned long freq, bool available) { return ERR_PTR(-EOPNOTSUPP); } -static inline struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, - unsigned int *level) +static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, + unsigned long *freq) { return ERR_PTR(-EOPNOTSUPP); } -static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, - unsigned long freq, bool available) +static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, + unsigned long *freq) { return ERR_PTR(-EOPNOTSUPP); } -static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, - unsigned long *freq) +static inline struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, + unsigned int level) { return ERR_PTR(-EOPNOTSUPP); } -static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, - unsigned long *freq) +static inline struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, + unsigned int *level) { return ERR_PTR(-EOPNOTSUPP); } From patchwork Fri Jul 21 09:40:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 705181 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 88BF6EB64DC for ; Fri, 21 Jul 2023 09:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230029AbjGUJlX (ORCPT ); Fri, 21 Jul 2023 05:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230105AbjGUJlS (ORCPT ); Fri, 21 Jul 2023 05:41:18 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E530E30C4 for ; Fri, 21 Jul 2023 02:41:16 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-68336d06620so1531173b3a.1 for ; Fri, 21 Jul 2023 02:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689932476; x=1690537276; 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=6VfRkQPrBQp5nkzs4j3nyKArLBvoZpDkodHX3J6rbBs=; b=iCXPQGvwGph1wJcfy5vSSwH6shKYOGyynlju+9gl4A04h/yKW9uOhJRBt8NLnwxmo6 ED0QoVvs6hdXY5QsxX6AlkkaG3tj4o/XB0FBmWbBrdJ4GUM2T2TK9pSZlsKQMyYgSYz6 MppgzuZZ56SOT1Tr0Ti7X+g2ov8t+2tuNznc+FukPQ6mIK3U1fa987bB+yHh8svg4oRG LNSXvTbC2fYdX9P2hR8XRhia9Bo1em7EHAzTCySDUy1u922uOvaoLOAMBpkF0Hbs+Pci M9LFscK0/EDqwEY7zgmjhW9llglYBLEfJ8002K2wHzkSlgT/0mOG3qbc9JRMk4pjQSoQ pMWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689932476; x=1690537276; 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=6VfRkQPrBQp5nkzs4j3nyKArLBvoZpDkodHX3J6rbBs=; b=gyO7F7c9UoLBuzUdE3ER6ZlrQee7euyTZDw88bs9xVon7jNvPkWAKOYI1HZGzlQkVb 0nB7sL7uEd2LNGsPzNYU/fa/s3gDmx40uoMGxcSQ6Nu4RelujAtXOW/hOk361OcaEwm8 S+t7sLCFMJjgH8HOvcmqgYsBBy8Dhej4qBuu4ZGw26+dD0PSX2K+zJ8UQloQwKlzk3I7 XH1XUY59I5lZ59rIJxCsdsCfyEWVmemkvw6xbDlqNAwV0y0McPYKusOZBGG7cznVsOgt JbzEebNFPEQjc1X5MTAVrxBzcIgSjuRNB5YRajSg6ZHXAMKaKEbcAftBtwNxBQECt2t+ TdEw== X-Gm-Message-State: ABy/qLb+Tr7OZfHNECZj3GiDG4yrlpHKPmDYDN7HBhGvWBotQCb4Mvdk 49Du4g07KicLi3V8rKD51WG1Fg== X-Google-Smtp-Source: APBJJlFFaDABXjfj3teUYbjZ3xP8/Hta2nJG2IfmVTu/qm200JNmynpvTbbWjXkG9w7UAXArYfhCQg== X-Received: by 2002:a05:6a00:22c4:b0:686:2fde:4da with SMTP id f4-20020a056a0022c400b006862fde04damr1949197pfj.15.1689932476347; Fri, 21 Jul 2023 02:41:16 -0700 (PDT) Received: from localhost ([122.172.87.195]) by smtp.gmail.com with ESMTPSA id x9-20020a056a00270900b00654228f9e93sm2584934pfv.120.2023.07.21.02.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 02:41:15 -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 2/6] OPP: Introduce dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs Date: Fri, 21 Jul 2023 15:10:55 +0530 Message-Id: <142e17c1c2b48e3fb4f024e62ab6dee18f268694.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 From: Manivannan Sadhasivam In the case of devices with multiple clocks, drivers need to specify the clock index for the OPP framework to find the OPP corresponding to the floor/ceil of the supplied frequency. So let's introduce the two new APIs accepting the clock index as an argument. These APIs use the exising _find_key_ceil() helper by supplying the clock index to it. Signed-off-by: Manivannan Sadhasivam [ Viresh: Rearranged definitions in pm_opp.h ] Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 56 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 18 ++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 3f46e499d615..cb4f47b341f9 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -658,6 +658,34 @@ struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, } EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil); +/** + * dev_pm_opp_find_freq_ceil_indexed() - Search for a rounded ceil freq for the + * clock corresponding to the index + * @dev: Device for which we do this operation + * @freq: Start frequency + * @index: Clock index + * + * Search for the matching ceil *available* OPP for the clock corresponding to + * the specified index from a starting freq for a device. + * + * Return: matching *opp and refreshes *freq accordingly, 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_ceil_indexed(struct device *dev, unsigned long *freq, + u32 index) +{ + return _find_key_ceil(dev, freq, index, true, _read_freq, NULL); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil_indexed); + /** * dev_pm_opp_find_freq_floor() - Search for a rounded floor freq * @dev: device for which we do this operation @@ -683,6 +711,34 @@ struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, } EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor); +/** + * dev_pm_opp_find_freq_floor_indexed() - Search for a rounded floor freq for the + * clock corresponding to the index + * @dev: Device for which we do this operation + * @freq: Start frequency + * @index: Clock index + * + * Search for the matching floor *available* OPP for the clock corresponding to + * the specified index from a starting freq for a device. + * + * Return: matching *opp and refreshes *freq accordingly, 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_floor_indexed(struct device *dev, unsigned long *freq, + u32 index) +{ + return _find_key_floor(dev, freq, index, true, _read_freq, NULL); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor_indexed); + /** * dev_pm_opp_find_level_exact() - search for an exact level * @dev: device for which we do this operation diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 3821f50b9b89..2617f2c51f29 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -125,9 +125,15 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq); +struct dev_pm_opp *dev_pm_opp_find_freq_floor_indexed(struct device *dev, + unsigned long *freq, u32 index); + struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, unsigned long *freq); +struct dev_pm_opp *dev_pm_opp_find_freq_ceil_indexed(struct device *dev, + unsigned long *freq, u32 index); + struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, unsigned int level); @@ -261,12 +267,24 @@ static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, return ERR_PTR(-EOPNOTSUPP); } +static inline struct dev_pm_opp * +dev_pm_opp_find_freq_floor_indexed(struct device *dev, unsigned long *freq, u32 index) +{ + return ERR_PTR(-EOPNOTSUPP); +} + static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, unsigned long *freq) { return ERR_PTR(-EOPNOTSUPP); } +static inline struct dev_pm_opp * +dev_pm_opp_find_freq_ceil_indexed(struct device *dev, unsigned long *freq, u32 index) +{ + return ERR_PTR(-EOPNOTSUPP); +} + static inline struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, unsigned int level) { From patchwork Fri Jul 21 09:40:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 706020 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 E5C3FEB64DD for ; Fri, 21 Jul 2023 09:41:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbjGUJl3 (ORCPT ); Fri, 21 Jul 2023 05:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbjGUJlX (ORCPT ); Fri, 21 Jul 2023 05:41:23 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46DA730D4 for ; Fri, 21 Jul 2023 02:41:20 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-66c729f5618so1563109b3a.1 for ; Fri, 21 Jul 2023 02:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689932480; x=1690537280; 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=JYBTSL0OfRqOhOs6Z05SkTlqzON3K7UIBYPi9xq4xxc=; b=h/+u+zIoZ/y1VnucGLle63jX7c+pQ7Xm0NSJwjLnLSldtrque1+JD9Y6a5Wt6PV+s8 nSh+rpgcEuhavmiPomFhpb0tgkZ9ria5aWjkvT4t/eGKlkkib3Se8yudwK9gO7HWsWso riB1rg8fd7Cn3A4auXB5333l3S1A/Wm/ucpZx74pgINzcnP4STs9BAOF0/Wx9lk5e+d/ +mOZ6lXDiummONPaFzjVBcA7Ne48ukqaWjjF9HPevN7LRV5KGvNLT9FWwCs5HFGjSxKr EPYzojBgnvifHYFzhsMhUsMRDXh5/j/snvR7jwU9b/RRxI6r0U2/XSIGuPL2z9v0xMEB OszQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689932480; x=1690537280; 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=JYBTSL0OfRqOhOs6Z05SkTlqzON3K7UIBYPi9xq4xxc=; b=SlUoFkIHLTMMeTYaY5eHvXXMd5LGt9o5fdutrQDIRCeHyrjO4o4LbpnCnfZ/mjez+a vx4u7vTv6c5rX2MlIK/DjqAeIa2TrGtG1IDPWegR6B0Ww24aB2o10rQY8xr4TRVrX6Ro WSi6xCPf1UcY0EHBZ8UlNLnHxWYTccBdL4z3rpKZX46wuap6s/fyfXm6YD3fTaOBioXh 7BqoHjBLTDkZyVWlHC5d4Kuab33/slq4GQqGrq+weTsMPqGvN06YQrhgyQ+ppxcGczwi yWxRMtBtQajRMsX6m9u3RtW9GzA5JmUhm6ngu/xIEEcKpmmHo9Q2FJNP5YHdFEBiwGge LIMw== X-Gm-Message-State: ABy/qLa0tWt0ziOzIhsASSI2TSlIgX4hPwxorQxhFXqIK8zi4OzovuKH OqvxKU9zYstHh5kLSeHe6Bu4Cw== X-Google-Smtp-Source: APBJJlHXUu/oayiAgSCxfpwW4T9SemBsvXOG6+3NOAj1UN9MdpiDtsif4PSKpRSdjDaxkHrn6GIH5g== X-Received: by 2002:a05:6a00:2351:b0:686:24e1:d12e with SMTP id j17-20020a056a00235100b0068624e1d12emr1697924pfj.30.1689932479645; Fri, 21 Jul 2023 02:41:19 -0700 (PDT) Received: from localhost ([122.172.87.195]) by smtp.gmail.com with ESMTPSA id j26-20020a62e91a000000b00682ad247e5fsm2633899pfh.179.2023.07.21.02.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 02:41:19 -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 3/6] OPP: Introduce dev_pm_opp_get_freq_indexed() API Date: Fri, 21 Jul 2023 15:10:56 +0530 Message-Id: <93dc0fb7d0c51908ce1a1c35bec846afa7596e65.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 From: Manivannan Sadhasivam In the case of devices with multiple clocks, drivers need to specify the frequency index for the OPP framework to get the specific frequency within the required OPP. So let's introduce the dev_pm_opp_get_freq_indexed() API accepting the frequency index as an argument. Signed-off-by: Manivannan Sadhasivam Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 22 ++++++++++++++++++++++ include/linux/pm_opp.h | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index cb4f47b341f9..00638d40353f 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -197,6 +197,28 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); +/** + * dev_pm_opp_get_freq_indexed() - Gets the frequency corresponding to an + * available opp with specified index + * @opp: opp for which frequency has to be returned for + * @index: index of the frequency within the required opp + * + * Return: frequency in hertz corresponding to the opp with specified index, + * else return 0 + */ +unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index) +{ + struct opp_table *opp_table = opp->opp_table; + + if (IS_ERR_OR_NULL(opp) || index >= opp_table->clk_count) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + return opp->rates[index]; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq_indexed); + /** * dev_pm_opp_get_level() - Gets the level corresponding to an available opp * @opp: opp for which level value has to be returned for diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 2617f2c51f29..a13a1705df57 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -105,6 +105,8 @@ unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp); unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); +unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index); + unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, @@ -213,6 +215,11 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) return 0; } +static inline unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index) +{ + return 0; +} + static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) { return 0; 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) { From patchwork Fri Jul 21 09:40:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 706019 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 37F33EB64DC for ; Fri, 21 Jul 2023 09:41:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231421AbjGUJln (ORCPT ); Fri, 21 Jul 2023 05:41:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbjGUJlb (ORCPT ); Fri, 21 Jul 2023 05:41:31 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 699F7358B for ; Fri, 21 Jul 2023 02:41:26 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1b8ad356f03so11067605ad.1 for ; Fri, 21 Jul 2023 02:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689932486; x=1690537286; 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=ecCZasV/2WenVXDyoE4/W5g65II48G/OFEkNC6yHhK4=; b=xPO2cIrcSsEOWHLbJo/1rP2vhKK+JOYOe3Q0ys29Ek26FtDXZUte1VyFagly6pU1c6 WF0Hc8txjsBW6htA1P6/B3Et9sMJqeMDGtZ9QlhYOAW0k5v/ljmqZ3LlmkBTWsvzLqrc By+JpiGtwqO1BB5Ib/lZKA+iK5vc4vKQps36kqmDyRgmkDM7XVZPlmaHMp4SPBq1vZW9 Ohb/l6AIAQFKjXnSbvcvURLoxKgJJ+vfLtKgnhaxCdFrto/AE8sa0cyu8e0p4uqH3MCP PVOKtMgMkP+mweNRC45npmdd3bl6UkU9I1NWOWNYhrP69yPOZi6RTk00uJW2nAJQTAmH Mivg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689932486; x=1690537286; 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=ecCZasV/2WenVXDyoE4/W5g65II48G/OFEkNC6yHhK4=; b=QVl+NisxvAFrm+5wAT30Jtw4VRx0DVSR4F4QWtSHdUt+Fxy3D9K7lC8XxvjDkOhxcG xeCeVI/GwHE/BQ2q3Z6UbEsNprDFr70+WR1w1Z7qIYR4ihbW5O1B7wi4qC5czwcvpBMh yU1sbC1Slj1RzCt+xWxZQoL9HUwPWE+Myr6utEaYPOu7p7uxm4qcXlP54qgBPtUkvxlH 5twaxIHDUT2ZML32YKPRxh30vn38dMp0VXY9vIq8dfMcjgSJI/Qcmxhxe+gBqQOA7jM/ QPWPaQx+c5HV1UdEwh2bg9KyoGHKI46efIj/+K3gcqGteIv57M5y6t06NbsVgogDogfr jv3Q== X-Gm-Message-State: ABy/qLYOB5+UIorWzEfQbAceo+CAk8cT4iwjWaUSBdakY8t1dCNR1Ayy KBQw+OOq44IKNRIsMbfrCxUrWQ== X-Google-Smtp-Source: APBJJlHSnvCG5tuyWxpXiUQIgWDsCPS3Y8Nd+m2OqCv6WoSuswjTFEEEnMT3ddbdlQ3vTCzoObeAEw== X-Received: by 2002:a17:902:ba88:b0:1b8:944a:a932 with SMTP id k8-20020a170902ba8800b001b8944aa932mr1144713pls.2.1689932485880; Fri, 21 Jul 2023 02:41:25 -0700 (PDT) Received: from localhost ([122.172.87.195]) by smtp.gmail.com with ESMTPSA id jg5-20020a17090326c500b001b9fdeead86sm2989244plb.68.2023.07.21.02.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 02:41:25 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Manivannan Sadhasivam , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] OPP: Update _read_freq() to return the correct frequency Date: Fri, 21 Jul 2023 15:10:58 +0530 Message-Id: <13c3657578d0c054cfcfe4496dde560b6a816e3b.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 Now that we support finding indexed frequencies, lets update _read_freq() to return the right one. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 7b1d5724b3d8..95f49fbe431c 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -472,7 +472,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_opp_count); /* Helpers to read keys */ static unsigned long _read_freq(struct dev_pm_opp *opp, int index) { - return opp->rates[0]; + return opp->rates[index]; } static unsigned long _read_level(struct dev_pm_opp *opp, int index) From patchwork Fri Jul 21 09:40:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 705179 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 F385FEB64DD for ; Fri, 21 Jul 2023 09:41:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229947AbjGUJlr (ORCPT ); Fri, 21 Jul 2023 05:41:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231204AbjGUJlh (ORCPT ); Fri, 21 Jul 2023 05:41:37 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6B8E30E3 for ; Fri, 21 Jul 2023 02:41:29 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1b8bbcfd89aso10523415ad.1 for ; Fri, 21 Jul 2023 02:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689932489; x=1690537289; 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=wV1Dq3qxy3owBxFZT6zTX4jA+LGfZlUCj9m2f/LMDI4=; b=PX7uG1KzgJBF9OqFkdVoGQGowY0yc8uyhhSfAf0grrqIE31HiSaobdTHh3woQlGXGl AFqxibmxcYe39UOHeBHgoboxh9JYggzuUuvt1gJCi3ouJBIdUMoF4ixPcx8eJN3OK+ki btdQ/IoO87PY9n2Su1E4ChD5X10ObsuPDki1Rx/1aBCFcdc0ZdGVGdfetwIkwd4MKWeJ bJJqDzcGmqQUmyZtwGJPIyHwHDwculDG0IBmUXRxtWgTrZCBt4aD8Bdicjs7GNHauexv CtVk4Y80Atp8Fu256ntEOo/AGfDuZyhUX4EgdG9q7xiblOoGPCtYOssK23WQuWvV/B85 uh+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689932489; x=1690537289; 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=wV1Dq3qxy3owBxFZT6zTX4jA+LGfZlUCj9m2f/LMDI4=; b=ftJdB+blzZ0Xk43lArYgwzJKIG+R3GvFz0XNwIgE3fNUUTt5hBXqr0DlFrha5Sgg9D e2IXBfRYDIrz6FeKAYQXrHeB862E0gBkira1oladpJ4AKChZ7eMNAH91BRk24T8GbWzs 5Oi6vRQfdB+Yop7ESv9Lw3qWf4V+uMswaUpNdZ9oXI9fGlDBF+CNYYRBMocubiuXozAU l9ClqWgS3pLSq5/a3X8L8EYiS8i9ODZxyhLSsoGQ+1iqDaV0S8aTpwL3yyMVfufsb2lG 3fSf1+KOPSvFNM/foyTyg2upybp2GkHqe4K8bI9TzwHxSYWuOOW0p7yYhszwYpsL8Pgf NqHw== X-Gm-Message-State: ABy/qLaeIPupq/5Ea87DJhPTfXW8ZhbMZAzctbTVvWKRFBrgXx9/ZrU8 foLGeXrXZ8ebABJi5OwH099LLg== X-Google-Smtp-Source: APBJJlFwLBVVI5u6w9IjfM/dmNtJVCNAkIhF1rY/8iqPtscxzS4IN3fls6jffvT2kO3RWDvl6CRYyw== X-Received: by 2002:a17:902:ce84:b0:1b6:ba60:77f0 with SMTP id f4-20020a170902ce8400b001b6ba6077f0mr1347697plg.10.1689932489156; Fri, 21 Jul 2023 02:41:29 -0700 (PDT) Received: from localhost ([122.172.87.195]) by smtp.gmail.com with ESMTPSA id u22-20020a170902a61600b001b2069072ccsm3005270plq.18.2023.07.21.02.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 02:41:28 -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 6/6] OPP: Reuse dev_pm_opp_get_freq_indexed() Date: Fri, 21 Jul 2023 15:10:59 +0530 Message-Id: <5ddded46303f9d034ecb79f1fcc48abcc590f7db.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 Reuse dev_pm_opp_get_freq_indexed() from dev_pm_opp_get_freq(). Signed-off-by: Viresh Kumar Acked-by: Manivannan Sadhasivam --- drivers/opp/core.c | 21 --------------------- include/linux/pm_opp.h | 12 +++++------- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 95f49fbe431c..16a103e6695b 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -176,27 +176,6 @@ unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_power); -/** - * dev_pm_opp_get_freq() - Gets the frequency corresponding to an available opp - * @opp: opp for which frequency has to be returned for - * - * Return: frequency in hertz corresponding to the opp, else - * return 0 - */ -unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) -{ - if (IS_ERR_OR_NULL(opp)) { - pr_err("%s: Invalid parameters\n", __func__); - return 0; - } - - if (!assert_single_clk(opp->opp_table)) - return 0; - - return opp->rates[0]; -} -EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); - /** * dev_pm_opp_get_freq_indexed() - Gets the frequency corresponding to an * available opp with specified index diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 23e4e4eaaa42..91f87d7e807c 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -103,8 +103,6 @@ int dev_pm_opp_get_supplies(struct dev_pm_opp *opp, struct dev_pm_opp_supply *su unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp); -unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); - unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index); unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); @@ -214,11 +212,6 @@ static inline unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp) return 0; } -static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) -{ - return 0; -} - static inline unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index) { return 0; @@ -669,4 +662,9 @@ static inline void dev_pm_opp_put_prop_name(int token) dev_pm_opp_clear_config(token); } +static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) +{ + return dev_pm_opp_get_freq_indexed(opp, 0); +} + #endif /* __LINUX_OPP_H__ */