From patchwork Fri Dec 22 07:26:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 122629 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1908822qgn; Thu, 21 Dec 2017 23:30:32 -0800 (PST) X-Google-Smtp-Source: ACJfBos4AthxNKGnKDa6Ku+a9JdQjcuM7Dt2H0rFTw+f5RGGme2MBO7nifWef8/GcvcFNFgxPVSm X-Received: by 10.99.49.75 with SMTP id x72mr12226019pgx.123.1513927831919; Thu, 21 Dec 2017 23:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513927831; cv=none; d=google.com; s=arc-20160816; b=irxbMZLqDqWf/6Brh6z6c5YOywKLUSqTpgaWeAyHnp5+IA+08rzj847UbfvhdAsHEo u2/e/mO5iVTGjgy5s6qBM0naZGa6HyJPCz7mOWSWDF9repbk14a6udJ+9vW7leoVw4za IBkKwoaBQ0GMVY+lvNv1As4FoxKs+VELXAQcfK48/gGGd9fEJCSNy8W9aI79SUXIuSjk t5xaXuvoX49CyQhBKmGZjj2j+LGmd9Z/MMbYGq3UU4SOGogHxIApnwTEh+YRYEI7PQS5 tm4CLS1q0NnlJOKTSCN8NCdFlVv81Gi85/O4hB5P6TmRzC2gG3sTrHqG1EaUvp+NySCw hpGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=zl+NeZIFEqERsvHNx/Vffb2UiLVHPv9RPXU3IpDG0zA=; b=INM+3o1F6rdTYELES3NKPiqsxd7178fTjltwUDlmIQAnu9LjkUMa9X1UH1rF2UPkVL r61JlMlzzwSKClv1pgjv5rgtl1/W5MFVTDSuhoy2Ky8H/nx4OL9FaFqDih+YrS+THcvW 0a8kfAwl2ItlQQWl0K53J5OVL86HkdmZKY72XiA8mhrxZrtlXljrabvqHou2xyXE/DKZ pIdsReLudvwDQvwFdUYy36Zbxz01l2dobrtwETRkxNPiFJwNmGhFz93DvKryvXb6CBrn 3aQCErAWb8TBF1HeeMjJIPonX3/huYQsK9qJIFiZ4LDqdD1Q/W1ufv/lnjXpeYGNUhfp Msgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VuMUGmn/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i187si8044784pgc.532.2017.12.21.23.30.31; Thu, 21 Dec 2017 23:30:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VuMUGmn/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755379AbdLVHa2 (ORCPT + 28 others); Fri, 22 Dec 2017 02:30:28 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:44268 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753856AbdLVHaX (ORCPT ); Fri, 22 Dec 2017 02:30:23 -0500 Received: by mail-pg0-f67.google.com with SMTP id j9so14210182pgc.11 for ; Thu, 21 Dec 2017 23:30:23 -0800 (PST) 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 :in-reply-to:references; bh=zl+NeZIFEqERsvHNx/Vffb2UiLVHPv9RPXU3IpDG0zA=; b=VuMUGmn/Uukfy2iRWglTHqivgb5MhaYH1Nm7QFdkg4WdnDCyZejweyfCn6bTjqmbsv TIz393f33gqn3h/n7B9Y8GLqljfWr14akcJLgjT4Jl3lx3pZZHzccniqOBG4tZenv4uF nha+EGczs/LP+Gj04Mv8cctMG1mQyyK04zBEk= 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:in-reply-to:references; bh=zl+NeZIFEqERsvHNx/Vffb2UiLVHPv9RPXU3IpDG0zA=; b=AbFKg4mJGu0Oc1n/h2i67wuMfQw9KRwqrJ7chjyjv+adxax8dw+nXNLSm2pv51CAla +8v+7vMp5R4Yd65YhJCiSVBMQ53jJuRpBEeriqsZmwz5C7tRipi3vTO7YWaY8ed1Qr6I QGChSp0+2y926cmqtWTOUqNU/ATCk1y9utJs8LU0791DrO1Tfe9jQYMHTsKJvXnc4rIu ohA2VP+imk+zApDNdVQGwWd7YrthSP1btBkE04owKCJtOeyPYhDRWWArE7Uy6VkKy/r9 Nh3H0o9XyUh7LPkCxDellEM51VV9z0OIKvsY9uiAheEtfMUy8ZS4VIT4bbkcLltfbuQZ k1Fg== X-Gm-Message-State: AKGB3mJ7KDjUDI6G03shWMsR+R1l4em7g212YKBB52/moftLgHsZLOCz JxP8NmrZmbTApjeQw+lONExX/Q== X-Received: by 10.99.67.195 with SMTP id q186mr12060314pga.163.1513927822859; Thu, 21 Dec 2017 23:30:22 -0800 (PST) Received: from localhost ([122.172.139.116]) by smtp.gmail.com with ESMTPSA id u6sm43969698pfk.126.2017.12.21.23.30.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2017 23:30:22 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Kevin Hilman , "Rafael J. Wysocki" , Len Brown , Pavel Machek Cc: Viresh Kumar , linux-pm@vger.kernel.org, Stephen Boyd , Nishanth Menon , Vincent Guittot , robh+dt@kernel.org, rnayak@codeaurora.org, sudeep.holla@arm.com, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] PM / Domain: Add struct device to genpd Date: Fri, 22 Dec 2017 12:56:27 +0530 Message-Id: X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The power-domain core would be using the OPP core going forward and the OPP core has the basic requirement of a device structure for its working. Add a struct device to the genpd structure and also add a genpd bus type for the devices. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 1 + 2 files changed, 38 insertions(+) -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 0c80bea05bcb..013c1e206167 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1630,6 +1630,10 @@ static void genpd_lock_init(struct generic_pm_domain *genpd) } } +static struct bus_type genpd_bus_type = { + .name = "genpd", +}; + /** * pm_genpd_init - Initialize a generic I/O PM domain object. * @genpd: PM domain object to initialize. @@ -1687,6 +1691,18 @@ int pm_genpd_init(struct generic_pm_domain *genpd, return ret; } + genpd->dev.bus = &genpd_bus_type; + device_initialize(&genpd->dev); + dev_set_name(&genpd->dev, "%s", genpd->name); + + ret = device_add(&genpd->dev); + if (ret) { + dev_err(&genpd->dev, "failed to add device: %d\n", ret); + put_device(&genpd->dev); + kfree(genpd->free); + return ret; + } + mutex_lock(&gpd_list_lock); list_add(&genpd->gpd_list_node, &gpd_list); mutex_unlock(&gpd_list_lock); @@ -1724,6 +1740,7 @@ static int genpd_remove(struct generic_pm_domain *genpd) list_del(&genpd->gpd_list_node); genpd_unlock(genpd); + device_del(&genpd->dev); cancel_work_sync(&genpd->power_off_work); kfree(genpd->free); pr_debug("%s: removed %s\n", __func__, genpd->name); @@ -1888,6 +1905,7 @@ int of_genpd_add_provider_simple(struct device_node *np, if (!ret) { genpd->provider = &np->fwnode; genpd->has_provider = true; + genpd->dev.of_node = np; } } @@ -1924,6 +1942,7 @@ int of_genpd_add_provider_onecell(struct device_node *np, data->domains[i]->provider = &np->fwnode; data->domains[i]->has_provider = true; + data->domains[i]->dev.of_node = np; } ret = genpd_add_provider(np, data->xlate, data); @@ -2691,3 +2710,21 @@ static void __exit genpd_debug_exit(void) } __exitcall(genpd_debug_exit); #endif /* CONFIG_DEBUG_FS */ + +static int __init pm_genpd_core_init(void) +{ + int ret; + + ret = bus_register(&genpd_bus_type); + if (ret) + pr_err("bus_register failed (%d)\n", ret); + + return ret; +} +pure_initcall(pm_genpd_core_init); + +static void __exit pm_genpd_core_exit(void) +{ + bus_unregister(&genpd_bus_type); +} +__exitcall(pm_genpd_core_exit); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 04dbef9847d3..aaacaa35005d 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -49,6 +49,7 @@ struct genpd_power_state { struct genpd_lock_ops; struct generic_pm_domain { + struct device dev; struct dev_pm_domain domain; /* PM domain operations */ struct list_head gpd_list_node; /* Node in the global PM domains list */ struct list_head master_links; /* Links with PM domain as a master */