From patchwork Thu Oct 4 04:16:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 148088 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp453588lji; Wed, 3 Oct 2018 21:16:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Qoz+seOHqwHJ9QAd0Os09dTAtrzBG6yUyDufcwjbKNmS+QC8FzyNb9NtqjZIx6rXS7EuD X-Received: by 2002:a17:902:680e:: with SMTP id h14-v6mr4669750plk.177.1538626619375; Wed, 03 Oct 2018 21:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538626619; cv=none; d=google.com; s=arc-20160816; b=0sFeS8QcKpTO6LlbrIi0UfKFUFmoqFQKsmjzz/AitPglk3ptUfdtJJWjzJT+tf3JEm su1dts82wvNpjAD+XOnWz983Q+/TKwx7rKMIBjqzEQB3Gj781VGATGnjyBETRMUaGmoJ ylJ6xFuW6IevrJXGR6eaCVGFtv7SzJD1qjF8nt+kkcY3kNRuk8dF36Fnq0spP/7kQXDx iIjBnGq9H7M0SdgK9GfCneOg3L7ulFf3i0O/UyCBOmwbi1rezku3iWu/VRWbBe671Jci B/hgKbP6Tg9ZO0fVVruWhacDTnkq0Z6Px/1kw8XbYMt8UdSJXqLU5Jady/NRtnlOarZY rNhg== 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; bh=qmKhPk9+e4QtLT1wSGU4V2sT6TEBWes/IdprVh2Q0io=; b=uExxqU3lv64+wIwDWdslH7B6gQvk7xg1Z5Jgu6IvofP1SVI1ACW0aFba/yqiYImwTk onA45yAV5DrVIm0mwvnDibaQfTIURjS3HI8FC6mJ8dU69N5vAwlqzw2Lcrcco1NV+DK4 ZPoV70dwE71QsN/Efcwa/0CKtRPCYfZUzn4N8mFnvXGBgZYUmkORvDQM3BrPuIERF+fx QnYE1tGN29Fu6wkJycMzfT5xghxWrbOKHVLENzZvURSAQH+B9po3f+fYPqQjKkoI9+AS /6GFt2irQW01TCsH0S7Ky+q+biHrucRwHolG+zG1LBzcraZBKIH/qwRhmZp7mHEkqdak i47A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I/lWQzhr"; 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 j7-v6si3839822pfk.203.2018.10.03.21.16.59; Wed, 03 Oct 2018 21:16:59 -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="I/lWQzhr"; 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 S1727204AbeJDLIE (ORCPT + 32 others); Thu, 4 Oct 2018 07:08:04 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33919 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726813AbeJDLIE (ORCPT ); Thu, 4 Oct 2018 07:08:04 -0400 Received: by mail-pl1-f196.google.com with SMTP id f18-v6so4484780plr.1 for ; Wed, 03 Oct 2018 21:16:45 -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=qmKhPk9+e4QtLT1wSGU4V2sT6TEBWes/IdprVh2Q0io=; b=I/lWQzhr52XigUSMIbKX9KYqS94l1frlMSEWlqWA5e8XWYVzKQzlqWPff2nS/9fSWu dSoKVYSF4kQOfVueA9eI8+98chCNa6RyBd+t4uaCF4+fxoUoNaVg4vHMXuDfV7bYJymS J7fz8sti+e28HxD/J+QjjTp15B/DKPRPAXnuI= 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=qmKhPk9+e4QtLT1wSGU4V2sT6TEBWes/IdprVh2Q0io=; b=GUsztpROklXRCbKLgAm47tDHp5Nt4H9ogwtmSVT+ok7FKU6S4H2L5Kjioy4SBe0LIS FpDxDutcD1TiY9716Z+G/T5uRm93uS1SQCa1jm26m5p87VyWNBow22R2iadvqq2OxPJf iwmuUPMZn3QrXXTDJdmrg9JGj0O/ymSLnzwHerw4Zt9Xo77OTUEHthJJXjtCQnjVnAlf g+j3UeLiMskjrRycQvtd8jy/2SLBZPIWIPx34e0LTTLLrO8u50D8WMt7/jWD491PnUYL jNhl0jwZbi2xT6EllG8HnCoGnZUygA2/CYegPcLrieQZxMTmQ1F/mhilFtJA2ao2mUgu OQ1Q== X-Gm-Message-State: ABuFfogKDzhZR/V7i3W7WC6XsJLI78BLytzuOgiZAMt4VmvUGTKeFaOq pUdSi0E/7irti/ACtND/CyftVw== X-Received: by 2002:a17:902:bb88:: with SMTP id m8-v6mr4097054pls.120.1538626605578; Wed, 03 Oct 2018 21:16:45 -0700 (PDT) Received: from localhost ([122.172.76.11]) by smtp.gmail.com with ESMTPSA id 25-v6sm8577065pfm.36.2018.10.03.21.16.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 21:16:45 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , niklas.cassel@linaro.org, d-gerlach@ti.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] OPP: Improve error handling in dev_pm_opp_of_cpumask_add_table() Date: Thu, 4 Oct 2018 09:46:20 +0530 Message-Id: <50b6b87c8484da8bb5dcce00f84ec80aee8fc2bd.1538625101.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.18.0.rc1.242.g61856ae69a2c In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The error handling wasn't appropriate in dev_pm_opp_of_cpumask_add_table(). For example it returns 0 on success and also for the case where cpumask is empty or cpu_device wasn't found for any of the CPUs. It should really return error on such cases, so that the callers can be aware of the outcome. Fix it. Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) -- 2.18.0.rc1.242.g61856ae69a2c diff --git a/drivers/opp/of.c b/drivers/opp/of.c index a71ff3acca0f..67a384c8ead2 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -614,16 +614,18 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table); int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask) { struct device *cpu_dev; - int cpu, ret = 0; + int cpu, ret; - WARN_ON(cpumask_empty(cpumask)); + if (WARN_ON(cpumask_empty(cpumask))) + return -ENODEV; for_each_cpu(cpu, cpumask) { cpu_dev = get_cpu_device(cpu); if (!cpu_dev) { pr_err("%s: failed to get cpu%d device\n", __func__, cpu); - continue; + ret = -ENODEV; + goto remove_table; } ret = dev_pm_opp_of_add_table(cpu_dev); @@ -635,12 +637,16 @@ int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask) pr_debug("%s: couldn't find opp table for cpu:%d, %d\n", __func__, cpu, ret); - /* Free all other OPPs */ - _dev_pm_opp_cpumask_remove_table(cpumask, cpu); - break; + goto remove_table; } } + return 0; + +remove_table: + /* Free all other OPPs */ + _dev_pm_opp_cpumask_remove_table(cpumask, cpu); + return ret; } EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_add_table);