From patchwork Tue May 23 04:02:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9741867 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6329660380 for ; Tue, 23 May 2017 04:02:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DEC52871F for ; Tue, 23 May 2017 04:02:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 428192878A; Tue, 23 May 2017 04:02:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8B942871F for ; Tue, 23 May 2017 04:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751696AbdEWECY (ORCPT ); Tue, 23 May 2017 00:02:24 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:35209 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751648AbdEWECW (ORCPT ); Tue, 23 May 2017 00:02:22 -0400 Received: by mail-pf0-f181.google.com with SMTP id n23so101217527pfb.2 for ; Mon, 22 May 2017 21:02:21 -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 :in-reply-to:references; bh=NYqLBWYkKYxEez+qnX9K54pJBlTLyZyNqdpG/BrrJPg=; b=Iqs6HeFsullktAr2PMqP6tYRSYeIMJPGP88bWgegQAZZjKTmTIzsrc7v699ctM6SRq Wqj2VbJLWowg1IQmxZPkrx96rSDSpsLZA4RCw9UuHIjkqYXmslYqwk8UnJ9XEF+5AznD 1sbja524Blbinb3yxA/GQE6YuGVewATSHYD9o= 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:in-reply-to:references; bh=NYqLBWYkKYxEez+qnX9K54pJBlTLyZyNqdpG/BrrJPg=; b=hIkl6idktMCVJe2yQ37kAkeh+TU+1UT3YtkxA1pUGOfLMKwn9QyyEwbdJaWr5k3etK eUU07/ld1U5EmL010ljoNALeg9KFhRjWzwYFFgKAoymVUlR5j/PavLVflWrCK+5Ic85D efiyjSOEoflhKNnEe6i8KTUcKX30WhZNwhETexPNTuPprrUmHSlp+Qw3A4VH/dIO7wwA 5ZQy2sPjj32Q0Eoaqa2+Mjz8RGPPj6noREWK/a3aTXH9018d4ZZ3176oh4zPvCKEB5Nh io93abjx/jtJ8dFZ5PVFiJA7d+yDFKF4t4WeyP5oQ2W2AOmJYSaR4a+i/aUvgtTj/Bq0 2JLQ== X-Gm-Message-State: AODbwcCDSDqdG7JnqHRTPnFoAFLsGE1rulITOKyb4PrsVwGvGThcHlOQ uPp7u5//DgiYOMor X-Received: by 10.84.224.77 with SMTP id a13mr33699767plt.132.1495512141310; Mon, 22 May 2017 21:02:21 -0700 (PDT) Received: from localhost ([122.167.143.58]) by smtp.gmail.com with ESMTPSA id b195sm27523234pfb.29.2017.05.22.21.02.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2017 21:02:20 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH V2 2/4] PM / OPP: Don't create copy of regulators unnecessarily Date: Tue, 23 May 2017 09:32:11 +0530 Message-Id: X-Mailer: git-send-email 2.13.0.70.g6367777092d9 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This code was required while the OPP core was managed with help of RCUs, but not anymore. Get rid of unnecessary alloc/memcpy operations. Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd --- drivers/base/power/opp/core.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index c4590fc017ba..5ee7aadf0abf 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -180,7 +180,7 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) { struct opp_table *opp_table; struct dev_pm_opp *opp; - struct regulator *reg, **regulators; + struct regulator *reg; unsigned long latency_ns = 0; int ret, i, count; struct { @@ -198,15 +198,9 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) if (!count) goto put_opp_table; - regulators = kmalloc_array(count, sizeof(*regulators), GFP_KERNEL); - if (!regulators) - goto put_opp_table; - uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL); if (!uV) - goto free_regulators; - - memcpy(regulators, opp_table->regulators, count * sizeof(*regulators)); + goto put_opp_table; mutex_lock(&opp_table->lock); @@ -232,15 +226,13 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) * isn't freed, while we are executing this routine. */ for (i = 0; i < count; i++) { - reg = regulators[i]; + reg = opp_table->regulators[i]; ret = regulator_set_voltage_time(reg, uV[i].min, uV[i].max); if (ret > 0) latency_ns += ret * 1000; } kfree(uV); -free_regulators: - kfree(regulators); put_opp_table: dev_pm_opp_put_opp_table(opp_table);