From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934138AbdAIXga (ORCPT ); Mon, 9 Jan 2017 18:36:30 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:50616 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932671AbdAIXg3 (ORCPT ); Mon, 9 Jan 2017 18:36:29 -0500 DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 8DDB6613A9 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=sboyd@codeaurora.org Date: Mon, 9 Jan 2017 15:36:27 -0800 From: Stephen Boyd To: Viresh Kumar Cc: Rafael Wysocki , Viresh Kumar , Nishanth Menon , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: Re: [PATCH 02/12] PM / OPP: Add 'struct kref' to OPP table Message-ID: <20170109233627.GU17126@codeaurora.org> References: <3f23949c92492ea74a7a55cd04bcd41a37592ed5.1481106919.git.viresh.kumar@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3f23949c92492ea74a7a55cd04bcd41a37592ed5.1481106919.git.viresh.kumar@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/07, Viresh Kumar wrote: > @@ -894,8 +895,36 @@ static void _kfree_device_rcu(struct rcu_head *head) > kfree_rcu(opp_table, rcu_head); > } > > -static void _free_opp_table(struct opp_table *opp_table) > +void _get_opp_table_kref(struct opp_table *opp_table) > { > + kref_get(&opp_table->kref); > +} > + > +struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) > +{ > + struct opp_table *opp_table; > + > + /* Hold our table modification lock here */ > + mutex_lock(&opp_table_lock); > + > + opp_table = _find_opp_table(dev); > + if (!IS_ERR(opp_table)) { > + _get_opp_table_kref(opp_table); It seems odd to have _get_opp_table_kref() take a pointer to increment a kref on. It would be better to have _find_opp_table() return the pointer with the reference already taken so that we don't have to update callers with reference grabbing calls. Typically if a function returns a reference counted pointer the reference counting has already been done. > + goto unlock; > + } > + > + opp_table = _allocate_opp_table(dev); > + > +unlock: > + mutex_unlock(&opp_table_lock); > + > + return opp_table; > +} > +EXPORT_SYMBOL_GPL(dev_pm_opp_get_opp_table); > + > +static void _opp_table_kref_release_unlocked(struct kref *kref) > +{ > + struct opp_table *opp_table = container_of(kref, struct opp_table, kref); > struct opp_device *opp_dev; > > /* Release clk */ -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project