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: 148056 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557422lji; Wed, 3 Oct 2018 07:38:41 -0700 (PDT) X-Received: by 2002:a2e:6e08:: with SMTP id j8-v6mr1465886ljc.61.1538577521388; Wed, 03 Oct 2018 07:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577521; cv=none; d=google.com; s=arc-20160816; b=QCfh2qFPpD8MuEmqhumNnydVbBep4IzokStk+plS6+fCAa4T5ixdvmm/H4RsITqhf+ P/DfyKJNioo4ha7kUuJ8A6LE8rhWOSQLilN2RSHuWHPpjwBkwarvU91gUTI3UDSIJ1kg rNxz+kOL64VPP/IyBu75oB6BV+e6ki6mmc5GFFudTX5Efkm/UYaDpWwD1TWjwWI0Hx+V cEGGJIUKGy1oYbJQ5paLtOh3Z1ga1421fhEtSV3aKvuqD+hE4LEAznovUs7++1TpgH14 +Mh3RHFSxMPzpbm8GD9P3TgYbQFxsTfC9vNYChIUSqpoxltp6c4tbcSF8EUm/kj4tAQP XJwg== 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=lOD5x9dibVDZPPRf+HmlB0VLhQ+dq9aywfJobMmjAbY=; b=xM6G0v4RVLha0DUM2/pbGbCDHa0afSvmas+G81dQYi2cdiT9N3R/wetVIyDFEZJwqc EQM+oadMo4hRq8VJOO1Q8oWsJDUs0SotUOraybMnekoaLU5IGqkgzylzqVhz1itkIpnR U7sWzODe9P+98MBp+oROmaBhjJtLJFgLsiG/3DnC4EWPOSL0RdUMkdRi9iGqTYpnBJBc +mnM74Yp9FpsOdkm4KdZ+ByMwKfCDlY1gElq3W7rf97R9WC3FyvgpuxVZHEetURKv29/ 4uYcnjOoVWcXQDakQo3cSc7CR39oRlwdq1un3QsyrajlZRQqA1DKjUMjgFMXZFIuCffG vUhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RZ8hvbTQ; 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 u191-v6sor974074lja.32.2018.10.03.07.38.41 for (Google Transport Security); Wed, 03 Oct 2018 07:38:41 -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=RZ8hvbTQ; 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=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=oO1Rz+7sloOPZfyrz+4RuzGkHjsioHv5OYGyJ6zJcYzj9xXdk6ryX/T/avoXlMe5HB +8HaKM70LLYt5K+LUXjKHQFTDjGc55lgXptjp/LKab4JgLoQ2hwWa/DLvmkcEZeM5wpC Q4H6sBuAoXiUm1TfQMKFm3alwrp4dTdyuF6vq1tEDvLEdDuGXyU9i8TH/huSJnDPrqdm I7RoPwkmGDcuL9pW9Ufigwq/tTY5BAo78ya17BUVxzw6MuiddQAWbl0K4/Vbi67Xg7Si P51DSyY0mBLyk9ClZQHe4cEpPv6Xm/DFf06FP9LzwC6TkDZoao8TA1JWw/TsLiRVUwBF GyKQ== X-Gm-Message-State: ABuFfojf6xyPokji5xSGoDtRmSI17z5//0pc948JY/yHPFfylTfQFtLM ekueM/qkU9oab7MtYI22JIJS1+py 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) 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 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> 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(-) -- 2.17.1 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)