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: 92190 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1055415obz; Sun, 22 Jan 2017 20:43:33 -0800 (PST) X-Received: by 10.99.54.79 with SMTP id d76mr29872431pga.91.1485146613786; Sun, 22 Jan 2017 20:43:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f81si14470314pfa.44.2017.01.22.20.43.33; Sun, 22 Jan 2017 20:43:33 -0800 (PST) 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; 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 S1751301AbdAWEnS (ORCPT + 25 others); Sun, 22 Jan 2017 23:43:18 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:35712 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751113AbdAWEmr (ORCPT ); Sun, 22 Jan 2017 23:42:47 -0500 Received: by mail-pf0-f176.google.com with SMTP id f144so37889093pfa.2 for ; Sun, 22 Jan 2017 20:42:42 -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=Knoy7S2OcmVN2McqACI6KOjUBH1WwzcLGiPz8PAK8UJ9iyXreC9NGaSEn83TRvGJj1 OCOupNlFEMVCNJp5HN99wGRbPM9vT2Ckkt9MF9ryf5KPxe0PPyxfeoBDS4SLsHh42mwB KGjJFGpoin7z2hEJOdNo8DGun2jwi0kwTN5GCY9CseYyIj1Wu6eVOJABHXtPzFVr0QXn WnQJsJ5w89D2EJ00Js2Dx/Wi1SJSNccECWVUstPsiSBmHAL4XiETPTgeYIJN8LukN2lY aQFtPicgEOXKIDj+jwcZjO5zc50IXkkhUDNzwWpzq4oMd0+CyWg0iPUkCA57fkf9CgGA JScQ== X-Gm-Message-State: AIkVDXLTiO8ohY5Pc5SfdNSu+7XzNXeJnzAyLloSA8Lsgx52zHt5ZXgaDaMU7Ibozsb9Ng0F 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.7.1.410.g6faf27b 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; }