Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp144852pxj; Wed, 16 Jun 2021 22:49:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBgQuF4OGu5CS2z9oZKP2H4BbFBhL7daYOlMCP8jrZj4N7om8pbZBlJHtxxs2U+Uf+fPu/ X-Received: by 2002:a6b:7d03:: with SMTP id c3mr2511630ioq.2.1623908975735; Wed, 16 Jun 2021 22:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623908975; cv=none; d=google.com; s=arc-20160816; b=ac1XcEwlFLiGaLGpd+VZ5AmaQYiUfwssThxIljAntPNxo1Mip8heb2piBQ9aUeh2L2 oqaYVeezPganNDhDMhnKs1ikiR6F14Cz2T2Sa0T2tDnFZlPRXGMozaVRzgd/1n7G26mT czOrOODF7BGGSuMYOhB3ql/uCxVyaAd2MtdxqGRzXbm7hCAzkhjQW+e8fqJowpJhOMlB XmCUHBVLQ8dk7XoMgHU1dcUUWcSlvdu6YeW+Bjt75AQL412DMtuFJt5E9liA97EFNvtO gcLiEADw+zoapN+sybYKsIW/jMk5SjUQ+vgTzo0CeygxwT+zQj0CLmnO76gNxJSA50RG 0GPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=YkhycMwItQsXct9Ie+LrHnOaX0bytSrZJ0ISUxzczEw=; b=PrgjS8e6rA/F8v2vIjhjQPDCVuKX0zgSGS5rP7miqD4jOlADape/z8uMeTPmYgTaCS OizUWsWDaU6SVTh/LNUac4ytWUMCUkEktQ00cltA21gmj1TQF7jywQ+63XWmWfxlzVa6 YyNzQxIfayVn8/aHoMjPE8RyRZrVt0IgsyizfEV2CYyB9YpHkP7yUaXNrRGMr7zg+yud TcoGXp3N5fo5NzBfJf88YWhqlju0jlddmWMCBB4YHWNUc7xRMNgKmGbmCBj8NUoShENz GWU04xEJQ//oyvl0PF4hmjCNajIkMa5sYGggJJtFmY7Q6nQf6AoURwO7Ca4cl7C4uZ9Z ABQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=k+sIcHSU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i1si4681902iov.7.2021.06.16.22.49.24; Wed, 16 Jun 2021 22:49:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@samsung.com header.s=mail20170921 header.b=k+sIcHSU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230280AbhFQFtU (ORCPT + 99 others); Thu, 17 Jun 2021 01:49:20 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:58741 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230205AbhFQFtC (ORCPT ); Thu, 17 Jun 2021 01:49:02 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20210617054652epoutp0480cf150bf98c17ffc52c1edbf691be1a~JSHX0Sfal2854328543epoutp04D for ; Thu, 17 Jun 2021 05:46:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20210617054652epoutp0480cf150bf98c17ffc52c1edbf691be1a~JSHX0Sfal2854328543epoutp04D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1623908812; bh=YkhycMwItQsXct9Ie+LrHnOaX0bytSrZJ0ISUxzczEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+sIcHSUsLVdQtmd7yWB3shodo3u6/siS43XR0+f8ORkd8m/aYZdzrEBnVsOo5d1G zbbXFqtP7+VJj1HK50PxODDcUGdOfoZBXmm5ijM+GJ3PgYL186x0cnbXKBMuPRxuzq WlWsJgexH260WqiYa6ZTHdgc73yhn93lSdBd3EB4= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20210617054651epcas1p2cd5037b5a294d98fa445b9a9343b64b1~JSHXVZnUB2425124251epcas1p2g; Thu, 17 Jun 2021 05:46:51 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.158]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4G59zX2353z4x9Pr; Thu, 17 Jun 2021 05:46:48 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id E7.AA.09736.8C1EAC06; Thu, 17 Jun 2021 14:46:48 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20210617054647epcas1p41cd87f03bc6f5b44b6f2d7a3e5924860~JSHT1Od_t3132231322epcas1p4x; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210617054647epsmtrp1920595a8995e3e5b262cbf3240932e44~JSHT0SzjX1935819358epsmtrp1T; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) X-AuditID: b6c32a39-ea97ca8000002608-f8-60cae1c83c74 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B9.9D.08637.7C1EAC06; Thu, 17 Jun 2021 14:46:47 +0900 (KST) Received: from localhost.localdomain (unknown [10.113.221.102]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210617054647epsmtip11ecc08f069d1ddecb288a933acbeb5ff~JSHTkh6dd1533015330epsmtip1X; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) From: Chanwoo Choi To: andrew-sh.cheng@mediatek.com, hsinyi@chromium.org Cc: sibis@codeaurora.org, saravanak@google.com, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, cw00.choi@samsung.com, chanwoo@kernel.org, cwchoi00@gmail.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] PM / devfreq: passive: Reduce duplicate code when passive_devfreq case Date: Thu, 17 Jun 2021 15:05:46 +0900 Message-Id: <20210617060546.26933-5-cw00.choi@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617060546.26933-1-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLKsWRmVeSWpSXmKPExsWy7bCmnu6Jh6cSDNat5bXYvv4Fq8XEG1dY LK5/ec5q8eyotsWE1u3MFmeb3rBbXN41h83ic+8RRovbjSvYLLoO/WWzuLbwPasDt8fshoss Hpf7epk8ds66y+6xYFOpx6ZVnWweLSf3s3j0bVnF6PF5k1wAR1S2TUZqYkpqkUJqXnJ+SmZe uq2Sd3C8c7ypmYGhrqGlhbmSQl5ibqqtkotPgK5bZg7QnUoKZYk5pUChgMTiYiV9O5ui/NKS VIWM/OISW6XUgpScAssCveLE3OLSvHS95PxcK0MDAyNToMKE7Iwzs5QLdstXfH41hamBcb9k FyMnh4SAicTU12fZuhi5OIQEdjBKvJn4gB3C+cQo8WzlH1YI5xujxOGNk9lhWg7f+A3VspdR YmHnb6iqL4wSP5b9YwSpYhPQktj/4gYbiC0iYCqx5/BEFpAiZoF7jBKPlp8HSwgLxEpcW3+F CcRmEVCV2HxgA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CWhJ7H9xgw2kRkTAXOL4lWiQGmaBV4wS984+BqsRFoiW+DC7jRnE ZhFQldh8YAIjiM0rYCVxu38+M8QueYnVGw6A2ZwC1hLnltxhB5kpBFRz/lX6BEa+BYwMqxgl UwuKc9Nziw0LDPNSy/WKE3OLS/PS9ZLzczcxgkNWS3MH4/ZVH/QOMTJxMB5ilOBgVhLh1S0+ kSDEm5JYWZValB9fVJqTWnyIUZqDRUmc90LXyXghgfTEktTs1NSC1CKYLBMHp1QD00r2ybVn 2Z2O1zF8k9K4PtPavuf0qhjhVU/mrzjvG1ik43cgsey0wvXc4lOXj5/Y/y+a9Vl+PJtepZvM Qd+MnPjPnxl7tFVD+y/HLL8p8Cnk+No9B5nDHGfkPjg+ie/YmuCTomznT1x3tDd8bshbcL5l V6wHy9c18yau6BJ5t6PdU215a+ak7+7iYX6lLs69Jso5Hu7TTm5iWntq1fU0Ztcdp/gtz27q ejjrYNoRBtaLuXrvE/68XjvPxe7m6vstGfa1/y9qmW1/Uq9xdGHezXtqy36sXTTH1eB2m+6f GsnkrLxa52d7OTbsutUcu4vbXfjaoqXh/hes3M5rfVvj3fD40JyHSzdHbT42bfWzvkdKLMUZ iYZazEXFiQBD+CNRyAIAAA== X-CMS-MailID: 20210617054647epcas1p41cd87f03bc6f5b44b6f2d7a3e5924860 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210617054647epcas1p41cd87f03bc6f5b44b6f2d7a3e5924860 References: <20210617060546.26933-1-cw00.choi@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to keep the consistent coding style between passive_devfreq and passive_cpufreq, use common code for handling required opp property. Also remove the unneed conditional statement and unify the comment of both passive_devfreq and passive_cpufreq when getting the target frequency. Signed-off-by: Chanwoo Choi --- drivers/devfreq/governor_passive.c | 80 ++++++------------------------ 1 file changed, 15 insertions(+), 65 deletions(-) diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index 07e864509b7e..7102cb7eb30d 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -91,66 +91,17 @@ static int get_target_freq_with_devfreq(struct devfreq *devfreq, struct devfreq_passive_data *p_data = (struct devfreq_passive_data *)devfreq->data; struct devfreq *parent_devfreq = (struct devfreq *)p_data->parent; - unsigned long child_freq = ULONG_MAX; - struct dev_pm_opp *opp, *p_opp; - int i, count; - - /* - * If the devfreq device with passive governor has the specific method - * to determine the next frequency, should use the get_target_freq() - * of struct devfreq_passive_data. - */ - if (p_data->get_target_freq) - return p_data->get_target_freq(devfreq, freq); - - /* - * If the parent and passive devfreq device uses the OPP table, - * get the next frequency by using the OPP table. - */ - - /* - * - parent devfreq device uses the governors except for passive. - * - passive devfreq device uses the passive governor. - * - * Each devfreq has the OPP table. After deciding the new frequency - * from the governor of parent devfreq device, the passive governor - * need to get the index of new frequency on OPP table of parent - * device. And then the index is used for getting the suitable - * new frequency for passive devfreq device. - */ - if (!devfreq->profile || !devfreq->profile->freq_table - || devfreq->profile->max_state <= 0) - return -EINVAL; - - /* - * The passive governor have to get the correct frequency from OPP - * list of parent device. Because in this case, *freq is temporary - * value which is decided by ondemand governor. - */ - if (devfreq->opp_table && parent_devfreq->opp_table) { - p_opp = devfreq_recommended_opp(parent_devfreq->dev.parent, - freq, 0); - if (IS_ERR(p_opp)) - return PTR_ERR(p_opp); - - opp = dev_pm_opp_xlate_required_opp(parent_devfreq->opp_table, - devfreq->opp_table, p_opp); - dev_pm_opp_put(p_opp); - - if (IS_ERR(opp)) - goto no_required_opp; - - *freq = dev_pm_opp_get_freq(opp); - dev_pm_opp_put(opp); - - return 0; - } + unsigned long target_freq; + int i; + + /* Get target freq via required opps */ + target_freq = get_taget_freq_by_required_opp(parent_devfreq->dev.parent, + parent_devfreq->opp_table, + devfreq->opp_table, *freq); + if (target_freq) + goto out; -no_required_opp: - /* - * Get the OPP table's index of decided frequency by governor - * of parent device. - */ + /* Use Interpolation if required opps is not available */ for (i = 0; i < parent_devfreq->profile->max_state; i++) if (parent_devfreq->profile->freq_table[i] == *freq) break; @@ -158,16 +109,15 @@ static int get_target_freq_with_devfreq(struct devfreq *devfreq, if (i == parent_devfreq->profile->max_state) return -EINVAL; - /* Get the suitable frequency by using index of parent device. */ if (i < devfreq->profile->max_state) { - child_freq = devfreq->profile->freq_table[i]; + target_freq = devfreq->profile->freq_table[i]; } else { - count = devfreq->profile->max_state; - child_freq = devfreq->profile->freq_table[count - 1]; + i = devfreq->profile->max_state; + target_freq = devfreq->profile->freq_table[i - 1]; } - /* Return the suitable frequency for passive device. */ - *freq = child_freq; +out: + *freq = target_freq; return 0; } -- 2.17.1