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: 43844 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4D7AE23FFF for ; Tue, 27 Jan 2015 20:14:20 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id b6sf8845059lbj.0 for ; Tue, 27 Jan 2015 12:14:18 -0800 (PST) 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=K5pNrcO12iYJkzIykTxjmExk1LYkX7XOFy7Tcjkd5Z0=; b=HgkkkG4X23HSkpvL7uOvMVFUWbVfqa944je5E8AHFIdTEWQEMv2PbgRXTMH/txPRn5 49GkqwXcSilCeUiAuHHO3jit3OjJqwqIcJzzo243WPGoLXexUvlTTljb0nve/d8htbwp 2DBh6rc4OHNPQXzZOTJ4jpSQTe6vwIaEhyDNT8UGP4eGnTS2i0HIp8fPVe5nPL82lOHv i2eyK/SPZluL+TQEeyOPvEnQzcKRjurej+1QpwW12NIfCXNEvXxmACoFHg6tHaETLUoc DWCbOzHazRM7MyaUVEZVHdK0Zaa/RWP6Pf/2uj1dOWeYlEZV9dRa93Z390qDp3W+Hqde FhHQ== X-Gm-Message-State: ALoCoQlCEVH6WT4yk/jkFW9Ph0KX+gREoE0rfERiOv4dasZyYlRvybeZLFJ3euCpwPCtuCqyH5U5 X-Received: by 10.180.13.83 with SMTP id f19mr718451wic.7.1422389658939; Tue, 27 Jan 2015 12:14:18 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.66 with SMTP id u2ls87540lal.32.gmail; Tue, 27 Jan 2015 12:14:18 -0800 (PST) X-Received: by 10.152.5.132 with SMTP id s4mr3917121las.39.1422389658786; Tue, 27 Jan 2015 12:14:18 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id lu3si2321876lac.6.2015.01.27.12.14.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 12:14:18 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id s18so15400122lam.3 for ; Tue, 27 Jan 2015 12:14:18 -0800 (PST) X-Received: by 10.152.197.5 with SMTP id iq5mr4011359lac.6.1422389658725; Tue, 27 Jan 2015 12:14:18 -0800 (PST) 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.35.133 with SMTP id h5csp1213794lbj; Tue, 27 Jan 2015 12:14:18 -0800 (PST) X-Received: by 10.152.7.7 with SMTP id f7mr3682466laa.27.1422389650570; Tue, 27 Jan 2015 12:14:10 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id tv7si2257824lbb.83.2015.01.27.12.14.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 12:14:10 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id p9so15082683lbv.8 for ; Tue, 27 Jan 2015 12:14:10 -0800 (PST) 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> 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.44 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: , 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);