From patchwork Thu Jun 3 09:34:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 453238 Delivered-To: patches@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp114816jao; Thu, 3 Jun 2021 02:34:47 -0700 (PDT) X-Received: by 2002:a19:691e:: with SMTP id e30mr25466992lfc.302.1622712887298; Thu, 03 Jun 2021 02:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622712887; cv=none; d=google.com; s=arc-20160816; b=xAtqwDn2UJWJeZb+OFirAix+4q4rjjZkWVrZ9sH6WyUAQ6+Jiu+SgpEa+LGn7UYyns /q4qNZ4hQRQ5V/upBygRE0u8Tg+OCM9qH+N+0huPuOItxhCsf9vHqzz1Koh6npmHaH+Q FeYLvPi9KnPcOhjSCjrAd5Lg3u1wcM7pQWN38AGqNz9MAMCpKx5vRbZHJLHel4ksNtfm wDpcyV6b0CEpVUspIh57V9aHuz8djDAKuiL6v5iIVs5u8IkhWAr9xT8f3CxNMnKy5auT FA+jUGzj6OOGEpr9wvRiFhSLvWztBybMCnI530XTkzNcufONrKZAHlfrQzwcxKWZe2xT 8Ifg== 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=4rVASeO6Y6OcFufLMrsc56Y+VubvwdMfYIrrp6oq4r4=; b=IVWzeIDvmtj6KEZOLUrylR+NCCP+EJB5IaBn+1cKPNeNnDkjz5G9UUqmr3LkAhXFwb mPCl08tpzel+8Oj7s6WiqKpiYeN0P4MY4O0C4By3du3mW9z6egCVMxioCSdAWuy6UPOX 3SLeEy8Ufk70ylxJCDqTcwiKkFQlDhNBW8nQ7dQ+BmnOIYCmp38Ah4s2437XEBJ6iDmn +Ow1o4Gb3lmN1fbb73YRXhFrFSMNTJUly/BPdwvMewQY6omhMtn1eFs6P+re68WATzgl 5+0EC0wM4WJYXkkfX2UnziLU8VtV8Wk1L3pZJ2U/BAclRdyH2MQigJ0605qDbD96BJxf A10g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ttTV9dS3; 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 e26sor512285lfn.128.2021.06.03.02.34.47 for (Google Transport Security); Thu, 03 Jun 2021 02:34:47 -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=ttTV9dS3; 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=4rVASeO6Y6OcFufLMrsc56Y+VubvwdMfYIrrp6oq4r4=; b=ttTV9dS3FVDeh8gdxlsfE9fqeYyL4RbcrkOc2YpayXaxhjHVSYzHdSkYf8gZGF03ao FTogbxZRc6drk/Se9oX7peJvwggvDgXeGtDkyw/3Xv08d9EXgUxfFAxWP7R44czFhBxy YRp8d1xzO9W2w2WTbeLM/SXB4WmVUNrPmKHSY+ytmhEPVMbT1SAjeWGwL5t2SWQJjQuO EtV3pNVRyEYfFSK8vxVt+DnxeT0KTLj7s7EYNRrVYfL+2GZ7WUeOnjOue+Sp5vkkozMK JpZ6S/xnkX2a8JkxH42ozOzEKXBVmz9TURd2ykPpNXhzqc0krruQGo/0dWSw05UgWUqD SW2Q== 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=4rVASeO6Y6OcFufLMrsc56Y+VubvwdMfYIrrp6oq4r4=; b=g1dkzbMsiVYR4+Jc9S4T6szssYP8hjb0zVQC2nBdBDLunc1yVKuGMqbCTJ5g18L+jh zgUJolhPBE6Q9d1j9lYlna0HX6m4V/Z1qeEm/5V5O6wY/ysqvT0z/WXB1gnrQbi1OEvG CQb2MeWaAhaLdPbv6KkJLbYcJQ8perXs8Y7kgwzHdHwfIcopmjExXk8ThpDJOqx6tgHJ cIbyT5PIR4hzzbX9qLOAdVDNk/LLtdxfsE7tAol8LeW7MvgvnhsSGtdzXsbR40bfK7fF V+XXdDO67/eF5tiIapJi+2WDHK2RPV7HoPmmWHERUAt6E0VCfZco1pypCYL0QZPLVF/6 tMhg== X-Gm-Message-State: AOAM531NvniorGQYoadMUVo+MEeWF83L/hC4M/n5D2U2wAnsNU22NUJs xXsOqk+OyonCRZFMs4xbwGCNP03G X-Google-Smtp-Source: ABdhPJwTfUiqI1PTAa4Ti9ScSuSpJMZh9fZH533X9DuesqyiUwYZtT+W7JazvFs90129yoD0c46yiQ== X-Received: by 2002:ac2:5a4b:: with SMTP id r11mr18051551lfn.338.1622712886936; Thu, 03 Jun 2021 02:34:46 -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 q4sm263373lfc.172.2021.06.03.02.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 02:34:45 -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 v2 1/4] PM: domains: Split code in dev_pm_genpd_set_performance_state() Date: Thu, 3 Jun 2021 11:34:35 +0200 Message-Id: <20210603093438.138705-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210603093438.138705-1-ulf.hansson@linaro.org> References: <20210603093438.138705-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. Reviewed-by: Viresh Kumar Signed-off-by: Ulf Hansson --- Changes in v2: - A small cosmetic update and added Viresh's tag. --- drivers/base/power/domain.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) -- 2.25.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index b6a782c31613..5c476ed1c6c9 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;