From patchwork Wed Jun 20 17:22:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139369 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050332lji; Wed, 20 Jun 2018 10:22:37 -0700 (PDT) X-Received: by 2002:a19:9b49:: with SMTP id d70-v6mr6872886lfe.137.1529515357368; Wed, 20 Jun 2018 10:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515357; cv=none; d=google.com; s=arc-20160816; b=P9V7fgv+dG5y9XkgosvH5XKYHRR6pYZRhlu4iae7MkwxhMzh2C2LNeG95P8zULa4b7 EhN7UNFgmr05USkLYVH8hC508r70/TphPMXE9RT62zCvxf5lGBtql94pPfddQ4sdegHt RpLKkWiurQ/0/zCVw0eRv2I4UGJCEkvBiPTVZ88chkjUPRInCVGkFwTJlbxtxsaOepea N/oWQxbp8TBGkH9V23oO9Zc+Vo2V5ca+17xWSmcnRl7gA3rNCByspcXasw3fVzQTvQXs I63Lmw48jw9JI3yfIP4K/iQb9GKlsZdqavRk5FuSGODkpZOrddlc5/hZSACmvcygr8iu phOg== 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:arc-authentication-results; bh=Ta+r1yNZdCXimBKhBsWVqn0620vMogcKiWR1qFWwX9o=; b=t+XLgWjK4qGNfGNB/J4glH0F0kJTpHUPhquo+uVr+2M8Gur2PiFmfYVI4CNPyDoHpA +Ey3gCso/Nizu9Fr6dHdvTunCC1jE40bBrcVpxaIfd9EgSZk0fJz8uoeiI9iphQl7hs7 Qxg+Q3GXWRFnM2JZPKsr5UlyQELnODgURj8SG6EZy7E3bnHW6gXYUmGl22X94Az+MXHl cTmgEu4DLSQqYXSUU3ojoz/2gdwcwNvoSu3VVVxZUqVq7GBB4Y1jvVaNFfVTPDu3PQpp s5BibtB/oWlvDjSbUMCWMHJqxw8JE5dzjAQlbaGafeR20dY68NxI0A+IXgyR1vQESYmC uliw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EF2bvCWY; 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 j22-v6sor733400ljh.37.2018.06.20.10.22.37 for (Google Transport Security); Wed, 20 Jun 2018 10:22:37 -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=EF2bvCWY; 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=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=opSsIn96I0PbrY9K74ShA+KteLuXELdMP83Maitfgcbk+dd12e/7LsVo60s72IWpSm Se4xzm1+GzMTohOZcV006YPDL+qYiRy4B/LTgVnA2RehU+hSwo0Cj2eWdztf20DcyVkz 24vB3w63OWQtkpedBlP9Q1WVBH897V6GYCDQFwrQHNiIFf+HDgfql4LHpfdcNpLG9Fv6 Cb2sNsClLAdhS1ISRBqcOvgm72qqhDzyE/qDqUNfvALs/MHW057m8WHwiCQceJ9qO9DE avz1AlI+mwagaU6ihxR/p2BX+zwx7O6NtvAEpiFJpGH7y6KFP81hDuyyZuypeL1klkYh TA5w== X-Gm-Message-State: APt69E36cS0GUUIg3bmpir7zFPNJnkV1JoraDJK/GXd/TnXpHHymMHS5 JYUeor9VBw1whxrZL1XAJZV9QUUG X-Google-Smtp-Source: ADUXVKJyxlvSIFg+/7EwbEUN34YH+vPDjyjo+9LB6G2f5ADATsPe/le1yelWM3DGCZZIG5bc1+t24g== X-Received: by 2002:a2e:750d:: with SMTP id q13-v6mr14482924ljc.56.1529515357131; Wed, 20 Jun 2018 10:22:37 -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 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> 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 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)