mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: "Tudor Ambarus" <tudor.ambarus@linaro.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Peter Griffin" <peter.griffin@linaro.org>,
	"André Draszik" <andre.draszik@linaro.org>,
	"Michael Turquette" <mturquette@baylibre.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	"Sylwester Nawrocki" <s.nawrocki@samsung.com>,
	"Chanwoo Choi" <cw00.choi@samsung.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-clk@vger.kernel.org, willmcvicker@google.com,
	kernel-team@android.com
Subject: Re: [PATCH v3 3/5] clk: samsung: add Exynos ACPM clock driver
Date: Sat, 6 Sep 2025 14:19:30 +0200	[thread overview]
Message-ID: <eafb409d-5b5f-4791-939a-5a3c1eb00b9b@kernel.org> (raw)
In-Reply-To: <20250903-acpm-clk-v3-3-65ecd42d88c7@linaro.org>

On 03/09/2025 15:56, Tudor Ambarus wrote:
> +
> +static int acpm_clk_probe(struct platform_device *pdev)
> +{
> +	enum acpm_clk_dev_type type = platform_get_device_id(pdev)->driver_data;
> +	const struct acpm_clk_driver_data *drv_data;
> +	const struct acpm_handle *acpm_handle;
> +	struct clk_hw_onecell_data *clk_data;
> +	struct clk_hw **hws;
> +	struct device *dev = &pdev->dev;
> +	struct acpm_clk *aclks;
> +	unsigned int mbox_chan_id;
> +	int i, err, count;
> +
> +	switch (type) {
> +	case GS101_ACPM_CLK_ID:
> +		drv_data = &acpm_clk_gs101;

Just use acpm_clk_gs101 directly (see also further comment).

> +		break;
> +	default:
> +		return dev_err_probe(dev, -EINVAL, "Invalid device type\n");
> +	}
> +
> +	acpm_handle = devm_acpm_get_by_node(dev, dev->parent->of_node);
> +	if (IS_ERR(acpm_handle))
> +		return dev_err_probe(dev, PTR_ERR(acpm_handle),
> +				     "Failed to get acpm handle.\n");
> +
> +	count = drv_data->nr_clks;
> +	mbox_chan_id = drv_data->mbox_chan_id;
> +
> +	clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, count),
> +				GFP_KERNEL);
> +	if (!clk_data)
> +		return -ENOMEM;
> +
> +	clk_data->num = count;
> +	hws = clk_data->hws;
> +
> +	aclks = devm_kcalloc(dev, count, sizeof(*aclks), GFP_KERNEL);
> +	if (!aclks)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < count; i++) {
> +		const struct acpm_clk_variant *variant = &drv_data->clks[i];
> +		unsigned int id = variant->id;
> +		struct acpm_clk *aclk;
> +
> +		if (id >= count)

This is not possible. You control the IDs build time, so this must be
either build time check or no check. I vote for no check, because I
don't think the ID is anyhow related to number of clocks. What if (not
recommended but what if) the IDs have a gap and next ID is 1000. I see
your code using ID:


> +			return dev_err_probe(dev, -EINVAL,
> +					     "Invalid ACPM clock ID.\n");
> +
> +		aclk = &aclks[id];
> +		aclk->id = id;
> +		aclk->handle = acpm_handle;
> +		aclk->mbox_chan_id = mbox_chan_id;
> +
> +		hws[id] = &aclk->hw;

^^^ here, but why do you need it? Why it cannot be hws[i]?

> +
> +		err = acpm_clk_ops_init(dev, aclk, variant->name);
> +		if (err)
> +			return dev_err_probe(dev, err,
> +					     "Failed to register clock.\n");
> +	}
> +
> +	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
> +					   clk_data);
> +}
> +
> +static const struct platform_device_id acpm_clk_id[] = {
> +	{ "gs101-acpm-clk", GS101_ACPM_CLK_ID },

Please drop GS101_ACPM_CLK_ID here and in other places. It's dead code
now. It should be introduced with next users/devices.

> +	{},
> +};
> +MODULE_DEVICE_TABLE(platform, acpm_clk_id);

Best regards,
Krzysztof

  reply	other threads:[~2025-09-06 12:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-03 13:56 [PATCH v3 0/5] exynos-acpm: add DVFS protocol and " Tudor Ambarus
2025-09-03 13:56 ` [PATCH v3 1/5] dt-bindings: firmware: google,gs101-acpm-ipc: add ACPM clocks Tudor Ambarus
2025-09-03 13:56 ` [PATCH v3 2/5] firmware: exynos-acpm: add DVFS protocol Tudor Ambarus
2025-09-03 13:56 ` [PATCH v3 3/5] clk: samsung: add Exynos ACPM clock driver Tudor Ambarus
2025-09-06 12:19   ` Krzysztof Kozlowski [this message]
2025-09-08  7:39     ` Tudor Ambarus
2025-09-08  7:45       ` Krzysztof Kozlowski
2025-09-08 10:55         ` Tudor Ambarus
2025-09-08 13:09           ` Tudor Ambarus
2025-09-03 13:56 ` [PATCH v3 4/5] firmware: exynos-acpm: register ACPM clocks pdev Tudor Ambarus
2025-09-06 12:20   ` Krzysztof Kozlowski
2025-09-08  7:46     ` Tudor Ambarus
2025-09-03 13:56 ` [PATCH v3 5/5] arm64: defconfig: enable Exynos ACPM clocks Tudor Ambarus

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=eafb409d-5b5f-4791-939a-5a3c1eb00b9b@kernel.org \
    --to=krzk@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=andre.draszik@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel-team@android.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=peter.griffin@linaro.org \
    --cc=robh@kernel.org \
    --cc=s.nawrocki@samsung.com \
    --cc=sboyd@kernel.org \
    --cc=tudor.ambarus@linaro.org \
    --cc=will@kernel.org \
    --cc=willmcvicker@google.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®