From patchwork Wed Mar 14 16:58:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131670 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410119edg; Wed, 14 Mar 2018 09:59:04 -0700 (PDT) X-Received: by 10.46.145.131 with SMTP id f3mr3961708ljg.134.1521046744259; Wed, 14 Mar 2018 09:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046744; cv=none; d=google.com; s=arc-20160816; b=Koq8APHLAXe/XNe/c0SPqoWQZNooTcp+KkKs7tQ/ljFUH6u0cDWuOQpICrJQVWQ1fs Wgm9a7pXkFzrlpGoETEmZWglKkswAIRovySRXAJT3VBBEptKzvoMyR/CLHPsOGF9VYtw ArWGWuTrQjbovMw33XJUjmzXxoSyODL6bj6CMoJWCtnagZ27UdXPDeA7l3VQcmEY0SSR iAmbkQw9nyjpwJ5gMe66cmWY8czUTSijfq8sXjXRWoeQbrOa0Fp/M6QGtdGW8zjBxCgq e5aXkj6OEtoftp2x5Ua/51xxB2353MItpSjKpko/8VKGV3yTZcEKMMxT5l0rGawZbzLV O0QA== 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=YaMnfkFEmbN3EN+784vXetI6vdxnfXNMmaATuL7xpWLKdkKkur3iYh0x2FziySjh6w RK/H8FO0q9iLKhfn8pxszPGCxhpCIBHfQYIr/Pdh7n9xEdr4yjETxosFxV8PK7xlpCD5 w3iT/UU+DlhhoYQ83QKSvFYekxcoIMqtSwucopU4c5xaVYjHAezxHumm6tqy5BccbQAe bsGAN/WeuhtLCfLvQKWdm2dVxvtA87Zo1kttZtX98DGpOz2hmP/4prsx4VNmNCK78stW 1lXc00iTnXwXge6F786aqv3fZec0W11gMHlZX9E72jnPEwgz0ssX5eiBfc3yRUxTBWWA 3NlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VmtvPYm3; 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 y1-v6sor868993lfg.23.2018.03.14.09.59.04 for (Google Transport Security); Wed, 14 Mar 2018 09:59:04 -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=VmtvPYm3; 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=VmtvPYm3ZVkInfG6i5xbFtKCRH4INgwWQGX1yVKFjsPcf/Q+EZY7x5k6EAaLyesW9K MOWYc7hrV0xpM2zKNdlj9jNjlpB+e9DJobq8hdhbe1SZ3bB6LYA/dd7RBXszndDQ2BBq pbbWKr2wfXXQH9u6tJ8nCmOHUVCX9DAlHx20Y= 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=EbVMxDiaRyoVFa7k69xhskS5JgfaIDbBmLgsIDwbX2mIn6HOqoOo49Mn5d/8IEqeap 9dmh7k69AVJbLPTPjbALZW0J9XPbw66iNImV3QpWr5Qx7gtqbgrsx5zXgcmnRPbig9Tq 000JOpWM6FTwLuawMOpGJ0uy1NvUJfoCPWUdngMm+rM2ytuuzSfUNfAyqnWg0UJWhBp8 Jyu0FPUejwIxNDQ5JSkwsyGi1stVbTMa41DWoCC2Di65ERSRXwxR8tNCgz0jF8U9TTFp 4F1QPh8OLJy5bcmaFLMj7oR3DAWINoP7EeF2mBmknYgojLTu0DaC3ebTSz2XuF2rKeEO wVFA== X-Gm-Message-State: AElRT7H2CQ3YiM4RlNFqAxwd4vcEB5hM1hRiPFCcy/WtOQZ92Y7ubSVk ZIIuHq71GKIYZ/PMCVD0w+gGwYHz X-Google-Smtp-Source: AG47ELs3eF+sBpGB/98M1eL8koIYYSgfJ8k9SzJ/PsYUCz/rGNZvzdFkTJJ6vff7P+ksq/Ou7ZusOg== X-Received: by 2002:a19:2ad5:: with SMTP id q82-v6mr3886353lfq.79.1521046743907; Wed, 14 Mar 2018 09:59:03 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:03 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 01/25] PM / Domains: Don't treat zero found compatible idle states as an error Date: Wed, 14 Mar 2018 17:58:11 +0100 Message-Id: <1521046715-30683-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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)