Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1411274

Re: [PATCH 7/9] clocksource/drivers/cadence_ttc: Convert init function to return error

From Sören Brinkmann <soren.brinkmann@xilinx.com>
Newsgroups linux.kernel
Subject Re: [PATCH 7/9] clocksource/drivers/cadence_ttc: Convert init function to return error
Date 2016-06-01 16:40 +0200
Message-ID <rFftn-17P-1@gated-at.bofh.it> (permalink)
References <rF9R0-641-9@gated-at.bofh.it> <rF9R1-641-51@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Daniel,

On Wed, 2016-06-01 at 10:34:50 +0200, Daniel Lezcano wrote:
> The init functions do not return any error. They behave as the following:
> 
>  - panic, thus leading to a kernel crash while another timer may work and
>    make the system boot up correctly
> 
>  or
> 
>  - print an error and let the caller unaware if the state of the system
> 
> Change that by converting the init functions to return an error conforming
> to the CLOCKSOURCE_OF_RET prototype.
> 
> Proper error handling (rollback, errno value) will be changed later case
> by case, thus this change just return back an error or success in the init
> function.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  drivers/clocksource/cadence_ttc_timer.c | 82 +++++++++++++++++++--------------
>  1 file changed, 48 insertions(+), 34 deletions(-)
> 
[...]
>  	ttcce->ttc.clk_rate_change_nb.notifier_call =
>  		ttc_rate_change_clockevent_cb;
>  	ttcce->ttc.clk_rate_change_nb.next = NULL;
> -	if (clk_notifier_register(ttcce->ttc.clk,
> -				&ttcce->ttc.clk_rate_change_nb))
> +
> +	err = clk_notifier_register(ttcce->ttc.clk,
> +				    &ttcce->ttc.clk_rate_change_nb);
> +	if (err) {
>  		pr_warn("Unable to register clock notifier.\n");
> +		return err;

So far we handle this as warning only and move on, as the notifier is
only needed when frequency scaling is enabled. And even then, the effect
is usually just that timing is off.

> +	}
> +
>  	ttcce->ttc.freq = clk_get_rate(ttcce->ttc.clk);
>  
>  	ttcce->ttc.base_addr = base;
> @@ -451,13 +462,15 @@ static void __init ttc_setup_clockevent(struct clk *clk,
>  
>  	err = request_irq(irq, ttc_clock_event_interrupt,
>  			  IRQF_TIMER, ttcce->ce.name, ttcce);
> -	if (WARN_ON(err)) {
> +	if (err) {
>  		kfree(ttcce);
> -		return;
> +		return err;
>  	}
>  
>  	clockevents_config_and_register(&ttcce->ce,
>  			ttcce->ttc.freq / PRESCALE, 1, 0xfffe);
> +
> +	return 0;
>  }
>  
>  /**
> @@ -466,20 +479,14 @@ static void __init ttc_setup_clockevent(struct clk *clk,
>   * Initializes the timer hardware and register the clock source and clock event
>   * timers with Linux kernal timer framework
>   */
> -static void __init ttc_timer_init(struct device_node *timer)
> +static int __init ttc_timer_init(struct device_node *timer)
>  {
>  	unsigned int irq;
>  	void __iomem *timer_baseaddr;
>  	struct clk *clk_cs, *clk_ce;
> -	static int initialized;
> -	int clksel;
> +	int clksel, ret;
>  	u32 timer_width = 16;
>  
> -	if (initialized)
> -		return;
> -
> -	initialized = 1;
> -

This also changes behavior. We have multiple of these timer modules in
our HW and we don't want them all to be used for time keeping. This
construct made sure that we only use the first timer for which init is
called leaving the others for non-OS purposes.

	Sören

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/9] clocksource/drivers/clksrc-of: Improve error handling Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 10:40 +0200
  [PATCH 4/9] clocksource/drivers/mkt_timer: Convert init function to return error Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 10:40 +0200
  [PATCH 8/9] clocksource/drivers/st_lpc: Convert init function to return error Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 10:40 +0200
  [PATCH 7/9] clocksource/drivers/cadence_ttc: Convert init function to return error Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 10:40 +0200
    Re: [PATCH 7/9] clocksource/drivers/cadence_ttc: Convert init  function to return error Sören Brinkmann <soren.brinkmann@xilinx.com> - 2016-06-01 16:40 +0200
      Re: [PATCH 7/9] clocksource/drivers/cadence_ttc: Convert init  function to return error Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 16:50 +0200
  [PATCH 5/9] clocksource/drivers/exynos_mct: Convert init function to return error Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 11:00 +0200
    Re: [PATCH 5/9] clocksource/drivers/exynos_mct: Convert init function  to return error Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-06-06 13:00 +0200
      Re: [PATCH 5/9] clocksource/drivers/exynos_mct: Convert init function  to return error Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-06-06 13:30 +0200
      Re: [PATCH 5/9] clocksource/drivers/exynos_mct: Convert init function  to return error Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-06 13:30 +0200
  [PATCH 6/9] clocksource/drivers/asm9260: Convert init function to return error Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 11:00 +0200
  [PATCH 1/9] of: Add a new macro to declare_of for one parameter function returning a value Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 11:00 +0200
  [PATCH 9/9] clocksource/drivers/dw_apb_timer: Convert init function to return error Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 11:00 +0200
  [PATCH 3/9] clocksource/drivers/rockchip_timer: Convert init function to return error Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 11:10 +0200
  [PATCH 2/9] clocksource/drivers/clksrc-probe: Introduce init functions with return code Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-01 11:10 +0200
  Re: [PATCH 0/9] clocksource/drivers/clksrc-of: Improve error handling Geert Uytterhoeven <geert@linux-m68k.org> - 2016-06-07 12:00 +0200
    Re: [PATCH 0/9] clocksource/drivers/clksrc-of: Improve error handling Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-07 13:40 +0200
    Re: [PATCH 0/9] clocksource/drivers/clksrc-of: Improve error handling Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-08 00:30 +0200
    Re: [PATCH 0/9] clocksource/drivers/clksrc-of: Improve error handling Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-08 16:20 +0200
      Re: [PATCH 0/9] clocksource/drivers/clksrc-of: Improve error handling Geert Uytterhoeven <geert@linux-m68k.org> - 2016-06-09 09:50 +0200
        Re: [PATCH 0/9] clocksource/drivers/clksrc-of: Improve error handling Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-06-09 09:50 +0200

csiph-web