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: 39670 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A66FE24046 for ; Tue, 28 Oct 2014 14:38:26 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id ge10sf536123lab.5 for ; Tue, 28 Oct 2014 07:38:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=rSiliV1GcOyJAax5AL6rbJhksBUYoAlH4WX1WRMDctY=; b=E3P8736fFFJeOVhQeI5wUl+VD43cfhcrA5uHmZpM4YEy00iQrYRjjEpOyL4HkRgeT2 +EppfC5Jj1HHT0ili54OHpGGocZIgqubytquCpwDNKsi0ePIcnkbQSngbXGWjY9Yb3NM b66fpMhrJ2v7EXW6SewN/U+E4feanEABvqa4kHuhH+a1AGh/9pQ3wIFg8Ob2ng6QSCdv 9CAp83DMIAmCvcrxmI7a7VSIy3koNGkSpLaVhiieD1BvmEMAfI0gY9EEaGA2khKhY3P3 9NjOORc/FcxuvFVwTkuqH5eGLZW+g4FYV09OrXtk9SpnVy1clCWkt98TlpuLwGqxugU2 XPmw== X-Gm-Message-State: ALoCoQnvfqpzeJjKRrF9iRVooPy/RJswnHGVpmDjFVY+cfaughvPsN6wqnx1FE7jmYhxRRDXvvzo X-Received: by 10.112.48.98 with SMTP id k2mr59059lbn.15.1414507105262; Tue, 28 Oct 2014 07:38:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.227 with SMTP id e3ls70207laa.69.gmail; Tue, 28 Oct 2014 07:38:25 -0700 (PDT) X-Received: by 10.152.228.140 with SMTP id si12mr4518416lac.66.1414507105131; Tue, 28 Oct 2014 07:38:25 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id jw6si2806070lbc.101.2014.10.28.07.38.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Oct 2014 07:38:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id gm9so743700lab.4 for ; Tue, 28 Oct 2014 07:38:25 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr4438779lbc.23.1414507105055; Tue, 28 Oct 2014 07:38:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.84.229 with SMTP id c5csp492327lbz; Tue, 28 Oct 2014 07:38:24 -0700 (PDT) X-Received: by 10.152.45.2 with SMTP id i2mr4509577lam.7.1414507102999; Tue, 28 Oct 2014 07:38:22 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id qh5si2795887lbb.111.2014.10.28.07.38.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Oct 2014 07:38:22 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id hz20so758575lab.11 for ; Tue, 28 Oct 2014 07:38:22 -0700 (PDT) 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> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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)