From patchwork Thu Apr 18 10:27:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162455 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp563514jan; Thu, 18 Apr 2019 03:28:07 -0700 (PDT) X-Received: by 2002:a2e:8ec5:: with SMTP id e5mr40823545ljl.7.1555583287434; Thu, 18 Apr 2019 03:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555583287; cv=none; d=google.com; s=arc-20160816; b=vd/UqMQRowmwvahQOaE5dC0LoR1Pmk3zBPexAOptqQ5pcnFYd0euwEOMf+KK11qgHR 3PAVypsTLfLITjRCgpgnEkyF/mzVcyq/IDS3JsbOqH9bGYvSp0YZqONs624sCfJeIF/W q7/y2+Fbws23/KHJDvZ+eXjPhpSpEoppW0A/WUD4xRL1h6rQHaH26szFt9DCVGpc0cLH HEYZY2D5JfGXRRrrg0VOAj6EsUNk6ZPL1S9cw3Ew5rgp6Yg1spPlO5+ujwXpJkIlsAKx Hse3q9hZCe9W00xvw5CgtUkCnK/E1Q9FExXhBjO/ddRgeZHjdaVNPzhmWeySpKDBeIap MW6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wafwrLwOuLKydkAOyUifP9IzxQmxoflkxenKIZVDVeM=; b=DBbvSMagmCL24/8ounj/3HZWzMyYIrtH8OuYV10RXhjES1MHAkHZXXcchC/NaojIfA zuRIrEVRemfBIvdlKfVQGPvXUeW/p4fFG5/GZSXZf4Qoly4Ns/4OpkqNR/QhSphrlMfT 8IcaMDjggZuo2Ffs7amLalL9iiXxmDy0Q89bMIL14cVI8hWyWoBh/qaDfYFpHAsdHwr5 bL09/6fhiS7ovEZERetJWFrmUaT0RV2GwJufUHsSgOheDVi5YvApymgYUHtMd3urEGrY mkrsbgmTwM2Qh9/snAc/RBKzFj/3XJJpWHB1TQZQL/hr9nKamrBeGZcEcqLibPvG0WRD zkkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K9Sn5ca6; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d20sor818712lji.12.2019.04.18.03.28.07 for (Google Transport Security); Thu, 18 Apr 2019 03:28:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K9Sn5ca6; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=OPl7JFJGiSSsS3FGmqY1+PrUbXqemfBoIEoFdA/HbWd4UDtTI4s884yrdS2UtKxx8L Wto+pAaDQr5FnfEEN1QdnSDs3VSUxcc8030QL/ASZBGKlten7H/u/mrs7n6eO5AsrESA vs5q7E9RlxljKW2TvKv2nYJrG940TDgu/PZu1SQmLRZ9esacew+h46Nil6euped7KYIG mXbzmtIjaBSSguIR6dQCON7e2AD9fm7QIgW/Zqjbu42fDdxCj+B3nSKIDbtTm8iHNC5j Iyv5FZHSasm64EAf6Y8CNVDwpaWoYp/mY6BNYG4Y7kMoimAkQPvxK1daU0H6WPSialb8 oE8w== X-Gm-Message-State: APjAAAXouUXhClgxsVFAKWg0NovvUZIRWcVUjU1iS0pc/JAiJeQgLWMT cNFiA55RKtwwK/2NltNEOWoCjSNa X-Google-Smtp-Source: APXvYqx8DZQj9MIb9HjHiAJTg3ChuW8LvgA8jYMtqeuoPHn2n+vFcwnvvMiE9fHrTl1DCQzJpnEXyw== X-Received: by 2002:a2e:3207:: with SMTP id y7mr133196ljy.117.1555583287085; Thu, 18 Apr 2019 03:28:07 -0700 (PDT) Return-Path: 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> 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(-) -- 2.17.1 Acked-by: Viresh Kumar 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. */