From patchwork Tue Oct 28 14:38:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 5177651 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1F289C11AC for ; Tue, 28 Oct 2014 14:38:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F2F8200D6 for ; Tue, 28 Oct 2014 14:38:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B6F0A202F8 for ; Tue, 28 Oct 2014 14:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753566AbaJ1OiZ (ORCPT ); Tue, 28 Oct 2014 10:38:25 -0400 Received: from mail-la0-f54.google.com ([209.85.215.54]:56249 "EHLO mail-la0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753639AbaJ1OiY (ORCPT ); Tue, 28 Oct 2014 10:38:24 -0400 Received: by mail-la0-f54.google.com with SMTP id gm9so752821lab.13 for ; Tue, 28 Oct 2014 07:38:22 -0700 (PDT) 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=rSiliV1GcOyJAax5AL6rbJhksBUYoAlH4WX1WRMDctY=; b=Wgta2Ck8oHZwSDUHUApama9EnpppFnLc53PaYGgfErvzOUGtM2kuTXbw56Bm0bM4NH 5fgw6jtexux0rzKEid5jGyU2Y0ZN+rgEUxuA8t0O/TMy8ZIlJemDfydRnHISl/gOSmFM Y0kHrf2pPwwnfxj4aLPib1y1GDlx/0GRyGT4sicc66EZFFgwT7wDaBQb74D3HgG2lBim ndygRdccNC+fICXoQ7ug4WQPWp6fXKDgwoUz8KeCwMxFzEPcgDEelkehKPWPCja8ubjr CHLTw0m4krwulpDrRJ9pCfoLemjr3uz2nVrk1NPiGOOOUV26xycty+K5HL2CSEctPEbk AQ3w== X-Gm-Message-State: ALoCoQmejlB/4lwVi+X2nIW+4zXnQ/I4lnbA1vkEge/Zc+oT9zYZda5DrdSShE1kumR4+Qp8ecK2 X-Received: by 10.152.22.74 with SMTP id b10mr4557064laf.16.1414507102872; Tue, 28 Oct 2014 07:38:22 -0700 (PDT) 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 qg4sm680886lbb.36.2014.10.28.07.38.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Oct 2014 07:38:22 -0700 (PDT) From: Ulf Hansson To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven , Kevin Hilman , Alan Stern , Greg Kroah-Hartman , Tomasz Figa , Simon Horman , Magnus Damm , Ben Dooks , Kukjin Kim , Philipp Zabel , Mark Brown , Wolfram Sang , Russell King , Dmitry Torokhov , Jack Dai , Jinkun Hong , Aaron Lu , Sylwester Nawrocki , Ulf Hansson Subject: [PATCH 2/4] PM / Domains: Don't allow an existing generic PM domain data Date: Tue, 28 Oct 2014 15:38:08 +0100 Message-Id: <1414507090-516-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414507090-516-1-git-send-email-ulf.hansson@linaro.org> References: <1414507090-516-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=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 While adding devices to the generic PM domain we allocate data for the struct generic_pm_domain_data. Don't allow existing generic_pm_domain_data in this case, since that indicates the device is already being added from another context. Let's instead return an error. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 7546242..9d511c7 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1423,9 +1423,9 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, 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); + ret = -EINVAL; + goto out; } else { gpd_data = gpd_data_new; dev->power.subsys_data->domain_data = &gpd_data->base; @@ -1433,6 +1433,8 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (td) gpd_data->td = *td; + dev->pm_domain = &genpd->domain; + spin_unlock_irq(&dev->power.lock); if (genpd->attach_dev)