Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752366AbdFTVIX (ORCPT ); Tue, 20 Jun 2017 17:08:23 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53282 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751090AbdFTVIV (ORCPT ); Tue, 20 Jun 2017 17:08:21 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BD5D360853 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sboyd@codeaurora.org Date: Tue, 20 Jun 2017 14:08:20 -0700 From: Stephen Boyd To: Viresh Kumar Cc: Rafael Wysocki , Viresh Kumar , Nishanth Menon , linux-pm@vger.kernel.org, Vincent Guittot , Rajendra Nayak , linux-kernel@vger.kernel.org Subject: Re: [PATCH] PM / OPP: Add dev_pm_opp_{set|put}_clkname() Message-ID: <20170620210820.GU4493@codeaurora.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Content-Length: 1378 Lines: 47 On 06/20, Viresh Kumar wrote: > + */ > +struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char *name) > +{ > + struct opp_table *opp_table; > + int ret; > + > + opp_table = dev_pm_opp_get_opp_table(dev); > + if (!opp_table) > + return ERR_PTR(-ENOMEM); > + > + /* This should be called before OPPs are initialized */ > + if (WARN_ON(!list_empty(&opp_table->opp_list))) { > + ret = -EBUSY; > + goto err; > + } > + > + /* Already have clkname set */ > + if (opp_table->clk_name) { > + ret = -EBUSY; > + goto err; > + } > + > + opp_table->clk_name = kstrdup(name, GFP_KERNEL); > + if (!opp_table->clk_name) { Is there a reason to duplicate clk_name instead of using the clk structure returned from clk_get()? Is it because we may already have opp_table->clk set from default init? Why can't we always clk_put() the clk structure if it's !IS_ERR() and then allow dev_pm_opp_set_clkname() to be called many times in succession? Long story short, I don't see the benefit to allocating the name again here just to use it as a mechanism to know if the APIs have been called symmetrically. > + ret = -ENOMEM; > + goto err; > + } > + > + /* Already have default clk set, free it */ > + if (!IS_ERR(opp_table->clk)) > + clk_put(opp_table->clk); > + -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project