From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Taniya Das <taniya.das@oss.qualcomm.com>,
Bjorn Andersson <andersson@kernel.org>,
Abel Vesa <abelvesa@kernel.org>, Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Linus Walleij <linusw@kernel.org>,
Richard Cochran <richardcochran@gmail.com>,
Konrad Dybcio <konradybcio@kernel.org>
Cc: Ajit Pandey <ajit.pandey@oss.qualcomm.com>,
Imran Shaik <imran.shaik@oss.qualcomm.com>,
Jagadeesh Kona <jagadeesh.kona@oss.qualcomm.com>,
linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v3 03/10] clk: qcom: Add a driver for PDM GP_MN fractional clock divider
Date: Wed, 2 Dec 2026 12:55:40 +0100 [thread overview]
Message-ID: <640bd0cd-5a44-40fc-bd22-4d0e9ff153ec@oss.qualcomm.com> (raw)
In-Reply-To: <20261124-b4-pdm_clk_gp_mnd_v2-v3-3-98db26a87500@oss.qualcomm.com>
On 11/23/26 8:51 PM, Taniya Das wrote:
> The PDM (Pulse Density Modulation) hardware block on Qualcomm SoCs
> contains a GP_MN clock divider that produces a fractional output
> frequency from a fixed input clock (typically TCXO4):
[...]
> +static int gp_mnd_clk_runtime_resume(struct clk_gp_mnd *gp)
> +{
> + return pm_runtime_resume_and_get(gp->dev);
> +}
> +
> +static void gp_mnd_clk_runtime_put(struct clk_gp_mnd *gp)
> +{
> + pm_runtime_put(gp->dev);
> +}
These wrappers are totally unnecessary and confusing, just call
pm_runtime_... directly
> +static int gp_mnd_clk_set_rate(struct clk_hw *hw, unsigned long rate,
> + unsigned long parent_rate)
> +{
> + struct clk_gp_mnd *gp = to_clk_gp_mnd(hw);
> + unsigned long m = 0, n = 0;
> + unsigned int d_val, n_val;
> + int ret;
> +
> + rational_best_approximation(rate, parent_rate,
> + (unsigned long)GP_MND_MAX_M,
> + (unsigned long)GP_MND_MAX_N,
> + &m, &n);
> + if (!m || !n)
> + return -EINVAL;
> +
> + if (n <= 2 * m + 1)
> + return -EINVAL;
> +
> + ret = gp_mnd_clk_runtime_resume(gp);
> + if (ret)
> + return ret;
Use PM_RUNTIME_ACQUIRE_IF_ENABLED() to shed all the gotos
> +
> + ret = regmap_write(gp->regmap, GP_MND_MDIV_REG, m);
> + if (ret)
> + goto err_runtime_put;
> +
> + /* N divider holds the 1's complement of (N - M), N_WIDTH bits wide */
> + n_val = ~(n - m) & GP_MND_MAX_N;
FIELD_PREP, please
[...]
> +static unsigned long gp_mnd_clk_recalc_rate(struct clk_hw *hw,
> + unsigned long parent_rate)
> +{
> + struct clk_gp_mnd *gp = to_clk_gp_mnd(hw);
> + unsigned int m_val, n_val;
> + int ret;
> +
> + ret = gp_mnd_clk_runtime_resume(gp);
> + if (ret)
> + return 0;
> +
> + ret = regmap_read(gp->regmap, GP_MND_MDIV_REG, &m_val);
> + if (ret)
> + goto out_runtime_put;
> +
> + m_val &= GP_MND_MAX_M;
Likewise, FIELD_GET and ACQUIRE
[...]
> +static int clk_gp_mnd_probe(struct platform_device *pdev)
> +{
> + struct clk_parent_data parent_data = { .index = 0 };
> + struct clk_init_data init = {
> + .name = "gp_mn_clk",
Is there always at most one instance?
> + .ops = &clk_gp_mnd_ops,
> + .parent_data = &parent_data,
> + .num_parents = 1,
> + .flags = CLK_GET_RATE_NOCACHE,
Is this really necessary? i.e. do we expect the rate to change
without Linux knowing?
> + };
> + struct device *dev = &pdev->dev;
> + struct clk_gp_mnd *gp;
> + struct clk *clk;
> + void __iomem *base;
> + int ret;
nit: please keep a reverse-Christmas-tree sorting
Konrad
next prev parent reply other threads:[~2026-12-02 11:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 19:51 [PATCH v3 00/10] clk: qcom: Add PDM GP_MN fractional clock divider driver and DT support Taniya Das
2026-11-23 19:51 ` [PATCH v3 01/10] dt-bindings: clock: qcom: Add bindings for PDM GP_MN clock divider Taniya Das
2026-11-23 19:51 ` [PATCH v3 02/10] dt-bindings: clock: qcom: Add PDM XO4 divider clock IDs Taniya Das
2026-11-23 19:51 ` [PATCH v3 03/10] clk: qcom: Add a driver for PDM GP_MN fractional clock divider Taniya Das
2026-11-24 5:54 ` Abel Vesa
2026-12-02 11:39 ` Konrad Dybcio
2026-12-02 11:55 ` Konrad Dybcio [this message]
2026-11-23 19:51 ` [PATCH v3 04/10] clk: qcom: gcc: Add configurable PDM XO4 div clocks across targets Taniya Das
2026-12-02 12:15 ` Konrad Dybcio
2026-12-02 12:18 ` Konrad Dybcio
2026-11-23 19:51 ` [PATCH v3 05/10] arm64: dts: qcom: qcs8300: Add GP M/N clock controller Taniya Das
2026-11-23 19:51 ` [PATCH v3 06/10] arm64: dts: qcom: sa8775p: " Taniya Das
2026-11-23 19:51 ` [PATCH v3 07/10] arm64: dts: qcom: sc7280: " Taniya Das
2026-11-23 19:51 ` [PATCH v3 08/10] arm64: dts: qcom: qcs615: " Taniya Das
2026-11-23 19:51 ` [PATCH v3 09/10] arm64: dts: qcom: sm8750: " Taniya Das
2026-11-23 19:51 ` [PATCH v3 10/10] arm64: dts: qcom: shikra: " Taniya Das
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=640bd0cd-5a44-40fc-bd22-4d0e9ff153ec@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=abelvesa@kernel.org \
--cc=ajit.pandey@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=imran.shaik@oss.qualcomm.com \
--cc=jagadeesh.kona@oss.qualcomm.com \
--cc=jbrunet+clk@baylibre.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=taniya.das@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®