From patchwork Mon Jan 23 04:41:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9531741 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 4EF3B6020B for ; Mon, 23 Jan 2017 04:43:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41540279E0 for ; Mon, 23 Jan 2017 04:43:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3585B27D5E; Mon, 23 Jan 2017 04:43:32 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 EF571279E0 for ; Mon, 23 Jan 2017 04:43:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750802AbdAWEnR (ORCPT ); Sun, 22 Jan 2017 23:43:17 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:36634 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751194AbdAWEmr (ORCPT ); Sun, 22 Jan 2017 23:42:47 -0500 Received: by mail-pf0-f182.google.com with SMTP id 189so37932506pfu.3 for ; Sun, 22 Jan 2017 20:42:47 -0800 (PST) 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=d4npPgPNBOGIi4MjWVoTNXeBghNKs/nEHlRb0w8Yxk8=; b=aMk88e3L0bB/Z2udiXnucJC/tK+jcrgUK4JcSDS5RRrV3WXWTlw8412ENTTQy8pUhV JI3t/hRCfr5/sQn3pgor+BU2KYliNkMruW9FkuBrt3KqFxjYwDA4ouuYQEfF8R4kxAna mcAglHFYVSQa3yzFtKfeYpQy0XhxalDHZBkIg= 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=d4npPgPNBOGIi4MjWVoTNXeBghNKs/nEHlRb0w8Yxk8=; b=c7LHmJPd3Icj80oaGQ1z0WSXk5SOPzbGDFBptciF4SbvZYJq0QpP2kRiEOg20wS9de sJpm5nzCvotdHOyale9j6mk5ZEtGLKAUgkoNNIb/Ed4g/VZdQi6+YMxaGVUVasTRkdJj HMKVtyXYKc6xzMuTBIPd/QamCUKEeOjHct6bernUx12L7jjC6GeoXxkVI0PO0O43J9yG Idd/j7T03Im1qOdYdZWYY9m28wduKB3XVkoKgqq7z52iGEBVow3lCp/XUFJKDNeIdqLD ek+E16l4QBekgaZ3NAd9fJbODYtkW1hpOsKj1BvfQgsHq5EGGES2qWcOYO8w9KFvEHcU 9bOw== X-Gm-Message-State: AIkVDXLXp2oOuVPTS13v/UL67qzrCfoLT6BKGs7YFF9MYgscmOxsz3RaMEGvanJWF9lOOi/B X-Received: by 10.99.121.195 with SMTP id u186mr5843514pgc.96.1485146556950; Sun, 22 Jan 2017 20:42:36 -0800 (PST) Received: from localhost ([122.171.65.82]) by smtp.gmail.com with ESMTPSA id w65sm32761759pfw.9.2017.01.22.20.42.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jan 2017 20:42:36 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Viresh Kumar Subject: [PATCH V2 10/12] PM / OPP: Simplify _opp_set_availability() Date: Mon, 23 Jan 2017 10:11:50 +0530 Message-Id: <59507c403d7319f7ec1ac463e77f4dbfb36371d7.1485146406.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b 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 As we don't use RCU locking anymore, there is no need to replace an earlier OPP node with a new one. Just update the existing one. Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd --- drivers/base/power/opp/core.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index c40d9868bd97..f54ac2484723 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -1510,20 +1510,15 @@ static int _opp_set_availability(struct device *dev, unsigned long freq, bool availability_req) { struct opp_table *opp_table; - struct dev_pm_opp *new_opp, *tmp_opp, *opp = ERR_PTR(-ENODEV); + struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV); int r = 0; - /* keep the node allocated */ - new_opp = kmalloc(sizeof(*new_opp), GFP_KERNEL); - if (!new_opp) - return -ENOMEM; - /* Find the opp_table */ opp_table = _find_opp_table(dev); if (IS_ERR(opp_table)) { r = PTR_ERR(opp_table); dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r); - goto free_opp; + return r; } mutex_lock(&opp_table->lock); @@ -1544,32 +1539,20 @@ static int _opp_set_availability(struct device *dev, unsigned long freq, /* Is update really needed? */ if (opp->available == availability_req) goto unlock; - /* copy the old data over */ - *new_opp = *opp; - - /* plug in new node */ - new_opp->available = availability_req; - list_replace(&opp->node, &new_opp->node); - kfree(opp); + opp->available = availability_req; /* Notify the change of the OPP availability */ if (availability_req) blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE, - new_opp); + opp); else blocking_notifier_call_chain(&opp_table->head, - OPP_EVENT_DISABLE, new_opp); - - mutex_unlock(&opp_table->lock); - dev_pm_opp_put_opp_table(opp_table); - return 0; + OPP_EVENT_DISABLE, opp); unlock: mutex_unlock(&opp_table->lock); dev_pm_opp_put_opp_table(opp_table); -free_opp: - kfree(new_opp); return r; }