From patchwork Thu Apr 18 10:27:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162453 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp563466jan; Thu, 18 Apr 2019 03:28:04 -0700 (PDT) X-Received: by 2002:a2e:4ca:: with SMTP id a71mr50776008ljf.39.1555583284788; Thu, 18 Apr 2019 03:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555583284; cv=none; d=google.com; s=arc-20160816; b=NIak2ihRXzBrTxtGj4K8d3Tg2ADPdkXm0OJp8Co4GoTDOedsZEkM64OiNhNoQAj69J xIvxIrAxRfOkG4f3vmdlb8nmM6Jogzu5CnfCtUvWKl5vhJd9hMPRGKmwSJJb/2HminLU a0iIBaqfj6e2dG8e9Jr0WS9uEYJehAK3/+zYhFDkcJzydOjnQT5vnsTzyXkZzCY9xe8F WbbIPtc4eoLJV/LTgXqm20edUdWpCVC18atwbG9dpfQWhHkpB2FplvZqKxziTAo1ut3l W+cCN/3CqWz/t9W9UoVcabQARBjoX8NdCIu4SQsL+NyycD5a0YsrpYFTTwEjv7L5CdJd zqGw== 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=b4/z3HQphjEsvzH3BgLLETGidZtveaIsWYroUmoxADE=; b=NPVfneZIqJERmCTIGn46NM6Qzw1LWFL4HdhEu9W5dvooG/FJJALwn6MxfkLjDgy85W RMCAFdcKjgn5JbsklhgstwNYKQopM3XnC74k96tkCFvCv6a5j2jY3YDC70S/4aS/oBL7 QU+PwSnlZH/MTKXo14sB0dnOnE4bm+tlKJ3lt39lIargxuVNcqa8oh8aIZQ1UZSXebHF fMtEnwE0piHHGcFwYc7WKtUspkFAX4mdhbUEzmCho6dsseDf1fAYYBdnzMQoa+f/GLRn g4/wOi9AIbd/DUt3nX297h6R4FPMknC4Lyb1qNn6idhg2OoywI8VfCdRegT2DWSRuoq3 VXbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dqCViXMV; 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 e8sor811710ljk.39.2019.04.18.03.28.04 for (Google Transport Security); Thu, 18 Apr 2019 03:28:04 -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=dqCViXMV; 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=b4/z3HQphjEsvzH3BgLLETGidZtveaIsWYroUmoxADE=; b=dqCViXMVuDoEwPYSCRyR3gFK2YRd4ueBMYYsoKTDZBk8/sNQkdFgQyT1ulkoSxCdGD iAhP8JNaZwj2TCmXl4f7ZzxEBDd92pX2a3LfqUSWUStUGvg2OeFOK61rFvWTIAyj626k rIrTAHEyRISdxXMPD4TfZNgc9IfKh1Yw6kYNGVf7DZKue9bcPUal+pbuBTdioRI5UYzQ g2s6uRAlhuMFHEZy5QD79ISiwzLfRgqYfdl5sPwWyty5j7YnpeEl9aTv2FrzmZav7vqB B8UbnnltODguhp/+BwLPZyxW6LL/Kai69tJ4yKtrwHIGTv7TVRk6kdHzYn+nmUzxnAVO gZWw== 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=b4/z3HQphjEsvzH3BgLLETGidZtveaIsWYroUmoxADE=; b=WYbQJ9knL3jC9edgDypr+5AR1vpXiS8rlGSm+sVj8Sf/7DAQ0c//2lEyasMyTV8ZrF yZGNac4BNvxAN3Qku4TszADx/4tznx+5JoPsxHRo4By564ODlMe1vqFszOs9N7d5Rka/ MytsvIvgio5JTbo9D6DC7MMN53qXPKHpMzyolitj1uigIf3hTVRegg9JvEF9ifmGuqp+ K9h4NDIc3jAXED6Xsw1/Rmtk/NEqwzZw6vQ5NxobAnGCm9sIrVpoRgsE1Pn2r3V4pcGe PLt8cvb1fhYpbDxqnvI7dlW+YKRNsy14cVehuo9Xq3bx2z1tkh8G2LLGBfhcutps+K4X xPVw== X-Gm-Message-State: APjAAAV4wICZo2M6HFl9XHlh95ovmwRWzwfs/yKh1/CSpXTztuwYC1c7 i//R0Gz+e4AIp7Gu5VI0+YptpSUq X-Google-Smtp-Source: APXvYqyP2XTwEGKrSJgjpvfp4q5+IvD+SZE8dUmwojxp2fDrWNFrJxnGtyOuJAGcHcPBpX8n/+BePA== X-Received: by 2002:a2e:810d:: with SMTP id d13mr37663132ljg.93.1555583284116; Thu, 18 Apr 2019 03:28:04 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 03:28:03 -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 1/3] PM / Domains: Don't kfree() the virtual device in the error path Date: Thu, 18 Apr 2019 12:27:55 +0200 Message-Id: <20190418102757.1246-2-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> It's not correct to call kfree(dev) when device_register(dev) has failed. Fix this by calling put_device(dev) instead. Fixes: 3c095f32a92b ("PM / Domains: Add support for multi PM domains per device to genpd") Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 Acked-by: Viresh Kumar Acked-by: Niklas Cassel diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index ecac03dcc9b2..7fec69aebf46 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2528,7 +2528,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, ret = device_register(virt_dev); if (ret) { - kfree(virt_dev); + put_device(virt_dev); return ERR_PTR(ret); } From patchwork Thu Apr 18 10:27:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162454 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp563483jan; Thu, 18 Apr 2019 03:28:06 -0700 (PDT) X-Received: by 2002:ac2:4566:: with SMTP id k6mr15240780lfm.22.1555583286018; Thu, 18 Apr 2019 03:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555583286; cv=none; d=google.com; s=arc-20160816; b=KRlaVObF3htHsENxrVcs1oMGiCAz3XNkApFh21f3O6ZrWN3bNPyNYVl4ZqgZwt2SJ0 2Gd/9s9jfmtYbekVnA+YXf5s50U/3Ci6yI4wo7aaBK8UpYoTX1LYCvTdnbtw+cUtKIEh huzSGHEa0DtrVN1ETOQClDzqnn256fYkVOi27WwXbku+qRHYBba5sXSIaHs+8By5M1Tp TMuVcKZl8zHpVVqilMqmb2iNpfhA4c0VRF4hNTN8sdJVsgy+EOr3yEOmczlK02dlfCpx rryZi27WNcXAxrlHwO7Uufy6qYY/kfzYnGgJzoO2+da2j33Izh9ejjBkYoG2oKCu9T/H AKwg== 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=BLvAgBQDq6vF0i+wC/iY8ot3SYyciBGpMv8ybloeX/8=; b=fk9XlwU5Oo9FmgKSG7umZRuKMzZ/zqEZmUh3tjdjGj7S/cNtwgAifm5W8Rcl66U04r ll46wijAzLiORqahOyQqH+2LRTDDGnVgwgu9ONkIHByUoh4i0hpaD6Q0KUi8AeFsb1FL zIg+Y6TElZy+rO8ZWLuRheSyN32aBTwCKPOD2S/htrmCMKQY4EUtEyvWzY7V83isxzLw zYnC4vXssEtpiJvJuN3SL7S8ZAnzSZ4ZDlyBxYE5M96R9MSI2cfWaqTz/weaD7SLpj6i qTaOSKooDsriCa9mh9HFyoRlBz0xa8G8ZpZsMdUerjSPBNhabf5qeVhww2OLVwWLM8c2 wdjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UWjsHT1s; 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 p5sor821877ljg.8.2019.04.18.03.28.05 for (Google Transport Security); Thu, 18 Apr 2019 03:28:06 -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=UWjsHT1s; 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=BLvAgBQDq6vF0i+wC/iY8ot3SYyciBGpMv8ybloeX/8=; b=UWjsHT1soOCJol5kUrl4LvjOrmosF6Qvw1AlY4/rgZDKzdy0IOQ02rKUvJz1QU8gNS auSsccy7TFGnzKgKOC1bfnesKoR5bh0WoCMoy08Rq41b0kX1EP2CTMImfnNm59uHJLoE IZjc9ctIk/jINg1QD2Rf1VzNaJSDu5nibKxED3wklqMYDgxyAEjyzoqKJi0zikzveq+R X58rwBvNBMFh5psCB8ctl8jFZ7i6IkWgd+Hz9ktJ5yIBkuV+BdJFQ01a+bCearHLoCE4 LUcJXp8cIkbUXX2k6QObhuUjUaYTEJjlu/YKbBTRe6e7owNpatgqbz6seu+kgy5pi87T h45A== 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=BLvAgBQDq6vF0i+wC/iY8ot3SYyciBGpMv8ybloeX/8=; b=kq9yXedfQHWg3hTCjTkADi0wD7RMqBZT19bmSkfbKfzOG6lm+byFXdF07xKl1UymAs CerI6JHXZfITXMM8SbL/oI2XmsZs3IF2hjaOagUQSxnGKfXBb290RQoN/NFgtYlBu37M rA4oZaCiRNW3Yk+SjSf9sCStIX8Hv6JTFjhlk2BOZEmphG6CLq6SDmSCwRIZcZwfB6w0 OHJAon9SbgN12+xSIoI4yAjUAb3RxU2dnAWfLxxdMB4H8EhAo3exASvnAS4FgVECR0X5 5jtHbo+iVJqgQQT1ufcvsr64ztlsPmKJEbnbJbeQpAn6JAh2JP8cqnoIzcHggg50BgCt 12cA== X-Gm-Message-State: APjAAAVSo49h0knqTMRwvMIhLi77rwFJmbQX/GQysLHd57lo639lxhx9 qOFWOqkFP9d2kPGWlVSvtWrux1nV X-Google-Smtp-Source: APXvYqxP+kiPYsKyAHgOMKr4NxfGd1gczUvjp0zvE12QTUzn6AhXfh0nI+0yjdus7Gtj4hdq5UvIVA== X-Received: by 2002:a2e:711a:: with SMTP id m26mr50832819ljc.40.1555583285587; Thu, 18 Apr 2019 03:28:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 03:28:04 -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 2/3] PM / Domains: Allow OF lookup for multi PM domain case from ->attach_dev() Date: Thu, 18 Apr 2019 12:27:56 +0200 Message-Id: <20190418102757.1246-3-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> A genpd provider that uses the ->attach_dev() callback to lookup resources for a device, fails to do so when the device has multiple PM domains. This is because when genpd invokes the ->attach_dev() callback, it passes the allocated virtual device as the in-parameter. To address this problem, let's simply assign the dev->of_node for the virtual device, based upon the original device's OF node. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.17.1 Acked-by: Viresh Kumar Acked-by: Niklas Cassel diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 7fec69aebf46..801f31c87d16 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2345,6 +2345,7 @@ EXPORT_SYMBOL_GPL(of_genpd_remove_last); static void genpd_release_dev(struct device *dev) { + of_node_put(dev->of_node); kfree(dev); } @@ -2406,14 +2407,14 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } -static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np, - unsigned int index, bool power_on) +static int __genpd_dev_pm_attach(struct device *dev, unsigned int index, + bool power_on) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; int ret; - ret = of_parse_phandle_with_args(np, "power-domains", + ret = of_parse_phandle_with_args(dev->of_node, "power-domains", "#power-domain-cells", index, &pd_args); if (ret < 0) return ret; @@ -2481,7 +2482,7 @@ int genpd_dev_pm_attach(struct device *dev) "#power-domain-cells") != 1) return 0; - return __genpd_dev_pm_attach(dev, dev->of_node, 0, true); + return __genpd_dev_pm_attach(dev, 0, true); } EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); @@ -2525,6 +2526,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, dev_set_name(virt_dev, "genpd:%u:%s", index, dev_name(dev)); virt_dev->bus = &genpd_bus_type; virt_dev->release = genpd_release_dev; + virt_dev->of_node = of_node_get(dev->of_node); ret = device_register(virt_dev); if (ret) { @@ -2533,7 +2535,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, } /* Try to attach the device to the PM domain at the specified index. */ - ret = __genpd_dev_pm_attach(virt_dev, dev->of_node, index, false); + ret = __genpd_dev_pm_attach(virt_dev, index, false); if (ret < 1) { device_unregister(virt_dev); return ret ? ERR_PTR(ret) : NULL; 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. */