Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1039166imm; Wed, 20 Jun 2018 10:31:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJHXdRKTYj8KuBPthebWS5cK5yq7Yj7gcI/N9yxjjdkyYbfvV+g1RDOp3W/X8hQdBUpw2BA X-Received: by 2002:a63:714c:: with SMTP id b12-v6mr19521521pgn.420.1529515896029; Wed, 20 Jun 2018 10:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515896; cv=none; d=google.com; s=arc-20160816; b=uaO+0QyNSY/PzZgzifPh8y5N8Q0c3agOLGsIbHDjmoiyw7gV8rs1R9J8IAMwq+b+Sr o6fWQs0cAKH+0ZZEQbWGGSIkiHmlF8gWauyKZIy8+xbqda0Y0OE3FK334T39l1bM3Zff clndDx0U/G1eLCMcvY8hN0iEtppvpsxSGW2tHrgVocCrWfALFqzjLrhESE6+0lANLgCF HUPPURhZrr/bF3HOrD7al53UgzLGV0dQKVmct8AGY8occVJFnnCFmYUwXbdgH9L5yA/F jsJ+N0irifIzsxgRhsH+S23mVZknBEDJULO4ecJ7aUdcXqUawuRvspUpZp3fHz5QeIhB CAVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Ta+r1yNZdCXimBKhBsWVqn0620vMogcKiWR1qFWwX9o=; b=bPmUZGwI/xMMT/Fxb2zikrrM3KcTAoV3fjrF517WEaJ74e4Is7okbZsrkLGazFb+BM CCjZzjit2BZc7pqHwar0e1QvkR+UMhqBZosllljqN+ypWb0JNSHStiTHP1n4J6135ACh GTxxfRwxX2fHn7AZtoPz/1bsEIzUBvzkUp5TqRc1vSSRCSwc0/TsGQs1hjImajhaOdnF Swwq/uixEolurXSwi4GinUG/k5DcUriSJgacF6qhotNui7X4C1YOT6P6C/NvW2r7HHTZ C3Mmgb1mRW7Pdw1kWVcoZDJ5jOHCItDovycf2BHEF73LqZC2Dxj2zqPIN06TWL6xp2jT gUCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EF2bvCWY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7-v6si2880816pll.212.2018.06.20.10.31.22; Wed, 20 Jun 2018 10:31:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EF2bvCWY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932795AbeFTR3U (ORCPT + 99 others); Wed, 20 Jun 2018 13:29:20 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35053 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754226AbeFTRWi (ORCPT ); Wed, 20 Jun 2018 13:22:38 -0400 Received: by mail-lf0-f67.google.com with SMTP id i15-v6so490945lfc.2 for ; Wed, 20 Jun 2018 10:22:37 -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=Ta+r1yNZdCXimBKhBsWVqn0620vMogcKiWR1qFWwX9o=; b=EF2bvCWY87O7+fzTccjACc8uQ+tS6c1h47qU0WCLNE9BXDGDpA92Y+fa8fUNP0zlAn e1WjcPxKWKGFzqbDnJ1+i7Td/Zun5dmHEFYKseWWNCltTJu/QpSgKmKyjEwsnVloN5Ed URm3HgPUxaZXrnYKuvDuBJW2EHSlMzaWcJp+0= 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=Ta+r1yNZdCXimBKhBsWVqn0620vMogcKiWR1qFWwX9o=; b=t+Kl3GU1C3ASYANK5sottcI8CrwXv0l2nVDFmbEAZ4lfkXWriaqC7iizV4RBfYN+wj 0KXMdbtlVKLsG4i173Rf1rmSb6heNdW5UJP5ir50VL80tDRaEPCJYR2lbQmWG3MNxj8r beOebThPsMNK+O+ZZmk7d0O78llQIhIIWymT9fWTycYBkXMvgcRkR8qpkym8Uji/lTdi Zwn05X0+9bIwMzB5NzS+u/s5Gsno8t1ZBq+LY4keszrXjN3EcIEnpbQC7k52RY5p1+rs 5/xWbNPr3OGeyEiDBB6l+ClurK5EngA137FnZxEVqFDrPY1ftHZcMyg9XvcdHw/bkJbw 6ZvQ== X-Gm-Message-State: APt69E3lmiqtX83qOFnOz74GuaYy4moeCXpzINV8BTX/WHZ6/uhjWwp9 7Cg1vFoJDLN/Y8n/cr3P2iR9hg== X-Received: by 2002:a2e:750d:: with SMTP id q13-v6mr14482924ljc.56.1529515357131; Wed, 20 Jun 2018 10:22:37 -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 b2-v6sm514441lji.85.2018.06.20.10.22.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:36 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 01/26] PM / Domains: Don't treat zero found compatible idle states as an error Date: Wed, 20 Jun 2018 19:22:01 +0200 Message-Id: <20180620172226.15012-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 4925af5c4cf0..62969c3d5d04 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2452,8 +2452,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) @@ -2462,8 +2462,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) -- 2.17.1