public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Yoshinori Sato <ysato@users.sourceforge.jp>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] h8300: Initialize cleanup and remove module code
Date: Wed, 4 Nov 2015 14:49:53 +0100	[thread overview]
Message-ID: <563A0D01.8000804@linaro.org> (raw)
In-Reply-To: <1446622548-18248-1-git-send-email-ysato@users.sourceforge.jp>

On 11/04/2015 08:35 AM, Yoshinori Sato wrote:
> h8300's clocksource driver cleanup.
> - Use CLOCKSOURCE_OF_DECLARE
> - Remove module exit

Hi Yoshinori,

the patches does not apply on tip/timers/core.

Also it seems to contain changes not related to initialization cleanups 
and module code.

I have a few comment above regarding the initialization.

If you can separate the patches, it will be easier to review.

Thanks.

   -- Daniel

> Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
> ---
>   drivers/clocksource/h8300_timer16.c | 133 ++++++++++++-----------------
>   drivers/clocksource/h8300_timer8.c  | 164 ++++++++++++++----------------------
>   drivers/clocksource/h8300_tpu.c     | 105 ++++++++---------------
>   3 files changed, 151 insertions(+), 251 deletions(-)
>
> diff --git a/drivers/clocksource/h8300_timer16.c b/drivers/clocksource/h8300_timer16.c
> index 82941c1..e2e10cf 100644
> --- a/drivers/clocksource/h8300_timer16.c
> +++ b/drivers/clocksource/h8300_timer16.c
> @@ -17,6 +17,8 @@
>   #include <linux/clk.h>
>   #include <linux/io.h>
>   #include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
>
>   #include <asm/segment.h>
>   #include <asm/irq.h>
> @@ -47,7 +49,6 @@
>   #define ABSOLUTE 1
>
>   struct timer16_priv {
> -	struct platform_device *pdev;
>   	struct clocksource cs;
>   	struct irqaction irqaction;
>   	unsigned long total_cycles;
> @@ -147,43 +148,58 @@ static void timer16_disable(struct clocksource *cs)
>   #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 timer16_priv *p;
> +	struct clk *clk;
> +
> +	clk = of_clk_get(node, 0);
> +	if (IS_ERR(clk)) {
> +		pr_err("failed to get clock for clocksource\n");
> +		return;
> +	}
>
> -	memset(p, 0, sizeof(*p));
> -	p->pdev = pdev;
> +	base[REG_CH] = of_iomap(node, 0);
> +	if (!base[0]) {

if (!base[REG_CH]) {

> +		pr_err("failed to map registers for clocksource\n");
> +		goto free_clk;
> +	}
>
> -	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;
> +	base[REG_COMM] = of_iomap(node, 1);
> +	if (!base[1]) {

if (!base[REG_COMM]) {

> +		pr_err("failed to map registers for clocksource\n");
> +		goto unmap_ch;
>   	}
> -	irq = platform_get_irq(p->pdev, 0);
> +
> +	irq = irq_of_parse_and_map(node, 0);
>   	if (irq < 0) {
> -		dev_err(&p->pdev->dev, "failed to get irq\n");
> -		return irq;
> +		pr_err("failed to get irq for clockevent\n");
> +		goto unmap_comm;
>   	}
>
> -	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);
> +	p = kzalloc(sizeof(*p), GFP_KERNEL);
> +	if (!p) {
> +		pr_err("failed to allocate memory for clocksource\n");

No need to add an error for an allocation error and as the module 
static, this variable could be static also and initialized directly when 
declared.

> +		goto unmap_comm;
>   	}
> -	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;
> +	of_property_read_u32(node, "renesas,channel", &ch);
> +
> +	p->mapbase = (unsigned long)base[REG_CH];
> +	p->mapcommon = (unsigned long)base[REG_COMM];
>   	p->enb = 1 << ch;
>   	p->imfa = 1 << ch;
>   	p->imiea = 1 << (4 + ch);
> -	p->cs.name = pdev->name;
> +
> +	p->irqaction.name = node->name;
> +	p->irqaction.handler = timer16_interrupt;
> +	p->irqaction.dev_id = p;
> +	p->irqaction.flags = IRQF_TIMER;
> +
> +	p->cs.name = node->name;
>   	p->cs.rating = 200;
>   	p->cs.read = timer16_clocksource_read;
>   	p->cs.enable = timer16_enable;
> @@ -191,64 +207,23 @@ static int timer16_setup(struct timer16_priv *p, struct platform_device *pdev)
>   	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);
> +	ret = setup_irq(irq, &p->irqaction);

It is better to keep request_irq.

>   	if (ret < 0) {
> -		dev_err(&p->pdev->dev, "failed to request irq %d\n", irq);
> -		return ret;
> +		pr_err("failed to request irq %d of clocksource\n", irq);
> +		goto free_priv;
>   	}
>
>   	clocksource_register_hz(&p->cs, clk_get_rate(p->clk) / 8);
> -
> -	return 0;
> -}


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


  reply	other threads:[~2015-11-04 13:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04  7:35 [PATCH] h8300: Initialize cleanup and remove module code Yoshinori Sato
2015-11-04 13:49 ` Daniel Lezcano [this message]
2015-11-06  7:03 ` [PATCH v2] h8300: cleanup startup " Yoshinori Sato
2015-11-06 11:37   ` Daniel Lezcano
2015-11-06 16:31     ` [PATCH v3] " Yoshinori Sato
2015-11-06 16:42       ` Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=563A0D01.8000804@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox