Re: [PATCH V2 11/63] clocksource/drivers/digitcolor: Convert init function to return error

2016-06-16 Thread Baruch Siach
Hi Daniel,

On Thu, Jun 16, 2016 at 11:26:30PM +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 

It would be nice to have at least LAKL on Cc of the cover letter as well, so 
we can get the big picture. I found it at 
http://article.gmane.org/gmane.linux.kernel/2246137.

But anyway, for this and the final patch:

Acked-by: Baruch Siach 

Thanks,
baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [PATCH V2 11/63] clocksource/drivers/digitcolor: Convert init function to return error

2016-06-16 Thread Baruch Siach
Hi Daniel,

On Thu, Jun 16, 2016 at 11:26:30PM +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 

It would be nice to have at least LAKL on Cc of the cover letter as well, so 
we can get the big picture. I found it at 
http://article.gmane.org/gmane.linux.kernel/2246137.

But anyway, for this and the final patch:

Acked-by: Baruch Siach 

Thanks,
baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


[PATCH V2 11/63] clocksource/drivers/digitcolor: Convert init function to return error

2016-06-16 Thread Daniel Lezcano
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 
---
 drivers/clocksource/timer-digicolor.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/clocksource/timer-digicolor.c 
b/drivers/clocksource/timer-digicolor.c
index 96bb222..b929061 100644
--- a/drivers/clocksource/timer-digicolor.c
+++ b/drivers/clocksource/timer-digicolor.c
@@ -148,7 +148,7 @@ static u64 notrace digicolor_timer_sched_read(void)
return ~readl(dc_timer_dev.base + COUNT(TIMER_B));
 }
 
-static void __init digicolor_timer_init(struct device_node *node)
+static int __init digicolor_timer_init(struct device_node *node)
 {
unsigned long rate;
struct clk *clk;
@@ -161,19 +161,19 @@ static void __init digicolor_timer_init(struct 
device_node *node)
dc_timer_dev.base = of_iomap(node, 0);
if (!dc_timer_dev.base) {
pr_err("Can't map registers");
-   return;
+   return -ENXIO;
}
 
irq = irq_of_parse_and_map(node, dc_timer_dev.timer_id);
if (irq <= 0) {
pr_err("Can't parse IRQ");
-   return;
+   return -EINVAL;
}
 
clk = of_clk_get(node, 0);
if (IS_ERR(clk)) {
pr_err("Can't get timer clock");
-   return;
+   return PTR_ERR(clk);
}
clk_prepare_enable(clk);
rate = clk_get_rate(clk);
@@ -190,13 +190,17 @@ static void __init digicolor_timer_init(struct 
device_node *node)
ret = request_irq(irq, digicolor_timer_interrupt,
  IRQF_TIMER | IRQF_IRQPOLL, "digicolor_timerC",
  _timer_dev.ce);
-   if (ret)
+   if (ret) {
pr_warn("request of timer irq %d failed (%d)\n", irq, ret);
+   return ret;
+   }
 
dc_timer_dev.ce.cpumask = cpu_possible_mask;
dc_timer_dev.ce.irq = irq;
 
clockevents_config_and_register(_timer_dev.ce, rate, 0, 0x);
+
+   return 0;
 }
-CLOCKSOURCE_OF_DECLARE(conexant_digicolor, "cnxt,cx92755-timer",
+CLOCKSOURCE_OF_DECLARE_RET(conexant_digicolor, "cnxt,cx92755-timer",
   digicolor_timer_init);
-- 
1.9.1



[PATCH V2 11/63] clocksource/drivers/digitcolor: Convert init function to return error

2016-06-16 Thread Daniel Lezcano
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 
---
 drivers/clocksource/timer-digicolor.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/clocksource/timer-digicolor.c 
b/drivers/clocksource/timer-digicolor.c
index 96bb222..b929061 100644
--- a/drivers/clocksource/timer-digicolor.c
+++ b/drivers/clocksource/timer-digicolor.c
@@ -148,7 +148,7 @@ static u64 notrace digicolor_timer_sched_read(void)
return ~readl(dc_timer_dev.base + COUNT(TIMER_B));
 }
 
-static void __init digicolor_timer_init(struct device_node *node)
+static int __init digicolor_timer_init(struct device_node *node)
 {
unsigned long rate;
struct clk *clk;
@@ -161,19 +161,19 @@ static void __init digicolor_timer_init(struct 
device_node *node)
dc_timer_dev.base = of_iomap(node, 0);
if (!dc_timer_dev.base) {
pr_err("Can't map registers");
-   return;
+   return -ENXIO;
}
 
irq = irq_of_parse_and_map(node, dc_timer_dev.timer_id);
if (irq <= 0) {
pr_err("Can't parse IRQ");
-   return;
+   return -EINVAL;
}
 
clk = of_clk_get(node, 0);
if (IS_ERR(clk)) {
pr_err("Can't get timer clock");
-   return;
+   return PTR_ERR(clk);
}
clk_prepare_enable(clk);
rate = clk_get_rate(clk);
@@ -190,13 +190,17 @@ static void __init digicolor_timer_init(struct 
device_node *node)
ret = request_irq(irq, digicolor_timer_interrupt,
  IRQF_TIMER | IRQF_IRQPOLL, "digicolor_timerC",
  _timer_dev.ce);
-   if (ret)
+   if (ret) {
pr_warn("request of timer irq %d failed (%d)\n", irq, ret);
+   return ret;
+   }
 
dc_timer_dev.ce.cpumask = cpu_possible_mask;
dc_timer_dev.ce.irq = irq;
 
clockevents_config_and_register(_timer_dev.ce, rate, 0, 0x);
+
+   return 0;
 }
-CLOCKSOURCE_OF_DECLARE(conexant_digicolor, "cnxt,cx92755-timer",
+CLOCKSOURCE_OF_DECLARE_RET(conexant_digicolor, "cnxt,cx92755-timer",
   digicolor_timer_init);
-- 
1.9.1