mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-20 10:44:23 +08:00
clocksource/drivers/imx-gpt: Convert init function to return error
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>
This commit is contained in:
parent
de23484dd5
commit
c11cd416ae
@ -407,8 +407,10 @@ static const struct imx_gpt_data imx6dl_gpt_data = {
|
|||||||
.set_next_event = v2_set_next_event,
|
.set_next_event = v2_set_next_event,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void __init _mxc_timer_init(struct imx_timer *imxtm)
|
static int __init _mxc_timer_init(struct imx_timer *imxtm)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
switch (imxtm->type) {
|
switch (imxtm->type) {
|
||||||
case GPT_TYPE_IMX1:
|
case GPT_TYPE_IMX1:
|
||||||
imxtm->gpt = &imx1_gpt_data;
|
imxtm->gpt = &imx1_gpt_data;
|
||||||
@ -423,12 +425,12 @@ static void __init _mxc_timer_init(struct imx_timer *imxtm)
|
|||||||
imxtm->gpt = &imx6dl_gpt_data;
|
imxtm->gpt = &imx6dl_gpt_data;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BUG();
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ERR(imxtm->clk_per)) {
|
if (IS_ERR(imxtm->clk_per)) {
|
||||||
pr_err("i.MX timer: unable to get clk\n");
|
pr_err("i.MX timer: unable to get clk\n");
|
||||||
return;
|
return PTR_ERR(imxtm->clk_per);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_ERR(imxtm->clk_ipg))
|
if (!IS_ERR(imxtm->clk_ipg))
|
||||||
@ -446,8 +448,11 @@ static void __init _mxc_timer_init(struct imx_timer *imxtm)
|
|||||||
imxtm->gpt->gpt_setup_tctl(imxtm);
|
imxtm->gpt->gpt_setup_tctl(imxtm);
|
||||||
|
|
||||||
/* init and register the timer to the framework */
|
/* init and register the timer to the framework */
|
||||||
mxc_clocksource_init(imxtm);
|
ret = mxc_clocksource_init(imxtm);
|
||||||
mxc_clockevent_init(imxtm);
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return mxc_clockevent_init(imxtm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init mxc_timer_init(unsigned long pbase, int irq, enum imx_gpt_type type)
|
void __init mxc_timer_init(unsigned long pbase, int irq, enum imx_gpt_type type)
|
||||||
@ -469,21 +474,27 @@ void __init mxc_timer_init(unsigned long pbase, int irq, enum imx_gpt_type type)
|
|||||||
_mxc_timer_init(imxtm);
|
_mxc_timer_init(imxtm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type type)
|
static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type type)
|
||||||
{
|
{
|
||||||
struct imx_timer *imxtm;
|
struct imx_timer *imxtm;
|
||||||
static int initialized;
|
static int initialized;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Support one instance only */
|
/* Support one instance only */
|
||||||
if (initialized)
|
if (initialized)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
imxtm = kzalloc(sizeof(*imxtm), GFP_KERNEL);
|
imxtm = kzalloc(sizeof(*imxtm), GFP_KERNEL);
|
||||||
BUG_ON(!imxtm);
|
if (!imxtm)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
imxtm->base = of_iomap(np, 0);
|
imxtm->base = of_iomap(np, 0);
|
||||||
WARN_ON(!imxtm->base);
|
if (!imxtm->base)
|
||||||
|
return -ENXIO;
|
||||||
|
|
||||||
imxtm->irq = irq_of_parse_and_map(np, 0);
|
imxtm->irq = irq_of_parse_and_map(np, 0);
|
||||||
|
if (imxtm->irq <= 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
imxtm->clk_ipg = of_clk_get_by_name(np, "ipg");
|
imxtm->clk_ipg = of_clk_get_by_name(np, "ipg");
|
||||||
|
|
||||||
@ -494,22 +505,26 @@ static void __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type
|
|||||||
|
|
||||||
imxtm->type = type;
|
imxtm->type = type;
|
||||||
|
|
||||||
_mxc_timer_init(imxtm);
|
ret = _mxc_timer_init(imxtm);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init imx1_timer_init_dt(struct device_node *np)
|
static int __init imx1_timer_init_dt(struct device_node *np)
|
||||||
{
|
{
|
||||||
mxc_timer_init_dt(np, GPT_TYPE_IMX1);
|
return mxc_timer_init_dt(np, GPT_TYPE_IMX1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init imx21_timer_init_dt(struct device_node *np)
|
static int __init imx21_timer_init_dt(struct device_node *np)
|
||||||
{
|
{
|
||||||
mxc_timer_init_dt(np, GPT_TYPE_IMX21);
|
return mxc_timer_init_dt(np, GPT_TYPE_IMX21);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init imx31_timer_init_dt(struct device_node *np)
|
static int __init imx31_timer_init_dt(struct device_node *np)
|
||||||
{
|
{
|
||||||
enum imx_gpt_type type = GPT_TYPE_IMX31;
|
enum imx_gpt_type type = GPT_TYPE_IMX31;
|
||||||
|
|
||||||
@ -522,23 +537,23 @@ static void __init imx31_timer_init_dt(struct device_node *np)
|
|||||||
if (of_machine_is_compatible("fsl,imx6dl"))
|
if (of_machine_is_compatible("fsl,imx6dl"))
|
||||||
type = GPT_TYPE_IMX6DL;
|
type = GPT_TYPE_IMX6DL;
|
||||||
|
|
||||||
mxc_timer_init_dt(np, type);
|
return mxc_timer_init_dt(np, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init imx6dl_timer_init_dt(struct device_node *np)
|
static int __init imx6dl_timer_init_dt(struct device_node *np)
|
||||||
{
|
{
|
||||||
mxc_timer_init_dt(np, GPT_TYPE_IMX6DL);
|
return mxc_timer_init_dt(np, GPT_TYPE_IMX6DL);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLOCKSOURCE_OF_DECLARE(imx1_timer, "fsl,imx1-gpt", imx1_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx1_timer, "fsl,imx1-gpt", imx1_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx21_timer, "fsl,imx21-gpt", imx21_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx21_timer, "fsl,imx21-gpt", imx21_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx27_timer, "fsl,imx27-gpt", imx21_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx27_timer, "fsl,imx27-gpt", imx21_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx31_timer, "fsl,imx31-gpt", imx31_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx31_timer, "fsl,imx31-gpt", imx31_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx25_timer, "fsl,imx25-gpt", imx31_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx25_timer, "fsl,imx25-gpt", imx31_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx50_timer, "fsl,imx50-gpt", imx31_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx50_timer, "fsl,imx50-gpt", imx31_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx51_timer, "fsl,imx51-gpt", imx31_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx51_timer, "fsl,imx51-gpt", imx31_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx53_timer, "fsl,imx53-gpt", imx31_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx53_timer, "fsl,imx53-gpt", imx31_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx6q_timer, "fsl,imx6q-gpt", imx31_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx6q_timer, "fsl,imx6q-gpt", imx31_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx6dl_timer, "fsl,imx6dl-gpt", imx6dl_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx6dl_timer, "fsl,imx6dl-gpt", imx6dl_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx6sl_timer, "fsl,imx6sl-gpt", imx6dl_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx6sl_timer, "fsl,imx6sl-gpt", imx6dl_timer_init_dt);
|
||||||
CLOCKSOURCE_OF_DECLARE(imx6sx_timer, "fsl,imx6sx-gpt", imx6dl_timer_init_dt);
|
CLOCKSOURCE_OF_DECLARE_RET(imx6sx_timer, "fsl,imx6sx-gpt", imx6dl_timer_init_dt);
|
||||||
|
Loading…
Reference in New Issue
Block a user