[PATCH v8 05/12] clk: zte: Add Clock registration infrastructure

sashiko-bot at kernel.org sashiko-bot at kernel.org
Mon Jul 27 11:52:54 PDT 2026


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The ID sanity check incorrectly triggers a WARN_ON and fails the probe if the driver does not export any clocks.
--

--- Patch [5]: [PATCH v8 05/12] clk: zte: Add Clock registration infrastructure ---
commit a84018498091df350796aad9d7173588a10fa7ef
Author: Stefan Dösinger <stefandoesinger at gmail.com>

clk: zte: Add Clock registration infrastructure

This commit adds common clock registration infrastructure and helpers for
ZTE SoCs. It includes support for registering PLLs, muxes, dividers, and
gates, handling both exported and internal clocks.

> diff --git a/drivers/clk/zte/clk-zx.c b/drivers/clk/zte/clk-zx.c
> new file mode 100644
> index 0000000000000..c9e9048d3ade3
> --- /dev/null
> +++ b/drivers/clk/zte/clk-zx.c
[ ... ]
> +int zx_clk_common_probe(struct device *dev, struct device_node *of_node,
> +			const struct zx_clk_data *data)
> +{
> +	unsigned int public_clk_count = 0, highest_id = 0;
> +	struct clk_hw_onecell_data *clocks;
> +	struct regmap *map;
> +	struct clk *clk;
> +	unsigned int i;
> +	int res;
> +
> +	map = device_node_to_regmap(of_node);
> +	if (IS_ERR(map))
> +		return PTR_ERR(map);
> +
> +	for (i = 0; i < data->num_muxes; ++i) {
> +		if (data->muxes[i].id != ZX297520V3_CLK_NO_EXPORT) {
> +			if (data->muxes[i].id > highest_id)
> +				highest_id = data->muxes[i].id;
> +			public_clk_count++;
> +		}
> +	}
> +	for (i = 0; i < data->num_gates; ++i) {
> +		if (data->gates[i].id != ZX297520V3_CLK_NO_EXPORT) {
> +			if (data->gates[i].id > highest_id)
> +				highest_id = data->gates[i].id;
> +			public_clk_count++;
> +		}
> +	}
> +
> +	if (WARN_ON(public_clk_count != highest_id + 1))
> +		return -EINVAL;

[Severity: Medium]
Does this check unintentionally fail the probe if a driver doesn't export
any clocks?

Since highest_id is initialized to 0, if there are no exported clocks
public_clk_count will be 0. The check (0 != 0 + 1) evaluates to true,
triggering the WARN_ON and returning -EINVAL.

Perhaps highest_id could be initialized to ~0U instead, or a check could be
added to bypass this when public_clk_count is 0?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260727-zx29clk-v8-0-7a107b00f1dd@gmail.com?part=5



More information about the linux-phy mailing list