From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Boyd Subject: Re: [PATCH v2 3/3] clk: qcom: Introduce parent_map tables Date: Thu, 19 Mar 2015 22:37:51 -0700 Message-ID: <20150320053751.GA12794@codeaurora.org> References: <1426753763-8953-1-git-send-email-georgi.djakov@linaro.org> <1426753763-8953-4-git-send-email-georgi.djakov@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from smtp.codeaurora.org ([198.145.29.96]:47867 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750782AbbCTFhx (ORCPT ); Fri, 20 Mar 2015 01:37:53 -0400 Content-Disposition: inline In-Reply-To: <1426753763-8953-4-git-send-email-georgi.djakov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org To: Georgi Djakov Cc: mturquette@linaro.org, galak@codeaurora.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org On 03/19, Georgi Djakov wrote: > diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c > index e20d947db3e5..a946b48f2d82 100644 > --- a/drivers/clk/qcom/common.c > +++ b/drivers/clk/qcom/common.c > @@ -43,6 +43,23 @@ struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate) > } > EXPORT_SYMBOL_GPL(qcom_find_freq); > > +int qcom_find_src_index(const struct parent_map *map, u8 src) > +{ > + int i = 0; > + > + if (!map) > + return -EINVAL; > + > + do { > + if (src == map->src) > + return i; > + i++; > + } while (map++); > + > + return -ENOENT; > +} > +EXPORT_SYMBOL_GPL(qcom_find_src_index); Sorry I didn't notice this before, but we don't need/want to have NULL terminated entries because it requires the first element to be non-zero for all valid entries and also wastes space in each parent map array. We already know that a particular clock has N number of parents and we can query that from the framework, so we should use __clk_get_num_parents() to figure out how many times to loop. > + > struct regmap * > qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc) > { > diff --git a/drivers/clk/qcom/gcc-apq8084.c b/drivers/clk/qcom/gcc-apq8084.c > index e3ef90264214..f75b505a13b8 100644 > --- a/drivers/clk/qcom/gcc-apq8084.c > +++ b/drivers/clk/qcom/gcc-apq8084.c > @@ -1263,9 +1271,9 @@ static const struct freq_tbl ftbl_gcc_usb_hsic_clk[] = { > { } > }; > > -static u8 usb_hsic_clk_src_map[] = { > - [P_XO] = 0, > - [P_GPLL1] = 4, > +static const struct parent_map usb_hsic_clk_src_map[] = { > + { P_XO, 0 }, > + { P_GPLL1, 4 }, > }; This doesn't seem to be NULL terminated anyway. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project