From patchwork Tue Jan 27 20:13:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 5720131 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 04F7F9F2ED for ; Tue, 27 Jan 2015 20:14:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 29FE320253 for ; Tue, 27 Jan 2015 20:14:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC7AA20256 for ; Tue, 27 Jan 2015 20:14:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759605AbbA0UON (ORCPT ); Tue, 27 Jan 2015 15:14:13 -0500 Received: from mail-lb0-f181.google.com ([209.85.217.181]:58978 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754100AbbA0UOM (ORCPT ); Tue, 27 Jan 2015 15:14:12 -0500 Received: by mail-lb0-f181.google.com with SMTP id u10so15086116lbd.12 for ; Tue, 27 Jan 2015 12:14:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K5pNrcO12iYJkzIykTxjmExk1LYkX7XOFy7Tcjkd5Z0=; b=WVNG8qwMitBtm8z8VmA+5FwBIHFFU7/I80Z0JDGugCkgqksrWbspldDF/V5SWVS9gl yiapdAaKHdPZD07g+ub53ARDBOR/NUwM7zOIZ9nkoAvJUA1r7uNtDxlit0UB69izXAzz s1ggsvOnl0YOnVmwKGXo+FInhksOGIPC6Rwwj8ozwnEqZxHiYLSeI5w6Ri5reTZFqKgV lxjX9jveFjeJ2fg5cv7lu9F+NHSw8mDpHEtULt83bu+Wa/KeHqF1ih5BBofp68r04jNZ DDqHcnMeqPik/jpp3qqecuy2O6DzT0ci68R/JsHsuw9Ii5qo8GK72E6fbZjOwTY+udk9 eogQ== X-Gm-Message-State: ALoCoQkD6FVqMEoXtCM7eVT8f4FlqwQB6WpxJzCBoUjs6FaT4KMqBi4FeQUGOOWw8dXzks1MXN6I X-Received: by 10.112.202.195 with SMTP id kk3mr3759169lbc.53.1422389650477; Tue, 27 Jan 2015 12:14:10 -0800 (PST) Received: from uffe-Latitude-E6430s.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id ya4sm713470lbb.32.2015.01.27.12.14.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jan 2015 12:14:09 -0800 (PST) From: Ulf Hansson To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Kevin Hilman , linux-pm@vger.kernel.org Cc: Geert Uytterhoeven , Dmitry Torokhov , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH 3/8] PM / Domains: Don't allow an existing generic_pm_domain_data Date: Tue, 27 Jan 2015 21:13:40 +0100 Message-Id: <1422389625-11730-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422389625-11730-1-git-send-email-ulf.hansson@linaro.org> References: <1422389625-11730-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When adding a device to a genpd, a struct generic_pm_domain_data is allocated per device. Verify that there are no existing generic_pm_domain_data for the device we are about to add, since that tells us it has already been added to a genpd. When genpd supported PM domain device callbacks, this was a valid scenario. Now it isn't so let's return an error code. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 351df5b..76eb0c3 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1444,26 +1444,30 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (ret) goto out; - genpd->device_count++; - genpd->max_off_time_changed = true; - spin_lock_irq(&dev->power.lock); - dev->pm_domain = &genpd->domain; if (dev->power.subsys_data->domain_data) { - gpd_data = to_gpd_data(dev->power.subsys_data->domain_data); - } else { - gpd_data = gpd_data_new; - dev->power.subsys_data->domain_data = &gpd_data->base; + spin_unlock_irq(&dev->power.lock); + ret = -EINVAL; + goto out; } + + gpd_data = gpd_data_new; + dev->power.subsys_data->domain_data = &gpd_data->base; + if (td) gpd_data->td = *td; + dev->pm_domain = &genpd->domain; + spin_unlock_irq(&dev->power.lock); if (genpd->attach_dev) genpd->attach_dev(genpd, dev); + genpd->device_count++; + genpd->max_off_time_changed = true; + mutex_lock(&gpd_data->lock); gpd_data->base.dev = dev; list_add_tail(&gpd_data->base.list_node, &genpd->dev_list);