Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp411930yba; Thu, 18 Apr 2019 03:30:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8RUegxCLT/r1xdiPBz5eBjJ/47OwVEuai94+n8wDCyVLe5UVUb5AgFWyC0n1X/RHG55V0 X-Received: by 2002:a62:ae13:: with SMTP id q19mr95841276pff.152.1555583452674; Thu, 18 Apr 2019 03:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555583452; cv=none; d=google.com; s=arc-20160816; b=nbcOAexXRV/QW7JlEbyuTavqW+dIVuwMl38H3kONJgOwtIjW/Rx6oUDWEJ3teRdJfF U8m+sSboVO+zehUe2n9mvIs/TX9suQ39Ct71UTGGJxRjLDOMK+OuUn7MDbcEyxVJt3Ri oF4qsK6vVdIFE0vdBn38NXrmvsj4CLE8YOUM7Fwti1QN+RXZ3YENBNxlOIybdTU/+RXV vP19eLFWeMkV0dp6aCA0f4BpUdFWZf0nQ4pY5YJE8ehNUsCJawURmEyfqoKfjjPMTctd hyJ3dkSaMc0boxRbkY0+L64dfkTwkKnSI9dIOgxq2F2k8vPiay7JorYtoZT7GU7utrV+ UUJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=wafwrLwOuLKydkAOyUifP9IzxQmxoflkxenKIZVDVeM=; b=nNJiJRnK+p3TPmd+Mof+OMrTCmzN4ZZSC5KkFa7mO8xVd8a/ko7mZ9Z9voYo1NtfpN CEfWWyrh57aHZM652PGtQqz+s5Yii9GnsWh8tKyo1AOZAnYdo3U99rUTzSYH8jzrwLPh CzUmygB/sscybxs8BUeC4De3ZoEYMZGr7p2jgruE8h9H0yXj4YAaTXOwQU8/ioNmh6Pc bIaGWxzKv/3d3CLuopoUFocSNLNwgjsxUg5D9KvHlNKRo+ZxjwoYHbQcs5Qa1B3+K9sl OGdsEsVTysuruG05ypfHHDH1NBCcvTuFKSGB31CpFXvlwbAVWvyRO/Vfb9rorcpVY3BF mMkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K9Sn5ca6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10si1749675plp.130.2019.04.18.03.30.37; Thu, 18 Apr 2019 03:30:52 -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 header.s=google header.b=K9Sn5ca6; 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 S2388763AbfDRK2O (ORCPT + 99 others); Thu, 18 Apr 2019 06:28:14 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:43206 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388690AbfDRK2J (ORCPT ); Thu, 18 Apr 2019 06:28:09 -0400 Received: by mail-lj1-f195.google.com with SMTP id f18so1448938lja.10 for ; Thu, 18 Apr 2019 03:28:07 -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; bh=wafwrLwOuLKydkAOyUifP9IzxQmxoflkxenKIZVDVeM=; b=K9Sn5ca6TLeYDzKn/bN0TDe+nBCMyuOLBWUuArQo7+dzpUKJpvn2vC/VHvLutr05HY jRRNPoWivQlbL/nj01AJEJxNa7KKC7mKk5VBoI2GH1i0Dkmyp065vuviSSdxEWPSEb1p FSlMikftkKCT4Wf2/u7AIPrWhj3FNe+CUXvvnYQdRbVhIt3gRVotEnbHjwT0o0xpb02j iYFLKdVcNVc9w07qzKTzTVJSrHgwGOcD0lj+Z9VOR+PxqmbhiPAG+2rvvcyWmB4847PA u5jTfl35ZCmk5DxVBm/itv5LnmOIFEpQOB2jD9VC0KoURpTWIms4TuJJfE6XYSv+plo/ gZIA== 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; bh=wafwrLwOuLKydkAOyUifP9IzxQmxoflkxenKIZVDVeM=; b=RHdYF2xIcC3j2iIHjAVKKCB7cJX7TdoOcKNTOeEuROPcQbVRVLxdmeuXo5LMtX1wD8 svkxohe+C6pCkFCsixFM7kWwlqqSrttc44SUpQtn4XyEK36zExM6aF7b6GIfiV6NsUt8 y6ycYgXW9rIBdk86FbkscdcJKVhag71wti6S1Vd/oK8/NA+DlMCtjl/szHSlqbnDlYo8 krbpXzWZN2B6QwXVaf9Fl4//j+UQrUfT2n0M9fHZfh2y0D5DYBDn0t/3jvaTnh17ZXyo qmV60mdhqYyVqjWy2kUa11oauwajiQVhahA0RlOEShEZa5OjVuMlxq6iYLBaDv4Ectk8 Vv7w== X-Gm-Message-State: APjAAAWTlM3u3CVZl0mKPVROpXRdZ5XKHy67WIw7mj9LkEF16n4Y21Oa 52f4Fq4k67CcIXZEwqpTlBpgLw== X-Received: by 2002:a2e:3207:: with SMTP id y7mr133196ljy.117.1555583287085; Thu, 18 Apr 2019 03:28:07 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id l13sm320409ljj.96.2019.04.18.03.28.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 03:28:06 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Greg Kroah-Hartman , Jon Hunter , Rajendra Nayak , Viresh Kumar , Niklas Cassel , Kevin Hilman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] PM / Domains: Enable genpd_dev_pm_attach_by_id|name() for single PM domain Date: Thu, 18 Apr 2019 12:27:57 +0200 Message-Id: <20190418102757.1246-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190418102757.1246-1-ulf.hansson@linaro.org> References: <20190418102757.1246-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a call to dev_pm_domain_attach() succeeds to attach a device to its single PM domain, the important point is to prevent following calls to dev_pm_domain_attach_by_name|id() to fail. This is managed by checking the dev->pm_domain pointer and then return -EEXIST, rather than continue calling genpd_dev_pm_attach_by_id|name(). For this reason, let's enable genpd_dev_pm_attach_by_id|name() to be used for also single PM domains. This simplifies for future users to solely make use of dev_pm_domain_attach_by_id|name() rather than having to combine it with dev_pm_domain_attach(). Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 801f31c87d16..1b026704a8fc 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2512,10 +2512,10 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, if (!dev->of_node) return NULL; - /* Deal only with devices using multiple PM domains. */ + /* Verify that the index is within a valid range. */ num_domains = of_count_phandle_with_args(dev->of_node, "power-domains", "#power-domain-cells"); - if (num_domains < 2 || index >= num_domains) + if (index >= num_domains) return NULL; /* Allocate and register device on the genpd bus. */ -- 2.17.1