lkml.org 
[lkml]   [2016]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH V2 26/63] clocksource/drivers/nomadik-mtu: Convert init function to return error
    Date
    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/mxs_timer.c | 24 +++++++++++++++++-------
    1 file changed, 17 insertions(+), 7 deletions(-)

    diff --git a/drivers/clocksource/mxs_timer.c b/drivers/clocksource/mxs_timer.c
    index 16cf53b..17b9d19 100644
    --- a/drivers/clocksource/mxs_timer.c
    +++ b/drivers/clocksource/mxs_timer.c
    @@ -229,7 +229,7 @@ static int __init mxs_clocksource_init(struct clk *timer_clk)
    static int __init mxs_timer_init(struct device_node *np)
    {
    struct clk *timer_clk;
    - int irq;
    + int irq, ret;

    mxs_timrot_base = of_iomap(np, 0);
    WARN_ON(!mxs_timrot_base);
    @@ -237,10 +237,12 @@ static int __init mxs_timer_init(struct device_node *np)
    timer_clk = of_clk_get(np, 0);
    if (IS_ERR(timer_clk)) {
    pr_err("%s: failed to get clk\n", __func__);
    - return;
    + return PTR_ERR(timer_clk);
    }

    - clk_prepare_enable(timer_clk);
    + ret = clk_prepare_enable(timer_clk);
    + if (ret)
    + return ret;

    /*
    * Initialize timers to a known state
    @@ -278,11 +280,19 @@ static int __init mxs_timer_init(struct device_node *np)
    mxs_timrot_base + HW_TIMROT_FIXED_COUNTn(1));

    /* init and register the timer to the framework */
    - mxs_clocksource_init(timer_clk);
    - mxs_clockevent_init(timer_clk);
    + ret = mxs_clocksource_init(timer_clk);
    + if (ret)
    + return ret;
    +
    + ret = mxs_clockevent_init(timer_clk);
    + if (ret)
    + return ret;

    /* Make irqs happen */
    irq = irq_of_parse_and_map(np, 0);
    - setup_irq(irq, &mxs_timer_irq);
    + if (irq <= 0)
    + return -EINVAL;
    +
    + return setup_irq(irq, &mxs_timer_irq);
    }
    -CLOCKSOURCE_OF_DECLARE(mxs, "fsl,timrot", mxs_timer_init);
    +CLOCKSOURCE_OF_DECLARE_RET(mxs, "fsl,timrot", mxs_timer_init);
    --
    1.9.1
    \
     
     \ /
      Last update: 2016-06-17 00:21    [W:4.202 / U:0.324 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site