From patchwork Thu Apr 12 11:14:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133239 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573387ljb; Thu, 12 Apr 2018 04:14:40 -0700 (PDT) X-Received: by 10.46.135.214 with SMTP id v22mr404916ljj.94.1523531680156; Thu, 12 Apr 2018 04:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531680; cv=none; d=google.com; s=arc-20160816; b=sRBJ26to6aCce8DGiCBljILdQuI5Tc2IWpbgr9mJirlaoqR4jBsK31QtwVlk4cD7jX iTcdrhfjEN9O5q+y/IoFZ/GxGrE4XyWTjZlIQmIPAsn+dTEZVyl7DvX0b13IdtEq1k5M 82EOcY03yRx2HPTg6Li/flXghfFkb9tYzayMkwXpg/vvR1Kpc7oAxINSydDCC1E7FRTb vKY68gqRkTSMJT+qe6gDnsUfNRUT5xLIkHWNkbmG5m7rWXJHaIjqzgr6eeLiy/S5m+cz qQ5xwiAsxlJ3QQ0JLw5xBu2oJH74vr71UaZ5Sdn105utY/+/eA7GQol88Y3y3zgHYH6X vJ1w== 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=XHPVBb922TA1uGb222Hxlm4AdEoDZBjgQ2Eka3bpJ8w=; b=zXcPiojGMoud11rnBwyLO5mFbuqjy8Ni5xd5HOfJB6+LmNX1I5Q0w2lg8VTXa69zqv jUfzr8tyX2pEX0bp1Yx9444clFJTrfQoyimm0UhVh3PA0xDB1iZ9fo5OEQKLlOdtj8BJ LQEnSGzf2kefwbcYczJz/Yw6uAJWXk2wVrg309yq8y/FoDPnGjWdkydVp1tYiNZ8xJ3K nQERRGUq0DMuQdMCQFhoMHxF9XxykEpMEPVWRZR6S/dJdGXuxfnEaUvXyClOwULjIyTz g5cwpyIizdVBV8fVnIveM+ZZ64G1FfE4hfKtMOp/3O5oulOB2UIOab0DyhrHm0mtVKdV +q4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fS8hsvGo; 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 s22sor905225lji.78.2018.04.12.04.14.40 for (Google Transport Security); Thu, 12 Apr 2018 04:14:40 -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=fS8hsvGo; 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=XHPVBb922TA1uGb222Hxlm4AdEoDZBjgQ2Eka3bpJ8w=; b=fS8hsvGop8Bsgb6yQEOWHBdFib6VPln3gzYgN0qi9klYlzUTxc0Bbs0J2+cmm43CIY lbTICJOy5TaFMxBjyEu8DN3ba7i6KdcIkbVNkTLqtBTcONL9qXjeBlDtIB4tAUdzMgao mwZmOdktzkihRJOL6g+dD75DxivvmSIMzfgYo= 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=XHPVBb922TA1uGb222Hxlm4AdEoDZBjgQ2Eka3bpJ8w=; b=aJ7F3NrVdwx9CDNa11gkClnuLyyWTMgpfiHk3vxtjqlnNGdq/emcu07BTGjBxwQNBF YwtOI4TXm/uDJjWSI5umFt3yqNxrjKvCp0gTTbXzMFx0utN1RCOa2fgoPjW1GAM4Er1P OWOdcrPUNcUTcFaM9L5hw1rWK9jiz7fjRQ7y8YyKYjEuJ33ZsLhnW4NnStfX6Xb0njVf FFvN8x3DyhUhkIHVydKhwDw2cv3hxK7UX+aD3WudbcrSMr6eoWKdOT2QX8WWrzcEztq+ 5n2R0uL1kBvjXrODQsHOE508jlACHrrfJi+smkPXooyX7NQqMaBvvLZTc5XrayXGrLak jmFQ== X-Gm-Message-State: ALQs6tA6uq/pSjTe6g1XT6eSDMgyAHODtugKtqOQoZWaG0u0w44qmKmY Yz1XW7P887uId3qAQ4BA9s8umXNj X-Google-Smtp-Source: AIpwx4+yvJ6j8ntmMX+75QrNZFlmH+qcQJuhMtQko+JV/cz0dhHPv7NLifnykMzBkUg4kXpwCOE28Q== X-Received: by 10.46.144.72 with SMTP id n8mr411094ljg.96.1523531679941; Thu, 12 Apr 2018 04:14:39 -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 r29sm543187lje.72.2018.04.12.04.14.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:39 -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 v7 01/26] PM / Domains: Don't treat zero found compatible idle states as an error Date: Thu, 12 Apr 2018 13:14:06 +0200 Message-Id: <1523531671-27491-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-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 --- drivers/base/power/domain.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 1ea0e25..c2ef944 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2331,8 +2331,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) @@ -2341,8 +2341,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)