From patchwork Wed Jun 2 10:12:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 452487 Delivered-To: patches@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp429508jao; Wed, 2 Jun 2021 03:12:31 -0700 (PDT) X-Received: by 2002:a05:6512:2148:: with SMTP id s8mr3784156lfr.117.1622628751440; Wed, 02 Jun 2021 03:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622628751; cv=none; d=google.com; s=arc-20160816; b=PSAescZnbdJ8UfhNfV9ysCqM2/d8UBKvkKkazqfNslBXvyETSJStnq5OUj6U1b/gTy BzUXco+u01trt90kVAj/ib3wk4fm3VISIk+Zngc/fs4AR0CyaKpZjoN8oQUU198AcO2g trQ1ECIi2Up1RTyMsNrppIEJVJTI0xONeYCBUpFtnto6Fx2IV/nNQdCfkX9hir1Chy40 f/GMjU0s541EmPQkgQqFCfXzrP8QhjeBZN+aA9vlzyt8vsZu8spRjuWJXYGtAZb+kAw0 nVjqxxr5RtfK6jDAniRG5iE6Fup6lqpDqfRclvWQp4nhrQ1NudSNMm7aSMbbUs1lzzVW GmRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=hWJY2CFLHTV9te/K12aeGYAdOeh00bsaQx3awehhTns=; b=VyZDPnS9cO4916t/61oY6QY1qy4EIYGteJuo6KTy84n/B0HRHGg5s7vRL2HA4pjVGM xZzjUkOO8sAis5bh1dQ2Mcd7LIz206pFx0c0lUo8GCOxFTZrJzpmjgKI8MC9IociB0lB mdFLzw6m4040v3iTlv/MFi19XAqs8q1bHW6Mr8eeigyXjpSv3cTM1WFaBYuuedW/qltx tSxOL/zWYWKPaav/9tDB3s/uS/EkeEjvhTkrDOp7Ad8fVSRqLnXfI79TK1pN2Yu79oYq m7Fpj3bk4kSISrqji2zGPTvifQTH/NheYvU+JaLbSCzPxDrC1jDxUO8VFkeuFbd0NybQ mZtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=otscoI9p; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id h10sor8671164ljg.47.2021.06.02.03.12.31 for (Google Transport Security); Wed, 02 Jun 2021 03:12:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=otscoI9p; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=hWJY2CFLHTV9te/K12aeGYAdOeh00bsaQx3awehhTns=; b=otscoI9pFx2lrv6RxW/6Gl7A/sdHQxh3kPnxbLMMZGHhdC2it/DuwnF4MCeokvSaZz zIupfLbKOtmT4BEQ7K1IjqQUkWgfOxanvdw+SEb67ZyGIsDjCVeP6JO11fRGmgALYH+/ K3pUMG01BEnsLg4OIyMOhLm369wsjxTzXQHmKPysQtLXG9MxfFQT1KGe+16d+jwZA/nD yB/uyW5CVoiTLxd4gL7vCOqMjRGtL3D/JlGQ2rTwkfefgVRxjXwmw05VdJebQ2oSu38X Xp4JkQfw4cL0kiQgbCnUMTxPfuZ0M69DwW+Oe93PVRRDGY8LhNT9YGBKl9Tc9I6yrw41 Wd4Q== 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=hWJY2CFLHTV9te/K12aeGYAdOeh00bsaQx3awehhTns=; b=DWPu93+k20glpeWo/eQNrFbajTjhfEe4giXaiNDZXOdiQRSftAMyMxxvssQXMw9Gq7 CObM1sRJrYQIQ0pYSMbNuHe76+f3tlm0FVqgDiokQZ+3YdwJzcxL8cJdG548u7DirSrM 7f/BntBq/YEt1SK+OBxRP3cP3Y1ucO/L+zHitS/udo1WaESedNNvun5EnGUADOFesQLW PNN0ygyxkzvtSlLEHYeOt0Mod3M1k2j/oH4Mlzveo2rCVx0qhwjdINAV09i+cQBnK3/d mf/xeVNeQayhMu/jjAQ+XfhlC0d1YJKvBwOPqe/UYaJ+wJNbA01ss6BgtKXNehuUQxo4 39IQ== X-Gm-Message-State: AOAM530Nm/Je6yZzCs0Z2o+uhZBxsvKjIyYM6p01+8TFn4hbasZI6SJ2 ztiNWp32e9zetDCDk7sdX5mgrmYa X-Google-Smtp-Source: ABdhPJxYUSku4L7fSC+jpg2qG/mq4pKtA+sillsPDclxRNexC8+2QLmeOD45HAP9L6+27YKLwbnZUA== X-Received: by 2002:a2e:9083:: with SMTP id l3mr24610514ljg.315.1622628751113; Wed, 02 Jun 2021 03:12:31 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id y35sm1948938lfa.122.2021.06.02.03.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 03:12:30 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org Cc: Ulf Hansson , Dmitry Osipenko , Jonathan Hunter , Thierry Reding , Rajendra Nayak , Stephan Gerhold , Roja Rani Yarubandi , Bjorn Andersson , Vincent Guittot , Stephen Boyd , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] PM: domains: Split code in dev_pm_genpd_set_performance_state() Date: Wed, 2 Jun 2021 12:12:13 +0200 Message-Id: <20210602101215.78094-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210602101215.78094-1-ulf.hansson@linaro.org> References: <20210602101215.78094-1-ulf.hansson@linaro.org> MIME-Version: 1.0 To prepare some of the code in dev_pm_genpd_set_performance_state() to be re-used from subsequent changes, let's split it up into two functions. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) -- 2.25.1 Reviewed-by: Viresh Kumar diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index b6a782c31613..a3b6e751f366 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -379,6 +379,24 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd, return ret; } +static int genpd_set_performance_state(struct device *dev, unsigned int state) +{ + struct generic_pm_domain *genpd = dev_to_genpd(dev); + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); + unsigned int prev_state; + int ret; + + prev_state = gpd_data->performance_state; + gpd_data->performance_state = state; + + state = _genpd_reeval_performance_state(genpd, state); + ret = _genpd_set_performance_state(genpd, state, 0); + if (ret) + gpd_data->performance_state = prev_state; + + return ret; +} + /** * dev_pm_genpd_set_performance_state- Set performance state of device's power * domain. @@ -397,8 +415,6 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd, int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) { struct generic_pm_domain *genpd; - struct generic_pm_domain_data *gpd_data; - unsigned int prev; int ret; genpd = dev_to_genpd_safe(dev); @@ -410,16 +426,7 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) return -EINVAL; genpd_lock(genpd); - - gpd_data = to_gpd_data(dev->power.subsys_data->domain_data); - prev = gpd_data->performance_state; - gpd_data->performance_state = state; - - state = _genpd_reeval_performance_state(genpd, state); - ret = _genpd_set_performance_state(genpd, state, 0); - if (ret) - gpd_data->performance_state = prev; - + ret = genpd_set_performance_state(dev, state); genpd_unlock(genpd); return ret;