Skip to content

Commit

Permalink
clocksource/drivers/h8300_tpu: Convert init function to return error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Lezcano committed Jun 28, 2016
1 parent 691f8f8 commit f2f9900
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/clocksource/h8300_tpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,16 @@ static struct tpu_priv tpu_priv = {
#define CH_L 0
#define CH_H 1

static void __init h8300_tpu_init(struct device_node *node)
static int __init h8300_tpu_init(struct device_node *node)
{
void __iomem *base[2];
struct clk *clk;
int ret = -ENXIO;

clk = of_clk_get(node, 0);
if (IS_ERR(clk)) {
pr_err("failed to get clock for clocksource\n");
return;
return PTR_ERR(clk);
}

base[CH_L] = of_iomap(node, CH_L);
Expand All @@ -144,14 +145,13 @@ static void __init h8300_tpu_init(struct device_node *node)
tpu_priv.mapbase1 = base[CH_L];
tpu_priv.mapbase2 = base[CH_H];

clocksource_register_hz(&tpu_priv.cs, clk_get_rate(clk) / 64);

return;
return clocksource_register_hz(&tpu_priv.cs, clk_get_rate(clk) / 64);

unmap_L:
iounmap(base[CH_H]);
free_clk:
clk_put(clk);
return ret;
}

CLOCKSOURCE_OF_DECLARE(h8300_tpu, "renesas,tpu", h8300_tpu_init);
CLOCKSOURCE_OF_DECLARE_RET(h8300_tpu, "renesas,tpu", h8300_tpu_init);

0 comments on commit f2f9900

Please sign in to comment.