From patchwork Wed Jul 29 10:52:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 51639 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 47BA122DB5 for ; Wed, 29 Jul 2015 10:54:01 +0000 (UTC) Received: by laah7 with SMTP id h7sf2419757laa.2 for ; Wed, 29 Jul 2015 03:54:00 -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=PXK+1QJCEgdJmeUPTXFJaTcVNmS89IWIHW3gwDFaD0k3GUPqwV6ZsWul7nppyu6/q1 N5+OnlIYlTnuEmtpx9y0qRxc2tqghqQsSYwF4IWCZgxoqSP+yrNYVA1HbtZK28vdGHXz qCb/PR6N0b7ED4CcY5MAqQrXskL3pwYhRxxDt5xFl4NvQcoh0RMt1eNz0QmEdTMhOoRN pxLLHsY7R+6D4lOtv1uyhfy0SIRsT30SrKrcfsBnewxxAFIl3H8rRJWLcwjtIoRVr8P3 Ox1STwi2n9mBScwGBFQ6/jjQzikjcfdxKj7lC8Ejv71MoYxXirqzBuxS1ro820/US2xg jXkA== X-Gm-Message-State: ALoCoQlriXvVly7VG/p/8VhC4ZRxD1OEkv8UfvsHBynxJ0px5kA0A1co1s6EF9LVN/QN9fZd79DF X-Received: by 10.194.93.198 with SMTP id cw6mr15761664wjb.3.1438167240218; Wed, 29 Jul 2015 03:54:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.227 with SMTP id z3ls22513lad.97.gmail; Wed, 29 Jul 2015 03:53:59 -0700 (PDT) X-Received: by 10.152.23.4 with SMTP id i4mr38137453laf.51.1438167239883; Wed, 29 Jul 2015 03:53:59 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id t1si21207485lbk.72.2015.07.29.03.53.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jul 2015 03:53:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lagw2 with SMTP id w2so3775124lag.3 for ; Wed, 29 Jul 2015 03:53:59 -0700 (PDT) X-Received: by 10.112.166.106 with SMTP id zf10mr37876730lbb.36.1438167239660; Wed, 29 Jul 2015 03:53:59 -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 l6csp2675537lba; Wed, 29 Jul 2015 03:53:58 -0700 (PDT) X-Received: by 10.70.130.34 with SMTP id ob2mr91493083pdb.15.1438167237742; Wed, 29 Jul 2015 03:53:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kr7si8767486pab.155.2015.07.29.03.53.56; Wed, 29 Jul 2015 03:53:57 -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 S1752701AbbG2Kxv (ORCPT + 27 others); Wed, 29 Jul 2015 06:53:51 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:35661 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752635AbbG2Kxr (ORCPT ); Wed, 29 Jul 2015 06:53:47 -0400 Received: by pdrg1 with SMTP id g1so4083351pdr.2 for ; Wed, 29 Jul 2015 03:53:47 -0700 (PDT) X-Received: by 10.70.131.73 with SMTP id ok9mr92370069pdb.109.1438167227304; Wed, 29 Jul 2015 03:53:47 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id fy5sm40060976pdb.93.2015.07.29.03.53.45 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 29 Jul 2015 03:53:46 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , sboyd@codeaurora.org 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, 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 V3 04/16] PM / OPP: Create _remove_device_opp() for freeing dev_opp Date: Wed, 29 Jul 2015 16:22:59 +0530 Message-Id: <81d699ccc59f2ae1eab02ecc0b8e2a844f78b1c4.1438166099.git.viresh.kumar@linaro.org> 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.43 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); } /**