From patchwork Mon Jul 27 05:02:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 51483 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 8A13E214B7 for ; Mon, 27 Jul 2015 05:03:44 +0000 (UTC) Received: by laef2 with SMTP id f2sf23648811lae.0 for ; Sun, 26 Jul 2015 22:03:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=2SbpSMVYkEk8DQKm4wYRb+4YG+UCiNqo07OhQl26LMg=; b=avLpwys60b9lSLHMUwNc6LUlOp+xfli35+RkUS+CIRHR06dZQXZ0fDeImc7xghj+fK OCD4zCNTEfQdVahhWD/bBDKzbwndoCTWOPQWCBFSZIHGiaqMB2e5f1Uk+uMIDo+m0tHN A8tCPA2oiBF3s06UWWbljZJKhxm5+DiptZ0PHHF8uUGhO5F6S4D9+Zc72+8XaIbdj+5o WVlPo8JmkE2Wa+NwFvRiJ8LFFdMdyJU4BKIBo5c4kaVi7paN9sYumP7V+djdRdI7NTni YL9w+p4ynGN/2t2NwhML1yhQPXi6oney4ynWqZNB0tu4J3j8DaEJkdv6Zr9wHiFEwe2h +enA== X-Gm-Message-State: ALoCoQkFgkvZk9hdYowRAfkslBpJOmBqnKgRO42jCC3K9VGcEQfIwfI0Z0rIKT0V9zEPoHufLjd7 X-Received: by 10.112.118.194 with SMTP id ko2mr11297836lbb.16.1437973423188; Sun, 26 Jul 2015 22:03:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.69 with SMTP id l5ls601797lae.73.gmail; Sun, 26 Jul 2015 22:03:42 -0700 (PDT) X-Received: by 10.152.27.197 with SMTP id v5mr25273507lag.64.1437973422889; Sun, 26 Jul 2015 22:03:42 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id ps10si14362709lbb.26.2015.07.26.22.03.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jul 2015 22:03:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lahh5 with SMTP id h5so41839768lah.2 for ; Sun, 26 Jul 2015 22:03:42 -0700 (PDT) X-Received: by 10.152.6.69 with SMTP id y5mr24948163lay.72.1437973422615; Sun, 26 Jul 2015 22:03:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp1314703lba; Sun, 26 Jul 2015 22:03:41 -0700 (PDT) X-Received: by 10.70.48.68 with SMTP id j4mr63531840pdn.111.1437973420750; Sun, 26 Jul 2015 22:03:40 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fb10si24692574pdb.169.2015.07.26.22.03.39; Sun, 26 Jul 2015 22:03:40 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752258AbbG0FDe (ORCPT + 28 others); Mon, 27 Jul 2015 01:03:34 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:34694 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751754AbbG0FDb (ORCPT ); Mon, 27 Jul 2015 01:03:31 -0400 Received: by pdbbh15 with SMTP id bh15so45259355pdb.1 for ; Sun, 26 Jul 2015 22:03:30 -0700 (PDT) X-Received: by 10.70.48.68 with SMTP id j4mr63530362pdn.111.1437973410677; Sun, 26 Jul 2015 22:03:30 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id da3sm26818959pdb.8.2015.07.26.22.03.29 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 26 Jul 2015 22:03:30 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, rob.herring@linaro.org, arnd.bergmann@linaro.org, nm@ti.com, broonie@kernel.org, mturquette@baylibre.com, sboyd@codeaurora.org, Sudeep.Holla@arm.com, viswanath.puttagunta@linaro.org, l.stach@pengutronix.de, thomas.petazzoni@free-electrons.com, linux-arm-kernel@lists.infradead.org, ta.omasab@gmail.com, kesavan.abhilash@gmail.com, khilman@linaro.org, santosh.shilimkar@oracle.com, b.zolnierkie@samsung.com, Viresh Kumar , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek Subject: [PATCH V2 03/11] OPP: Create _remove_device_opp() for freeing dev_opp Date: Mon, 27 Jul 2015 10:32:33 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This will be used from multiple places later. Lets create a separate routine for that. Reviewed-by: Stephen Boyd Reviewed-by: Bartlomiej Zolnierkiewicz Signed-off-by: Viresh Kumar --- drivers/base/power/opp.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 8c3fd57975fb..7895fdd64192 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -449,6 +449,22 @@ static void _kfree_device_rcu(struct rcu_head *head) } /** + * _remove_device_opp() - Removes a device OPP table + * @dev_opp: device OPP table to be removed. + * + * Removes/frees device OPP table it it doesn't contain any OPPs. + */ +static void _remove_device_opp(struct device_opp *dev_opp) +{ + if (!list_empty(&dev_opp->opp_list)) + return; + + list_del_rcu(&dev_opp->node); + call_srcu(&dev_opp->srcu_head.srcu, &dev_opp->rcu_head, + _kfree_device_rcu); +} + +/** * _kfree_opp_rcu() - Free OPP RCU handler * @head: RCU head */ @@ -481,11 +497,7 @@ static void _opp_remove(struct device_opp *dev_opp, list_del_rcu(&opp->node); call_srcu(&dev_opp->srcu_head.srcu, &opp->rcu_head, _kfree_opp_rcu); - if (list_empty(&dev_opp->opp_list)) { - list_del_rcu(&dev_opp->node); - call_srcu(&dev_opp->srcu_head.srcu, &dev_opp->rcu_head, - _kfree_device_rcu); - } + _remove_device_opp(dev_opp); } /**