From patchwork Wed Oct 3 14:38:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10624913 X-Patchwork-Delegate: rjw@sisk.pl 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 DA2691926 for ; Wed, 3 Oct 2018 14:38:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C87C228AF5 for ; Wed, 3 Oct 2018 14:38:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBCB428B0D; Wed, 3 Oct 2018 14:38:48 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6469E28AF5 for ; Wed, 3 Oct 2018 14:38:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727092AbeJCV1Y (ORCPT ); Wed, 3 Oct 2018 17:27:24 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35007 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726967AbeJCV1X (ORCPT ); Wed, 3 Oct 2018 17:27:23 -0400 Received: by mail-lj1-f195.google.com with SMTP id o14-v6so5374138ljj.2 for ; Wed, 03 Oct 2018 07:38:41 -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=lOD5x9dibVDZPPRf+HmlB0VLhQ+dq9aywfJobMmjAbY=; b=RZ8hvbTQATzJjRDFdCkxhcX5piHn5HTxpCsnq5o90Cm5QmrwYKBxaToPvaD0O1X3Bb AcxEUfcmqXX2h9Us8+QrYsjyl3HWR7FVjhoK1muBM3ivgY+vAssmfX6feNbbmzYuJOG2 xdkoBcB1TkhnFERmGxxp9ix/XP2N2t/i/6H5g= 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=lOD5x9dibVDZPPRf+HmlB0VLhQ+dq9aywfJobMmjAbY=; b=SpVdTh9N2efi1dzdlDpqj0eBIoY6ZWg9t9EkwWj/Gj582ZcIOXeBIrsLlUxjm1xPfl nqDtnnwtI5+k2BmYZRsWmxgQ4nyK7Y6nfoRA0/4SujrFs4xJ/RoyE0pyd3qwJi0NfuxP rUSO5p7FHhSAXUcSg5BckTpQssdJN4JQbv5A0PiXLSRFq7QwxqAPHS2IG464x/8sNl8b v8mVzBid4QfPmKmYUWyJEKf0oLBvGKjtVcy2mKywQtTCQk72vbrXLkfPl31LcKsU2esH ruhmhwGHarngFlxpb/X4LVJw1p9wgzxpPz3aZNuwZZkHZQHmj78yyGc8e65XQHkOGQLW 81Og== X-Gm-Message-State: ABuFfojRhOVOWtjcjvCGG88z3R7F7jZel6NaNVwX9co8yqZmOnS91z9t 0sV57GlCmFKwQGbwIiLQyZJcAw== X-Google-Smtp-Source: ACcGV61DbPnzSLG0nVWYgX1I5i3G12v3UxOKQEvibV7kGdEUWyHVXws7WQhu9Pzav2u7XCqgP7qPgA== X-Received: by 2002:a2e:8346:: with SMTP id l6-v6mr1385660ljh.72.1538577521080; Wed, 03 Oct 2018 07:38:41 -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 18-v6sm380867ljo.74.2018.10.03.07.38.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:40 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 01/11] PM / Domains: Don't treat zero found compatible idle states as an error Date: Wed, 3 Oct 2018 16:38:14 +0200 Message-Id: <20181003143824.13059-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-1-ulf.hansson@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of returning -EINVAL from of_genpd_parse_idle_states() in case none compatible states was found, let's return 0 to indicate success. Assign also the out-parameter *states to NULL and *n to 0, to indicate to the caller that zero states have been found/allocated. This enables the caller of of_genpd_parse_idle_states() to easier act on the returned error code. Cc: Lina Iyer Signed-off-by: Ulf Hansson Reviewed-by: Lina Iyer --- drivers/base/power/domain.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 4b5714199490..e1bbddb02871 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2478,8 +2478,8 @@ static int genpd_iterate_idle_states(struct device_node *dn, * * Returns the device states parsed from the OF node. The memory for the states * is allocated by this function and is the responsibility of the caller to - * free the memory after use. If no domain idle states is found it returns - * -EINVAL and in case of errors, a negative error code. + * free the memory after use. If any or zero compatible domain idle states is + * found it returns 0 and in case of errors, a negative error code is returned. */ int of_genpd_parse_idle_states(struct device_node *dn, struct genpd_power_state **states, int *n) @@ -2488,8 +2488,14 @@ int of_genpd_parse_idle_states(struct device_node *dn, int ret; ret = genpd_iterate_idle_states(dn, NULL); - if (ret <= 0) - return ret < 0 ? ret : -EINVAL; + if (ret < 0) + return ret; + + if (!ret) { + *states = NULL; + *n = 0; + return 0; + } st = kcalloc(ret, sizeof(*st), GFP_KERNEL); if (!st)