From patchwork Fri Jun 29 11:04:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 140542 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp695067ljj; Fri, 29 Jun 2018 04:04:50 -0700 (PDT) X-Received: by 2002:a19:120d:: with SMTP id h13-v6mr9873279lfi.13.1530270290617; Fri, 29 Jun 2018 04:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530270290; cv=none; d=google.com; s=arc-20160816; b=gyhSPdjAHD024S7DGooihMNd7QZNL87DXVRvAwlsoz0RAsJQNIdiCeCdkIGLUnJ9SO foea5pxcTglcPiOQunlzG/SKhyiRla746c+PxdvBUgQtWvnKQgE6xZQ6gqrN30h6vcrs tD/0EpW6qtPHq7dKSEzSvOQYusQnG+cnt3DPgyRaIPmZRghl0+yM9BjRSljSQ5MJcOQd XsLw2z6/GxZyOkEuU223dyiG8arl3Uyfd1++VvYgM6kOxcPEyo5DdYBNGSzuBA/WIZXo CNYSMreX+fsbjyxtT/x7USbMQ3PSUlc8rve6/YcLBWJ9oudXCqPy/Hp59ggwmh0cBwWU M+eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=n/200TFAI5rWvodrt4dmZF2gjgm4n0cXeaHfsLRnUBY=; b=VKiXH9GbnC9jq/tcpQQIIBzRW9RIxsKs7MImdntovdy53Ik4YSNICt3ywFnZ0bVwlv pNv+M2YA+qdVrNnLTdJ7fMcdMLijsti6xyc4+z4roCitZrHxHU9ZY3bweHTCFS19EqnZ aBsDuBjLzbUN32vacqyvQTtm/Vyj+HWFybydRjzCjySp15VSS/ozG7zdu8VUHFgGM15f vT63Tul0uYz0Z1IEQR2uK19foRrpl06FTjEHb/7rlDo39TKF7lPJuQSHBLn5F7ZeqBRA XSNQ/fjXqFCU6++bD18kmWq95M7r7QDw4AnXggdXnigxqePGh+b7P6DkTSde0aG57smY Zbww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bdHMVJsK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 2-v6sor2164724ljd.65.2018.06.29.04.04.49 for (Google Transport Security); Fri, 29 Jun 2018 04:04:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bdHMVJsK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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; bh=n/200TFAI5rWvodrt4dmZF2gjgm4n0cXeaHfsLRnUBY=; b=bdHMVJsK6XKphntS4FF5q6H1MBibMjfN2I/rVTup28TzP406UdevK7LZzBQxY1hxfF FVVCBLw7sml9e26b5zgHS6/yRrXwWfka7fjp/A9EFZH4yOmqRbiOz4MjUyu7dmHs81Eu riC6iBDJFtkXYpon4ZkE/0+fK2c5TwAhlsZqE= 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; bh=n/200TFAI5rWvodrt4dmZF2gjgm4n0cXeaHfsLRnUBY=; b=IuoOn40lJE5NuaH4Igd1oRryJ8stWZA3mZtJV1SOjNZv5m5p0ut3jNIqZD7DxWdYWM XnXqhUiNSQGnB4og+D+WgT7syjpmIoArbWZzFrOMzVQBTQ7omzepsJc3LOACRqOkOEWF Bs2RCsl30ju6DhymfVRh+p/hFruvxxo4jU5u+h/k5NLaG0FBNbdrxGvwM4oCxMv/Msde buuRP9gn6gfLDyhuhV5qiSDqrsb7m5hH0Rx46Nw1fjxTyw/bYXsEbjtLCAbtg4u/ps3D h+s+cCVOUWKtqeje/ME+nZWuPHxC/v/+4/ohaCAllSmgjXS5fyezwLBRcVe3xvZMRBpD yGPA== X-Gm-Message-State: APt69E2wWtlPi45h9GxlTHqpbFzwtqq3fSV2rDpExU8NJrfxJWKmUJP7 lR2Ul/yWoMVqv8Xs56VX/STbj3WkR5MEag== X-Google-Smtp-Source: ADUXVKKDTcoB5MwWUlKsKaePV2qfh23WpG758LAfup4nUXURRTmyUtQsz3G10hID/iM24qcIhues6g== X-Received: by 2002:a2e:9516:: with SMTP id f22-v6mr9683298ljh.9.1530270289801; Fri, 29 Jun 2018 04:04:49 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id 89-v6sm508359lfs.32.2018.06.29.04.04.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 04:04:49 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Lucas Stach , Viresh Kumar , Kevin Hilman , linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 3/3] PM / Domains: Introduce dev_pm_domain_attach_by_name() Date: Fri, 29 Jun 2018 13:04:32 +0200 Message-Id: <20180629110432.5179-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629110432.5179-1-ulf.hansson@linaro.org> References: <20180629110432.5179-1-ulf.hansson@linaro.org> For the multiple PM domain case, let's introduce a new API called dev_pm_domain_attach_by_name(). This allows a consumer driver to associate its device with one of its PM domains, by using a name based lookup. Do note that, currently it's only genpd that supports multiple PM domains per device, but dev_pm_domain_attach_by_name() can easily by extended to cover other PM domain types, if/when needed. Signed-off-by: Ulf Hansson --- drivers/base/power/common.c | 17 +++++++++++++++++ include/linux/pm_domain.h | 7 +++++++ 2 files changed, 24 insertions(+) -- 2.17.1 diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index df41b4780b3b..b413951c6abc 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -152,6 +152,23 @@ struct device *dev_pm_domain_attach_by_id(struct device *dev, } EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id); +/** + * dev_pm_domain_attach_by_name - Associate a device with one of its PM domains. + * @dev: The device used to lookup the PM domain. + * @name: The name of the PM domain. + * + * For a detailed function description, see dev_pm_domain_attach_by_id(). + */ +struct device *dev_pm_domain_attach_by_name(struct device *dev, + char *name) +{ + if (dev->pm_domain) + return ERR_PTR(-EEXIST); + + return genpd_dev_pm_attach_by_name(dev, name); +} +EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_name); + /** * dev_pm_domain_detach - Detach a device from its PM domain. * @dev: Device to detach. diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 03e14a38462d..776c546d581a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -309,6 +309,8 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) int dev_pm_domain_attach(struct device *dev, bool power_on); struct device *dev_pm_domain_attach_by_id(struct device *dev, unsigned int index); +struct device *dev_pm_domain_attach_by_name(struct device *dev, + char *name); void dev_pm_domain_detach(struct device *dev, bool power_off); void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); #else @@ -321,6 +323,11 @@ static inline struct device *dev_pm_domain_attach_by_id(struct device *dev, { return NULL; } +static inline struct device *dev_pm_domain_attach_by_name(struct device *dev, + char *name) +{ + return NULL; +} static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {} static inline void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd) {}