mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>, tglx@linutronix.de
Cc: S32@nxp.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 07/20] clocksource/drivers/vf-pit: Allocate the struct timer at init time
Date: Fri, 1 Aug 2025 10:33:15 +0300	[thread overview]
Message-ID: <8d76fd30-57de-40b0-a847-4b84c8d529c5@oss.nxp.com> (raw)
In-Reply-To: <20250730082725.183133-8-daniel.lezcano@linaro.org>

On 7/30/2025 11:27 AM, Daniel Lezcano wrote:

[...]

>  static int __init pit_timer_init(struct device_node *np)
>  {
> +	struct pit_timer *pit;
>  	struct clk *pit_clk;
>  	void __iomem *timer_base;
>  	unsigned long clk_rate;
>  	int irq, ret;
>  
> +	pit = kzalloc(sizeof(*pit), GFP_KERNEL);
> +	if (!pit)
> +		return -ENOMEM;
> +
> +	ret = -ENXIO;
>  	timer_base = of_iomap(np, 0);
>  	if (!timer_base) {
>  		pr_err("Failed to iomap\n");
> -		return -ENXIO;
> +		goto out_kfree;
>  	}
>  
> +	ret = -EINVAL;
>  	irq = irq_of_parse_and_map(np, 0);
> -	if (irq <= 0)
> -		return -EINVAL;
> +	if (irq <= 0) {
> +		pr_err("Failed to irq_of_parse_and_map\n");
> +		goto out_iounmap;
> +	}
>  
>  	pit_clk = of_clk_get(np, 0);
> -	if (IS_ERR(pit_clk))
> -		return PTR_ERR(pit_clk);
> +	if (IS_ERR(pit_clk)) {
> +		ret = PTR_ERR(pit_clk);
> +		goto out_iounmap;

This does not revert the use of irq_of_parse_and_map. In my opinion, it
should be explicitly reverted as part of the cleanup phase by calling
irq_of_parse_and_map.

> +	}
>  
>  	ret = clk_prepare_enable(pit_clk);
>  	if (ret)
> -		return ret;
> +		goto out_clk_put;
>  
>  	clk_rate = clk_get_rate(pit_clk);
>  
>  	/* enable the pit module */
>  	writel(~PITMCR_MDIS, timer_base + PITMCR);
>  
> -	ret = pit_clocksource_init(&pit_timer, timer_base, clk_rate);
> +	ret = pit_clocksource_init(pit, timer_base, clk_rate);
>  	if (ret)
> -		return ret;
> +		goto out_disable_unprepare;
> +
> +	ret = pit_clockevent_init(pit, timer_base, clk_rate, irq, 0);
> +	if (ret)
> +		goto out_pit_clocksource_unregister;
> +
> +	return 0;
>  
> -	return pit_clockevent_init(&pit_timer, timer_base, clk_rate, irq, 0);
> +out_pit_clocksource_unregister:
> +	clocksource_unregister(&pit->cs);
> +out_disable_unprepare:
> +	clk_disable_unprepare(pit_clk);
> +out_clk_put:
> +	clk_put(pit_clk);
> +out_iounmap:
> +	iounmap(timer_base);
> +out_kfree:
> +	kfree(pit);
> +
> +	return ret;
>  }
>  TIMER_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init);

-- 
Regards,
Ghennadi

  reply	other threads:[~2025-08-01  7:33 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-30  8:27 [PATCH v2 00/20] Add support for the NXP automotive S32G PIT Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 01/20] clocksource/drivers/vf-pit: Replace raw_readl/writel to reald/writel Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 02/20] clocksource/drivers/vf-pit: Add COMPILE_TEST option Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 03/20] clocksource/drivers/vf-pit: Set the scene for multiple timers Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 04/20] clocksource/drivers/vf-pit: Rework the base address usage Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 05/20] clocksource/drivers/vf-pit: Pass the cpu number as parameter Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 06/20] clocksource/drivers/vf-pit: Encapsulate the initialization of the cycles_per_jiffy Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 07/20] clocksource/drivers/vf-pit: Allocate the struct timer at init time Daniel Lezcano
2025-08-01  7:33   ` Ghennadi Procopciuc [this message]
2025-08-04  9:12     ` Daniel Lezcano
2025-08-04 10:02       ` Ghennadi Procopciuc
2025-07-30  8:27 ` [PATCH v2 08/20] clocksource/drivers/vf-pit: Convert raw values to BIT macros Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 09/20] clocksource/drivers/vf-pit: Register the clocksource from the driver Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 10/20] clocksource/drivers/vf-pit: Encapsulate the macros Daniel Lezcano
2025-08-01  7:33   ` Ghennadi Procopciuc
2025-07-30  8:27 ` [PATCH v2 11/20] clocksource/drivers/vf-pit: Encapsulate the PTLCVAL macro Daniel Lezcano
2025-08-01  7:34   ` Ghennadi Procopciuc
2025-07-30  8:27 ` [PATCH v2 12/20] clocksource/drivers/vf-pit: Use the node name for the interrupt and timer names Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 13/20] clocksource/drivers/vf-pit: Encapsulate clocksource enable / disable Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 14/20] clocksource/drivers/vf-pit: Enable and disable module on error Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 15/20] clocksource/drivers/vf-pit: Encapsulate set counter function Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 16/20] clocksource/drivers/vf-pit: Consolidate calls to pit_*_disable/enable Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 17/20] clocksource/drivers/vf-pit: Unify the function name for irq ack Daniel Lezcano
2025-08-01  7:34   ` Ghennadi Procopciuc
2025-07-30  8:27 ` [PATCH v2 18/20] clocksource/drivers/vf-pit: Rename the VF PIT to NXP PIT Daniel Lezcano
2025-08-01  7:35   ` Ghennadi Procopciuc
2025-08-01  8:48     ` Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 19/20] dt: bindings: fsl,vf610-pit: Add compatible for s32g2 and s32g3 Daniel Lezcano
2025-07-30 23:36   ` Rob Herring
2025-07-31  7:41     ` Daniel Lezcano
2025-07-31  7:50       ` Krzysztof Kozlowski
2025-07-31  8:24         ` Daniel Lezcano
2025-07-30  8:27 ` [PATCH v2 20/20] clocksource/drivers/nxp-pit: Add NXP Automotive s32g2 / s32g3 support Daniel Lezcano
2025-08-01  7:36   ` Ghennadi Procopciuc

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=8d76fd30-57de-40b0-a847-4b84c8d529c5@oss.nxp.com \
    --to=ghennadi.procopciuc@oss.nxp.com \
    --cc=S32@nxp.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.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

all inboxes | Powered by JetHome®