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: 10906975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 951601390 for ; Thu, 18 Apr 2019 10:28:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76B1E28B68 for ; Thu, 18 Apr 2019 10:28:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AB5C28C4D; Thu, 18 Apr 2019 10:28:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1AD5228B68 for ; Thu, 18 Apr 2019 10:28:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=VvMUe6Q85nBVHbzp8sqfEcid1uhvl31FnSWyS+Mkln0=; b=JRODgEoguBma8YSFWeDWLELViX +ANqXK3evtZjVcn/3gJsV3DrnYWsX4pCrmDeKnW8I2xB9I96p8L1R6OMpKb8vDybl1wbXipRTkqf4 d8Xh4nnREus4llqmxaLLAZhyaZNJmWfjuloMPmdyrsA2brxmtetg6pLbwwZBiFvgTFDmy1W7qBFqL a9lb+ro2TO5WlggiRrKKHBobTCUiouPUbvabe6pWO2O8DeYWs/hD3bPM9gre2UNDWT6rOXgi7cim2 YCzwS37JDL2pHAx5s2yVs4QCjnEPffduk2SbvXleiocyVOqkYz054kzqIWTvd/AmWacJRi+k6GmNR fMUj7wKw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hH4Hl-000071-NO; Thu, 18 Apr 2019 10:28:53 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hH4H2-0007lO-SO for linux-arm-kernel@lists.infradead.org; Thu, 18 Apr 2019 10:28:10 +0000 Received: by mail-lj1-x244.google.com with SMTP id f23so1494112ljc.0 for ; Thu, 18 Apr 2019 03:28:08 -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=tw2MTQrWVV2txzTcCOXM+wUocYdDjMSJ+hRYwSejnND7Td3Oesbxe55d1q6KAtdgol X1cdJSCEv4le68/Hbc8s3KZObAwUxJ5lDX9KLAciqH6eDexq///1UWIH4icsJxqmnX5n 6FKMHRLjXNAMoPbW6d0kC822CERzul9HYjebPJOIm3pd6kL2h1ZiyPV5GZZTZA00jhdX 5hj78ezgn56FpCIDbUnY+HO89ijo3IOKBmAU5sjhHytrqM7F24sqdASdg2YFZUdR9Iuq weuajJ0LJif8CkCNf1oxXc7X5pWzIGIELymr/GyEtW3htp9Fp+HM1Mu3LzPUuP/u8WuK rjrw== X-Gm-Message-State: APjAAAXBYXoMfB0tTJxYLulid9ZHZLKGgOMNE55/0yWYfGLC7Pr/c0rX FQt3ZHdqGke8fPzSs4w0XK7+AA== 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) 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190418_032808_914774_D89ECC4F X-CRM114-Status: GOOD ( 14.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Rajendra Nayak , Kevin Hilman , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Jon Hunter , Viresh Kumar , Niklas Cassel , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Viresh Kumar Acked-by: Niklas Cassel --- 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. */