Re: [PATCH v2] h8300: cleanup startup and remove module code.

2015-11-06 Thread Daniel Lezcano

On 11/06/2015 08:03 AM, Yoshinori Sato wrote:

h8300's clocksource driver update.
Changes for v1
- Drop non-initialize changes.
- Private data static allocation.
- Avoid magic number.
- Use request_irq.


Hi Yoshinori,

thanks for the changes.

Unfortunately, they don't apply.

You should base your changes on top of:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git tip/timers/core

In order to have the latest changes with the h8300. One of them in the 
removal of the memset.


Regards

  -- Daniel


Signed-off-by: Yoshinori Sato 
---
  drivers/clocksource/h8300_timer16.c | 142 +
  drivers/clocksource/h8300_timer8.c  | 151 
  drivers/clocksource/h8300_tpu.c | 118 ++--
  3 files changed, 144 insertions(+), 267 deletions(-)

diff --git a/drivers/clocksource/h8300_timer16.c 
b/drivers/clocksource/h8300_timer16.c
index 82941c1..cdf0d83 100644
--- a/drivers/clocksource/h8300_timer16.c
+++ b/drivers/clocksource/h8300_timer16.c
@@ -17,6 +17,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 

  #include 
  #include 
@@ -47,9 +49,7 @@
  #define ABSOLUTE 1

  struct timer16_priv {
-   struct platform_device *pdev;
struct clocksource cs;
-   struct irqaction irqaction;
unsigned long total_cycles;
unsigned long mapbase;
unsigned long mapcommon;
@@ -144,111 +144,77 @@ static void timer16_disable(struct clocksource *cs)
p->cs_enabled = false;
  }

+static struct timer16_priv timer16_priv = {
+   .cs = {
+   .name = "h8300_16timer",
+   .rating = 200,
+   .read = timer16_clocksource_read,
+   .enable = timer16_enable,
+   .disable = timer16_disable,
+   .mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8),
+   .flags = CLOCK_SOURCE_IS_CONTINUOUS,
+   },
+};
+
  #define REG_CH   0
  #define REG_COMM 1

