From patchwork Mon Mar 20 09:32:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95487 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp852810qgd; Mon, 20 Mar 2017 02:34:24 -0700 (PDT) X-Received: by 10.84.193.129 with SMTP id f1mr8012086pld.63.1490002464549; Mon, 20 Mar 2017 02:34:24 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e26si11956014pfb.379.2017.03.20.02.34.24; Mon, 20 Mar 2017 02:34:24 -0700 (PDT) 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; 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 S1753755AbdCTJda (ORCPT + 23 others); Mon, 20 Mar 2017 05:33:30 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:33436 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753416AbdCTJcx (ORCPT ); Mon, 20 Mar 2017 05:32:53 -0400 Received: by mail-pf0-f181.google.com with SMTP id e129so24618962pfh.0 for ; Mon, 20 Mar 2017 02:32:52 -0700 (PDT) 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=dQuT8bm7gWUSN2fQIQ2FsDbg5lfkq36qPJFqckV+Dds=; b=PIfRmSq18RU5iJLOE/LSQR2DwFRLAefiyHXDn2Ehs64Y/j8PTrOVmtOuA6ebURNNk7 8w4ifm04UWx/iLVFxL4xF4ZGsoK458KbDRZHKQ+W4blcxn22HszLwc3hMYM2rDpntPv9 VEbIB9XG7JjmUsQgOPYH5480hBF5O2Xb1xRZU= 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=dQuT8bm7gWUSN2fQIQ2FsDbg5lfkq36qPJFqckV+Dds=; b=Dndxcdyy8+VaZifPol62FUjEhqjre/zNR/IfpDjLpfNBb2drjpAgiyHwA7EnTeEc9G WvZ+fJqafKU3eXKOIoAXGS64jEfQStaHKJUi0ih0ZxLsxZa/AETeuC3Kzb+/fuFZ6X1H ula8xFCpzUZxZdvzaZbvQsqPtrSdI2hU63IzRZThQcu1oWIov/ruFrl1v2ONeJwLZhun tTPYMHxUhe45XVi/QCi1PgW0PNbvvOEesjYcybPjbXuKc+vO77tJ2UQmW6wMxTsUKHtW Gy8zqpNlI2TCO9XatmwbSx26sMOw0N7QtxUnplxmd5SDji80qb233npSCHMLzrrYuTSl t/YQ== X-Gm-Message-State: AFeK/H0tuaf4he3E5WZBm2dpd3pKUpmB76Y/lMYb1/zGwRhN3t3mTffWm1QCWaOPtcEkMH/N X-Received: by 10.98.99.196 with SMTP id x187mr31354128pfb.168.1490002371905; Mon, 20 Mar 2017 02:32:51 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id y70sm2951417pfa.96.2017.03.20.02.32.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Mar 2017 02:32:51 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , ulf.hansson@linaro.org, Kevin Hilman , Kevin Hilman , Len Brown , Pavel Machek Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , robh+dt@kernel.org, lina.iyer@linaro.org, rnayak@codeaurora.org, Viresh Kumar Subject: [PATCH V4 8/9] PM / Domain: Add struct device to genpd Date: Mon, 20 Mar 2017 15:02:20 +0530 Message-Id: X-Mailer: git-send-email 2.12.0.432.g71c3a4f4ba37 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 a 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. Note that the of_node field of the device is only set when separate DT node is present for the power-domain, otherwise the of node is common across multiple genpd devices and filling the of_node field with it doesn't sound right. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 1 + 2 files changed, 37 insertions(+) -- 2.12.0.432.g71c3a4f4ba37 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 03dd7a61f08a..51d3afc0476d 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1536,6 +1536,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. @@ -1588,6 +1592,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); @@ -1625,6 +1641,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); @@ -1794,6 +1811,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; } } @@ -2407,3 +2425,21 @@ static void __exit pm_genpd_debug_exit(void) } __exitcall(pm_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 83795935709e..d55c0112dcde 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -47,6 +47,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 */