mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v3 07/10] clk: socfpga: add agilex5 clock support
Date: Tue, 24 Jun 2025 10:45:58 +0200	[thread overview]
Message-ID: <aFplxg4CG5vvpxu3@pengutronix.de> (raw)
In-Reply-To: <20250623-v2024-10-0-topic-socfpga-agilex5-v3-7-e9de9e31b2c1@pengutronix.de>

On Mon, Jun 23, 2025 at 03:57:52PM +0200, Steffen Trumtrar wrote:
> +
> +static int agilex5_clkmgr_probe(struct device *dev)
> +{
> +	struct device_node *np = dev->of_node;
> +	struct stratix10_clock_data *clk_data;
> +	struct resource *res;
> +	int i, num_clks;
> +
> +	res = dev_get_resource(dev, IORESOURCE_MEM, 0);
> +	if (IS_ERR(res))
> +		return PTR_ERR(res);

dev_get_resource() should only be used when you know it is used
somewhere else as well. Otherwise please use dev_request_mem_resource().
That way you will recognize conflicts and as an additional bonus the
resource will show up in iomem ooutput.

> +static int __init agilex5_clk_init(void)
> +{
> +	return platform_driver_register(&agilex5_clkmgr_driver);
> +}
> +core_initcall(agilex5_clk_init);

You could use core_platform_driver here.


> +static unsigned long clk_peri_c_clk_recalc_rate(struct clk_hw *hwclk,
> +					     unsigned long parent_rate)
> +{
> +	struct socfpga_periph_clk *socfpgaclk = to_periph_clk(hwclk);
> +	unsigned long div = 1;
> +	u32 val;
> +
> +	val = readl(socfpgaclk->reg);
> +	val &= GENMASK(SWCTRLBTCLKSEN_SHIFT - 1, 0);
> +	parent_rate /= val;
> +
> +	return parent_rate / div;

div is always 1.

> +}
> +
> +struct clk_hw *agilex5_register_pll(const struct stratix10_pll_clock *clks,
> +				void __iomem *reg)
> +{
> +	struct clk_hw *hw_clk;
> +	struct socfpga_pll *pll_clk;
> +	struct clk_init_data init;
> +	const char *name = clks->name;
> +	int ret;
> +
> +	pll_clk = xzalloc(sizeof(*pll_clk));
> +	if (!pll_clk)
> +		return ERR_PTR(-ENOMEM);

xzalloc never fails.

You kept the original kzalloc in some places and replaced with xzalloc
elsewhere. Could you use xzalloc consistently?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2025-06-24  9:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 13:57 [PATCH v3 00/10] ARM: SoCFPGA: Add initial support for Agilex5 Steffen Trumtrar
2025-06-23 13:57 ` [PATCH v3 01/10] ARM: socfpga: kconfig: sort entries Steffen Trumtrar
2025-06-23 13:57 ` [PATCH v3 02/10] mach: socfpga: debug_ll: rework putc_ll Steffen Trumtrar
2025-06-23 13:57 ` [PATCH v3 03/10] reset: reset-socfpga: build only for 32-bit socfpga Steffen Trumtrar
2025-06-23 13:57 ` [PATCH v3 04/10] arm: socfgpa: add support for SoCFPGA Agilex5 Steffen Trumtrar
2025-06-24  7:48   ` Sascha Hauer
2025-06-23 13:57 ` [PATCH v3 05/10] linux: clk: add clk_parent_data Steffen Trumtrar
2025-06-24 10:04   ` Sascha Hauer
2025-06-23 13:57 ` [PATCH v3 06/10] clk: support init->parent_data Steffen Trumtrar
2025-06-24  8:10   ` Sascha Hauer
2025-06-23 13:57 ` [PATCH v3 07/10] clk: socfpga: add agilex5 clock support Steffen Trumtrar
2025-06-24  8:45   ` Sascha Hauer [this message]
2025-06-23 13:57 ` [PATCH v3 08/10] net: phy: add Analog Devices ADIN1300 Steffen Trumtrar
2025-06-23 13:57 ` [PATCH v3 09/10] net: add support for Designware XGMAC (10gb) ethernet Steffen Trumtrar
2025-06-24  9:57   ` Sascha Hauer
2025-06-23 13:57 ` [PATCH v3 10/10] ARM: socfpga: add Arrow AXE5 Agilex5 board Steffen Trumtrar

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=aFplxg4CG5vvpxu3@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.trumtrar@pengutronix.de \
    /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