-static int timer16_setup(struct timer16_priv *p, struct platform_device *pdev)
+static void __init h8300_16timer_init(struct device_node *node)
  {
-   struct resource *res[2];
+   void __iomem *base[2];
int ret, irq;
unsigned int ch;
+   struct clk *clk;

-   memset(p, 0, sizeof(*p));
-   p->pdev = pdev;
-
-   res[REG_CH] = platform_get_resource(p->pdev,
-   IORESOURCE_MEM, REG_CH);
-   res[REG_COMM] = platform_get_resource(p->pdev,
- IORESOURCE_MEM, REG_COMM);
-   if (!res[REG_CH] || !res[REG_COMM]) {
-   dev_err(&p->pdev->dev, "failed to get I/O memory\n");
-   return -ENXIO;
-   }
-   irq = platform_get_irq(p->pdev, 0);
-   if (irq < 0) {
-   dev_err(&p->pdev->dev, "failed to get irq\n");
-   return irq;
+   clk = of_clk_get(node, 0);
+   if (IS_ERR(clk)) {
+   pr_err("failed to get clock for clocksource\n");
+   return;
}

-   p->clk = clk_get(&p->pdev->dev, "fck");
-   if (IS_ERR(p->clk)) {
-   dev_err(&p->pdev->dev, "can't get clk\n");
-   return PTR_ERR(p->clk);
+   base[REG_CH] = of_iomap(node, 0);
+   if (!base[REG_CH]) {
+   pr_err("failed to map registers for clocksource\n");
+   goto free_clk;
}
-   of_property_read_u32(p->pdev->dev.of_node, "renesas,channel", &ch);
-
-   p->pdev = pdev;
-   p->mapbase = res[REG_CH]->start;
-   p->mapcommon = res[REG_COMM]->start;
-   p->enb = 1 << ch;
-   p->imfa = 1 << ch;
-   p->imiea = 1 << (4 + ch);
-   p->cs.name = pdev->name;
-   p->cs.rating = 200;
-   p->cs.read = timer16_clocksource_read;
-   p->cs.enable = timer16_enable;
-   p->cs.disable = timer16_disable;
-   p->cs.mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
-   p->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS;

-   ret = request_irq(irq, timer16_interrupt,
- IRQF_TIMER, pdev->name, p);
-   if (ret < 0) {
-   dev_err(&p->pdev->dev, "failed to request irq %d\n", irq);
-   return ret;
+   base[REG_COMM] = of_iomap(node, 1);
+   if (!base[REG_COMM]) {
+   pr_err("failed to map registers for clocksource\n");
+   goto unmap_ch;
}

-   clocksource_register_hz(&p->cs, clk_get_rate(p->clk) / 8);
-
-   return 0;
-}
-
-static int timer16_probe(struct platform_device *pdev)
-{
-   struct timer16_priv *p = platform_get_drvdata(pdev);
-
-   if (p) {
-   dev_info(&pdev->dev, "kept as earlytimer\n");
-   return 0;
+   irq = irq_of_parse_and_map(node, 0);
+   if (irq < 0) {
+   pr_err("failed to get irq for clockevent\n");
+   goto unmap_comm;
}

-   p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
-   if (!p)
-   return -ENOM

[PATCH v2] h8300: cleanup startup and remove module code.

2015-11-05 Thread Yoshinori Sato
h8300's clocksource driver update.
Changes for v1
- Drop non-initialize changes.
- Private data static allocation.
- Avoid magic number.
- Use request_irq.

Signed-off-by: Yoshinori Sato 
---
 drivers/clocksource/h8300_timer16.c | 142 +
 drivers/clocksource/h8300_timer8.c  | 151 
 drivers/clocksource/h8300_tpu.c | 118 ++--
 3 files changed, 144 insertions(+), 267 deletions(-)

diff --git a/drivers/clocksource/h8300_timer16.c 
b/drivers/clocksource/h8300_timer16.c
index 82941c1..cdf0d83 100644
--- a/drivers/clocksource/h8300_timer16.c
+++ b/drivers/clocksource/h8300_timer16.c
@@ -17,6 +17,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -47,9 +49,7 @@
 #define ABSOLUTE 1
 
 struct timer16_priv {
-   struct platform_device *pdev;
struct clocksource cs;
-   struct irqaction irqaction;
unsigned long total_cycles;
unsigned long mapbase;
unsigned long mapcommon;
@@ -144,111 +144,77 @@ static void timer16_disable(struct clocksource *cs)
p->cs_enabled = false;
 }
 
+static struct timer16_priv timer16_priv = {
+   .cs = {
+   .name = "h8300_16timer",
+   .rating = 200,
+   .read = timer16_clocksource_read,
+   .enable = timer16_enable,
+   .disable = timer16_disable,
+   .mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8),
+   .flags = CLOCK_SOURCE_IS_CONTINUOUS,
+   },
+};
+
 #define REG_CH   0
 #define REG_COMM 1
 
-static int timer16_setup(struct timer16_priv *p, struct platform_device *pdev)
+static void __init h8300_16timer_init(struct device_node *node)
 {
-   struct resource *res[2];
+   void __iomem *base[2];
int ret, irq;
unsigned int ch;
+   struct clk *clk;
 
-   memset(p, 0, sizeof(*p));
-   p->pdev = pdev;
-
-   res[REG_CH] = platform_get_resource(p->pdev,
-   IORESOURCE_MEM, REG_CH);
-   res[REG_COMM] = platform_get_resource(p->pdev,
- IORESOURCE_MEM, REG_COMM);
-   if (!res[REG_CH] || !res[REG_COMM]) {
-   dev_err(&p->pdev->dev, "failed to get I/O memory\n");
-   return -ENXIO;
-   }
-   irq = platform_get_irq(p->pdev, 0);
-   if (irq < 0) {
-   dev_err(&p->pdev->dev, "failed to get irq\n");
-   return irq;
+   clk = of_clk_get(node, 0);
+   if (IS_ERR(clk)) {
+   pr_err("failed to get clock for clocksource\n");
+   return;
}
 
-   p->clk = clk_get(&p->pdev->dev, "fck");
-   if (IS_ERR(p->clk)) {
-   dev_err(&p->pdev->dev, "can't get clk\n");
-   return PTR_ERR(p->clk);
+   base[REG_CH] = of_iomap(node, 0);
+   if (!base[REG_CH]) {
+   pr_err("failed to map registers for clocksource\n");
+   goto free_clk;
}
-   of_property_read_u32(p->pdev->dev.of_node, "renesas,channel", &ch);
-
-   p->pdev = pdev;
-   p->mapbase = res[REG_CH]->start;
-   p->mapcommon = res[REG_COMM]->start;
-   p->enb = 1 << ch;
-   p->imfa = 1 << ch;
-   p->imiea = 1 << (4 + ch);
-   p->cs.name = pdev->name;
-   p->cs.rating = 200;
-   p->cs.read = timer16_clocksource_read;
-   p->cs.enable = timer16_enable;
-   p->cs.disable = timer16_disable;
-   p->cs.mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
-   p->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS;
 
-   ret = request_irq(irq, timer16_interrupt,
- IRQF_TIMER, pdev->name, p);
-   if (ret < 0) {
-   dev_err(&p->pdev->dev, "failed to request irq %d\n", irq);
-   return ret;
+   base[REG_COMM] = of_iomap(node, 1);
+   if (!base[REG_COMM]) {
+   pr_err("failed to map registers for clocksource\n");
+   goto unmap_ch;
}
 
-   clocksource_register_hz(&p->cs, clk_get_rate(p->clk) / 8);
-
-   return 0;
-}
-
-static int timer16_probe(struct platform_device *pdev)
-{
-   struct timer16_priv *p = platform_get_drvdata(pdev);
-
-   if (p) {
-   dev_info(&pdev->dev, "kept as earlytimer\n");
-   return 0;
+   irq = irq_of_parse_and_map(node, 0);
+   if (irq < 0) {
+   pr_err("failed to get irq for clockevent\n");
+   goto unmap_comm;
}
 
-   p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
-   if (!p)
-   return -ENOMEM;
+   of_property_read_u32(node, "renesas,channel", &ch);
 
-   return timer16_setup(p, pdev);
-}
+   timer16_priv.mapbase = (unsigned long)base[REG_CH];
+   timer16_priv.mapcommon = (unsigned long)base[REG_COMM];
+   timer16_priv.enb = 1 << ch;
+   timer16_priv.imfa = 1 << ch;
+   timer16_priv.imiea = 1 << (4 + ch);
 
-static int ti