2013-10-28 22:49:14

by Laurent Pinchart

[permalink] [raw]
Subject: [PATCH 00/12] Prepare various SH/R Mobile/Car drivers for CCF migration

Hello,

This patch series, based on v3.12-rc7, prepares various Renesas SH-Mobile,
R-Mobile and R-Car drivers for migration to CCF by adding clock prepare and
unprepare support.

The patches are pretty straightforward. Most of the drivers called
clk_enable and clk_disable in sleepable context, I've thus just converted them
to clk_prepare_enable and clk_disable_unprepare.

The clocksource drivers were slightly more complex to handle as clk_enable and
clk_disable were called in non-sleepable context. As the clocksource framework
architecture doesn't provide any sleepable callback in which clocks could be
prepared and unprepared, I've added clk_prepare and clk_unprepare calls in the
probe and suspend/resume handlers (clocksources can't be removed so the remove
handler doesn't need a clk_unprepare call).

I'd like to get all these patches merged in v3.14. As they will need to go
through their respective subsystems' trees, I would appreciate if all
maintainers involved could notify me when they merge patches from this series
in their tree to help me tracking the merge status. I don't plan to send pull
requests individually for these patches, and I will repost patches
individually if changes are requested during review.

Cc: Daniel Lezcano <[email protected]>
Cc: [email protected]
Cc: Tejun Heo <[email protected]>
Cc: [email protected]
Cc: David Airlie <[email protected]>
Cc: [email protected]
Cc: Wolfram Sang <[email protected]>
Cc: [email protected]
Cc: Chris Ball <[email protected]>
Cc: Guennadi Liakhovetski <[email protected]>
Cc: [email protected]
Cc: Felipe Balbi <[email protected]>
Cc: [email protected]
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Yoshihiro Shimoda <[email protected]>
Cc: Jean-Christophe Plagniol-Villard <[email protected]>
Cc: Tomi Valkeinen <[email protected]>
Cc: [email protected]

Laurent Pinchart (12):
clocksource: sh_cmt: Add clk_prepare/unprepare support
clocksource: sh_mtu2: Add clk_prepare/unprepare support
clocksource: sh_tmu: Add clk_prepare/unprepare support
sata_rcar: Convert to clk_prepare/unprepare
drm: shmob_drm: Convert to clk_prepare/unprepare
i2c: sh_mobile: Convert to clk_prepare/unprepare
mmc: sh_mmcif: Convert to clk_prepare/unprepare
mmc: sh_mobile_sdhi: Convert to clk_prepare/unprepare
usb: gadget: r8a66597-udc: Convert to clk_prepare/unprepare
usb: r8a66597-hcd: Convert to clk_prepare/unprepare
fbdev: shmobile-hdmi: Convert to clk_prepare/unprepare
fbdev: shmobile-lcdcfb: Convert to clk_prepare/unprepare

drivers/ata/sata_rcar.c | 10 +++++-----
drivers/clocksource/sh_cmt.c | 20 ++++++++++++++++----
drivers/clocksource/sh_mtu2.c | 16 ++++++++++++++--
drivers/clocksource/sh_tmu.c | 20 +++++++++++++++++---
drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 4 ++--
drivers/i2c/busses/i2c-sh_mobile.c | 8 ++++----
drivers/mmc/host/sh_mmcif.c | 12 ++++++------
drivers/mmc/host/sh_mobile_sdhi.c | 4 ++--
drivers/usb/gadget/r8a66597-udc.c | 6 +++---
drivers/usb/host/r8a66597-hcd.c | 4 ++--
drivers/video/sh_mobile_hdmi.c | 6 +++---
drivers/video/sh_mobile_lcdcfb.c | 4 ++--
12 files changed, 76 insertions(+), 38 deletions(-)

--
Regards,

Laurent Pinchart


2013-10-28 22:49:17

by Laurent Pinchart

[permalink] [raw]
Subject: [PATCH 03/12] clocksource: sh_tmu: Add clk_prepare/unprepare support

Prepare the clock at probe time, as there is no other appropriate place
in the driver where we're allowed to sleep.

Cc: Daniel Lezcano <[email protected]>
Cc: [email protected]
Signed-off-by: Laurent Pinchart <[email protected]>
---
drivers/clocksource/sh_tmu.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 78b8dae..63557cd 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -472,12 +472,26 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev)
ret = PTR_ERR(p->clk);
goto err1;
}
+
+ ret = clk_prepare(p->clk);
+ if (ret < 0)
+ goto err2;
+
p->cs_enabled = false;
p->enable_count = 0;

- return sh_tmu_register(p, (char *)dev_name(&p->pdev->dev),
- cfg->clockevent_rating,
- cfg->clocksource_rating);
+ ret = sh_tmu_register(p, (char *)dev_name(&p->pdev->dev),
+ cfg->clockevent_rating,
+ cfg->clocksource_rating);
+ if (ret < 0)
+ goto err3;
+
+ return 0;
+
+ err3:
+ clk_unprepare(p->clk);
+ err2:
+ clk_put(p->clk);
err1:
iounmap(p->mapbase);
err0:
--
1.8.1.5

2013-10-28 22:49:15

by Laurent Pinchart

[permalink] [raw]
Subject: [PATCH 02/12] clocksource: sh_mtu2: Add clk_prepare/unprepare support

Prepare the clock at probe time, as there is no other appropriate place
in the driver where we're allowed to sleep.

Cc: Daniel Lezcano <[email protected]>
Cc: [email protected]
Signed-off-by: Laurent Pinchart <[email protected]>
---
drivers/clocksource/sh_mtu2.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index 4aac9ee..3cf1283 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -313,8 +313,20 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev)
goto err1;
}

- return sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev),
- cfg->clockevent_rating);
+ ret = clk_prepare(p->clk);
+ if (ret < 0)
+ goto err2;
+
+ ret = sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev),
+ cfg->clockevent_rating);
+ if (ret < 0)
+ goto err3;
+
+ return 0;
+ err3:
+ clk_unprepare(p->clk);
+ err2:
+ clk_put(p->clk);
err1:
iounmap(p->mapbase);
err0:
--
1.8.1.5

2013-10-28 22:49:12

by Laurent Pinchart

[permalink] [raw]
Subject: [PATCH 01/12] clocksource: sh_cmt: Add clk_prepare/unprepare support

Prepare the clock at probe time, as there is no other appropriate place
in the driver where we're allowed to sleep.

Cc: Daniel Lezcano <[email protected]>
Cc: [email protected]
Signed-off-by: Laurent Pinchart <[email protected]>
---
drivers/clocksource/sh_cmt.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 0965e98..940341a 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -634,12 +634,18 @@ static int sh_cmt_clock_event_next(unsigned long delta,

static void sh_cmt_clock_event_suspend(struct clock_event_device *ced)
{
- pm_genpd_syscore_poweroff(&ced_to_sh_cmt(ced)->pdev->dev);
+ struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
+
+ pm_genpd_syscore_poweroff(&p->pdev->dev);
+ clk_unprepare(p->clk);
}

static void sh_cmt_clock_event_resume(struct clock_event_device *ced)
{
- pm_genpd_syscore_poweron(&ced_to_sh_cmt(ced)->pdev->dev);
+ struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
+
+ clk_prepare(p->clk);
+ pm_genpd_syscore_poweron(&p->pdev->dev);
}

static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
@@ -737,6 +743,10 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
goto err2;
}

+ ret = clk_prepare(p->clk);
+ if (ret < 0)
+ goto err3;
+
if (res2 && (resource_size(res2) == 4)) {
/* assume both CMSTR and CMCSR to be 32-bit */
p->read_control = sh_cmt_read32;
@@ -773,19 +783,21 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
cfg->clocksource_rating);
if (ret) {
dev_err(&p->pdev->dev, "registration failed\n");
- goto err3;
+ goto err4;
}
p->cs_enabled = false;

ret = setup_irq(irq, &p->irqaction);
if (ret) {
dev_err(&p->pdev->dev, "failed to request irq %d\n", irq);
- goto err3;
+ goto err4;
}

platform_set_drvdata(pdev, p);

return 0;
+err4:
+ clk_unprepare(p->clk);
err3:
clk_put(p->clk);
err2:
--
1.8.1.5

2013-10-29 05:55:40

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH 01/12] clocksource: sh_cmt: Add clk_prepare/unprepare support

On Mon, Oct 28, 2013 at 11:49:18PM +0100, Laurent Pinchart wrote:
> Prepare the clock at probe time, as there is no other appropriate place
> in the driver where we're allowed to sleep.
>
> Cc: Daniel Lezcano <[email protected]>
> Cc: [email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>

Thanks Laurent,

I have queued this up in the clocksources branch of my renesas tree.
I will send a pull request to Mike once v3.13-rc1 has hit the shelves.
Mike, please let me know if you would prefer something earlier than that.

> ---
> drivers/clocksource/sh_cmt.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
> index 0965e98..940341a 100644
> --- a/drivers/clocksource/sh_cmt.c
> +++ b/drivers/clocksource/sh_cmt.c
> @@ -634,12 +634,18 @@ static int sh_cmt_clock_event_next(unsigned long delta,
>
> static void sh_cmt_clock_event_suspend(struct clock_event_device *ced)
> {
> - pm_genpd_syscore_poweroff(&ced_to_sh_cmt(ced)->pdev->dev);
> + struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
> +
> + pm_genpd_syscore_poweroff(&p->pdev->dev);
> + clk_unprepare(p->clk);
> }
>
> static void sh_cmt_clock_event_resume(struct clock_event_device *ced)
> {
> - pm_genpd_syscore_poweron(&ced_to_sh_cmt(ced)->pdev->dev);
> + struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
> +
> + clk_prepare(p->clk);
> + pm_genpd_syscore_poweron(&p->pdev->dev);
> }
>
> static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
> @@ -737,6 +743,10 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
> goto err2;
> }
>
> + ret = clk_prepare(p->clk);
> + if (ret < 0)
> + goto err3;
> +
> if (res2 && (resource_size(res2) == 4)) {
> /* assume both CMSTR and CMCSR to be 32-bit */
> p->read_control = sh_cmt_read32;
> @@ -773,19 +783,21 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
> cfg->clocksource_rating);
> if (ret) {
> dev_err(&p->pdev->dev, "registration failed\n");
> - goto err3;
> + goto err4;
> }
> p->cs_enabled = false;
>
> ret = setup_irq(irq, &p->irqaction);
> if (ret) {
> dev_err(&p->pdev->dev, "failed to request irq %d\n", irq);
> - goto err3;
> + goto err4;
> }
>
> platform_set_drvdata(pdev, p);
>
> return 0;
> +err4:
> + clk_unprepare(p->clk);
> err3:
> clk_put(p->clk);
> err2:
> --
> 1.8.1.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

2013-10-29 05:55:54

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH 02/12] clocksource: sh_mtu2: Add clk_prepare/unprepare support

On Mon, Oct 28, 2013 at 11:49:19PM +0100, Laurent Pinchart wrote:
> Prepare the clock at probe time, as there is no other appropriate place
> in the driver where we're allowed to sleep.
>
> Cc: Daniel Lezcano <[email protected]>
> Cc: [email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>
> ---
> drivers/clocksource/sh_mtu2.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)

Thanks Laurent,

I have queued this up in the clocksources branch of my renesas tree.
I will send a pull request to Mike once v3.13-rc1 has hit the shelves.
Mike, please let me know if you would prefer something earlier than that.

2013-10-29 05:56:04

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH 03/12] clocksource: sh_tmu: Add clk_prepare/unprepare support

On Mon, Oct 28, 2013 at 11:49:20PM +0100, Laurent Pinchart wrote:
> Prepare the clock at probe time, as there is no other appropriate place
> in the driver where we're allowed to sleep.
>
> Cc: Daniel Lezcano <[email protected]>
> Cc: [email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>
> ---
> drivers/clocksource/sh_tmu.c | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)

Thanks Laurent,

I have queued this up in the clocksources branch of my renesas tree.
I will send a pull request to Mike once v3.13-rc1 has hit the shelves.
Mike, please let me know if you would prefer something earlier than that.

2013-10-29 09:54:41

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 01/12] clocksource: sh_cmt: Add clk_prepare/unprepare support

Hi Simon,

On Tuesday 29 October 2013 14:55:35 Simon Horman wrote:
> On Mon, Oct 28, 2013 at 11:49:18PM +0100, Laurent Pinchart wrote:
> > Prepare the clock at probe time, as there is no other appropriate place
> > in the driver where we're allowed to sleep.
> >
> > Cc: Daniel Lezcano <[email protected]>
> > Cc: [email protected]
> > Signed-off-by: Laurent Pinchart
> > <[email protected]>
>
> Thanks Laurent,
>
> I have queued this up in the clocksources branch of my renesas tree.
> I will send a pull request to Mike once v3.13-rc1 has hit the shelves.
> Mike, please let me know if you would prefer something earlier than that.

I thought the clocksource patches had to go through Daniel's tree. If you can
take them directly that's easier, so I'm fine with that. Does this imply your
Acked-by (for patches 01 to 03) ?

> > ---
> >
> > drivers/clocksource/sh_cmt.c | 20 ++++++++++++++++----
> > 1 file changed, 16 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
> > index 0965e98..940341a 100644
> > --- a/drivers/clocksource/sh_cmt.c
> > +++ b/drivers/clocksource/sh_cmt.c
> > @@ -634,12 +634,18 @@ static int sh_cmt_clock_event_next(unsigned long
> > delta,>
> > static void sh_cmt_clock_event_suspend(struct clock_event_device *ced)
> > {
> > - pm_genpd_syscore_poweroff(&ced_to_sh_cmt(ced)->pdev->dev);
> > + struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
> > +
> > + pm_genpd_syscore_poweroff(&p->pdev->dev);
> > + clk_unprepare(p->clk);
> > }
> >
> > static void sh_cmt_clock_event_resume(struct clock_event_device *ced)
> > {
> > - pm_genpd_syscore_poweron(&ced_to_sh_cmt(ced)->pdev->dev);
> > + struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
> > +
> > + clk_prepare(p->clk);
> > + pm_genpd_syscore_poweron(&p->pdev->dev);
> > }
> >
> > static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
> >
> > @@ -737,6 +743,10 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct
> > platform_device *pdev)>
> > goto err2;
> > }
> >
> > + ret = clk_prepare(p->clk);
> > + if (ret < 0)
> > + goto err3;
> > +
> > if (res2 && (resource_size(res2) == 4)) {
> > /* assume both CMSTR and CMCSR to be 32-bit */
> > p->read_control = sh_cmt_read32;
> > @@ -773,19 +783,21 @@ static int sh_cmt_setup(struct sh_cmt_priv *p,
> > struct platform_device *pdev)>
> > cfg->clocksource_rating);
> > if (ret) {
> > dev_err(&p->pdev->dev, "registration failed\n");
> > - goto err3;
> > + goto err4;
> > }
> > p->cs_enabled = false;
> >
> > ret = setup_irq(irq, &p->irqaction);
> > if (ret) {
> > dev_err(&p->pdev->dev, "failed to request irq %d\n", irq);
> > - goto err3;
> > + goto err4;
> > }
> >
> > platform_set_drvdata(pdev, p);
> >
> > return 0;
> >
> > +err4:
> > + clk_unprepare(p->clk);
> > err3:
> > clk_put(p->clk);
> > err2:
--
Regards,

Laurent Pinchart

2013-10-29 11:15:11

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH 02/12] clocksource: sh_mtu2: Add clk_prepare/unprepare support

Hello.

On 29-10-2013 2:49, Laurent Pinchart wrote:

> Prepare the clock at probe time, as there is no other appropriate place
> in the driver where we're allowed to sleep.

> Cc: Daniel Lezcano <[email protected]>
> Cc: [email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>
> ---
> drivers/clocksource/sh_mtu2.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)

> diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
> index 4aac9ee..3cf1283 100644
> --- a/drivers/clocksource/sh_mtu2.c
> +++ b/drivers/clocksource/sh_mtu2.c
> @@ -313,8 +313,20 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev)
> goto err1;
> }
>
> - return sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev),
> - cfg->clockevent_rating);
> + ret = clk_prepare(p->clk);
> + if (ret < 0)
> + goto err2;
> +
> + ret = sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev),
> + cfg->clockevent_rating);
> + if (ret < 0)
> + goto err3;
> +
> + return 0;
> + err3:
> + clk_unprepare(p->clk);
> + err2:
> + clk_put(p->clk);

This one seems to be a fix and so needs to be in a separate patch...

WBR, Sergei

2013-10-29 11:17:02

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH 03/12] clocksource: sh_tmu: Add clk_prepare/unprepare support

On 29-10-2013 2:49, Laurent Pinchart wrote:

> Prepare the clock at probe time, as there is no other appropriate place
> in the driver where we're allowed to sleep.

> Cc: Daniel Lezcano <[email protected]>
> Cc: [email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>
> ---
> drivers/clocksource/sh_tmu.c | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)

> diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
> index 78b8dae..63557cd 100644
> --- a/drivers/clocksource/sh_tmu.c
> +++ b/drivers/clocksource/sh_tmu.c
> @@ -472,12 +472,26 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev)
> ret = PTR_ERR(p->clk);
> goto err1;
> }
> +
> + ret = clk_prepare(p->clk);
> + if (ret < 0)
> + goto err2;
> +
> p->cs_enabled = false;
> p->enable_count = 0;
>
> - return sh_tmu_register(p, (char *)dev_name(&p->pdev->dev),
> - cfg->clockevent_rating,
> - cfg->clocksource_rating);
> + ret = sh_tmu_register(p, (char *)dev_name(&p->pdev->dev),
> + cfg->clockevent_rating,
> + cfg->clocksource_rating);
> + if (ret < 0)
> + goto err3;
> +
> + return 0;
> +
> + err3:
> + clk_unprepare(p->clk);
> + err2:
> + clk_put(p->clk);

This one seems to be a fix, and should be done separately.

WBR, Sergei

2013-10-29 13:24:34

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 02/12] clocksource: sh_mtu2: Add clk_prepare/unprepare support

Hi Sergei,

On Tuesday 29 October 2013 15:15:09 Sergei Shtylyov wrote:
> On 29-10-2013 2:49, Laurent Pinchart wrote:
> > Prepare the clock at probe time, as there is no other appropriate place
> > in the driver where we're allowed to sleep.
> >
> > Cc: Daniel Lezcano <[email protected]>
> > Cc: [email protected]
> > Signed-off-by: Laurent Pinchart
> > <[email protected]>
> > ---
> >
> > drivers/clocksource/sh_mtu2.c | 16 ++++++++++++++--
> > 1 file changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
> > index 4aac9ee..3cf1283 100644
> > --- a/drivers/clocksource/sh_mtu2.c
> > +++ b/drivers/clocksource/sh_mtu2.c
> > @@ -313,8 +313,20 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p,
> > struct platform_device *pdev)>
> > goto err1;
> > }
> >
> > - return sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev),
> > - cfg->clockevent_rating);
> > + ret = clk_prepare(p->clk);
> > + if (ret < 0)
> > + goto err2;
> > +
> > + ret = sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev),
> > + cfg->clockevent_rating);
> > + if (ret < 0)
> > + goto err3;
> > +
> > + return 0;
> > + err3:
> > + clk_unprepare(p->clk);
> > + err2:
> > + clk_put(p->clk);
>
> This one seems to be a fix and so needs to be in a separate patch...

I'll split the patch and repost (same for 03/12)

--
Regards,

Laurent Pinchart

2013-10-29 14:30:25

by Laurent Pinchart

[permalink] [raw]
Subject: [PATCH v2 1/2] clocksource: sh_mtu2: Release clock when sh_mtu2_register() fails

Fix the probe error path to release the clock resource when the
sh_mtu2_register() call fails.

Cc: Daniel Lezcano <[email protected]>
Cc: [email protected]
Signed-off-by: Laurent Pinchart <[email protected]>
---
drivers/clocksource/sh_mtu2.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index 4aac9ee..e6cfb32 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -313,8 +313,15 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev)
goto err1;
}

- return sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev),
- cfg->clockevent_rating);
+ ret = sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev),
+ cfg->clockevent_rating);
+ if (ret < 0)
+ goto err2;
+
+ return 0;
+
+ err2:
+ clk_put(p->clk);
err1:
iounmap(p->mapbase);
err0:
--
1.8.1.5

2013-10-29 14:30:24

by Laurent Pinchart

[permalink] [raw]
Subject: [PATCH v2 2/2] clocksource: sh_mtu2: Add clk_prepare/unprepare support

Prepare the clock at probe time, as there is no other appropriate place
in the driver where we're allowed to sleep.

Cc: Daniel Lezcano <[email protected]>
Cc: [email protected]
Signed-off-by: Laurent Pinchart <[email protected]>
---
drivers/clocksource/sh_mtu2.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index e6cfb32..3cf1283 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -313,13 +313,18 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev)
goto err1;
}

+ ret = clk_prepare(p->clk);
+ if (ret < 0)
+ goto err2;
+
ret = sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev),
cfg->clockevent_rating);
if (ret < 0)
- goto err2;
+ goto err3;

return 0;
-
+ err3:
+ clk_unprepare(p->clk);
err2:
clk_put(p->clk);
err1:
--
1.8.1.5

2013-10-29 14:31:20

by Laurent Pinchart

[permalink] [raw]
Subject: [PATCH v2 2/2] clocksource: sh_tmu: Add clk_prepare/unprepare support

Prepare the clock at probe time, as there is no other appropriate place
in the driver where we're allowed to sleep.

Cc: Daniel Lezcano <[email protected]>
Cc: [email protected]
Signed-off-by: Laurent Pinchart <[email protected]>
---
drivers/clocksource/sh_tmu.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 1597837..63557cd 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -472,6 +472,11 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev)
ret = PTR_ERR(p->clk);
goto err1;
}
+
+ ret = clk_prepare(p->clk);
+ if (ret < 0)
+ goto err2;
+
p->cs_enabled = false;
p->enable_count = 0;

@@ -479,10 +484,12 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev)
cfg->clockevent_rating,
cfg->clocksource_rating);
if (ret < 0)
- goto err2;
+ goto err3;

return 0;

+ err3:
+ clk_unprepare(p->clk);
err2:
clk_put(p->clk);
err1:
--
1.8.1.5

2013-10-29 14:31:18

by Laurent Pinchart

[permalink] [raw]
Subject: [PATCH v2 1/2] clocksource: sh_tmu: Release clock when sh_tmu_register() fails

Fix the probe error path to release the clock resource when the
sh_tmu_register() call fails.

Cc: Daniel Lezcano <[email protected]>
Cc: [email protected]
Signed-off-by: Laurent Pinchart <[email protected]>
---
drivers/clocksource/sh_tmu.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 78b8dae..1597837 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -475,9 +475,16 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev)
p->cs_enabled = false;
p->enable_count = 0;

- return sh_tmu_register(p, (char *)dev_name(&p->pdev->dev),
- cfg->clockevent_rating,
- cfg->clocksource_rating);
+ ret = sh_tmu_register(p, (char *)dev_name(&p->pdev->dev),
+ cfg->clockevent_rating,
+ cfg->clocksource_rating);
+ if (ret < 0)
+ goto err2;
+
+ return 0;
+
+ err2:
+ clk_put(p->clk);
err1:
iounmap(p->mapbase);
err0:
--
1.8.1.5

2013-10-30 00:10:25

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH 01/12] clocksource: sh_cmt: Add clk_prepare/unprepare support

On Tue, Oct 29, 2013 at 10:55:05AM +0100, Laurent Pinchart wrote:
> Hi Simon,
>
> On Tuesday 29 October 2013 14:55:35 Simon Horman wrote:
> > On Mon, Oct 28, 2013 at 11:49:18PM +0100, Laurent Pinchart wrote:
> > > Prepare the clock at probe time, as there is no other appropriate place
> > > in the driver where we're allowed to sleep.
> > >
> > > Cc: Daniel Lezcano <[email protected]>
> > > Cc: [email protected]
> > > Signed-off-by: Laurent Pinchart
> > > <[email protected]>
> >
> > Thanks Laurent,
> >
> > I have queued this up in the clocksources branch of my renesas tree.
> > I will send a pull request to Mike once v3.13-rc1 has hit the shelves.
> > Mike, please let me know if you would prefer something earlier than that.
>
> I thought the clocksource patches had to go through Daniel's tree. If you can
> take them directly that's easier, so I'm fine with that. Does this imply your
> Acked-by (for patches 01 to 03) ?

Sorry, my mistake. The do go through Daniel. As a convenience
I have been picking up Renesas clocksource patches and passing
them on to Daniel. I'm happy to keep doing this. And I'm happy to
go the next step and add some entries to MAINTAINERS if that is
useful to others.

As I mentioned above I have queued these up (though not yet pushed them
as I got bogged down yesterday afternoon). But if you would
prefer Daniel to take them directly then please use the following:

Patches 01 - 03:

Acked-by: Simon Horman <[email protected]>

>
> > > ---
> > >
> > > drivers/clocksource/sh_cmt.c | 20 ++++++++++++++++----
> > > 1 file changed, 16 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
> > > index 0965e98..940341a 100644
> > > --- a/drivers/clocksource/sh_cmt.c
> > > +++ b/drivers/clocksource/sh_cmt.c
> > > @@ -634,12 +634,18 @@ static int sh_cmt_clock_event_next(unsigned long
> > > delta,>
> > > static void sh_cmt_clock_event_suspend(struct clock_event_device *ced)
> > > {
> > > - pm_genpd_syscore_poweroff(&ced_to_sh_cmt(ced)->pdev->dev);
> > > + struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
> > > +
> > > + pm_genpd_syscore_poweroff(&p->pdev->dev);
> > > + clk_unprepare(p->clk);
> > > }
> > >
> > > static void sh_cmt_clock_event_resume(struct clock_event_device *ced)
> > > {
> > > - pm_genpd_syscore_poweron(&ced_to_sh_cmt(ced)->pdev->dev);
> > > + struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
> > > +
> > > + clk_prepare(p->clk);
> > > + pm_genpd_syscore_poweron(&p->pdev->dev);
> > > }
> > >
> > > static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
> > >
> > > @@ -737,6 +743,10 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct
> > > platform_device *pdev)>
> > > goto err2;
> > > }
> > >
> > > + ret = clk_prepare(p->clk);
> > > + if (ret < 0)
> > > + goto err3;
> > > +
> > > if (res2 && (resource_size(res2) == 4)) {
> > > /* assume both CMSTR and CMCSR to be 32-bit */
> > > p->read_control = sh_cmt_read32;
> > > @@ -773,19 +783,21 @@ static int sh_cmt_setup(struct sh_cmt_priv *p,
> > > struct platform_device *pdev)>
> > > cfg->clocksource_rating);
> > > if (ret) {
> > > dev_err(&p->pdev->dev, "registration failed\n");
> > > - goto err3;
> > > + goto err4;
> > > }
> > > p->cs_enabled = false;
> > >
> > > ret = setup_irq(irq, &p->irqaction);
> > > if (ret) {
> > > dev_err(&p->pdev->dev, "failed to request irq %d\n", irq);
> > > - goto err3;
> > > + goto err4;
> > > }
> > >
> > > platform_set_drvdata(pdev, p);
> > >
> > > return 0;
> > >
> > > +err4:
> > > + clk_unprepare(p->clk);
> > > err3:
> > > clk_put(p->clk);
> > > err2:
> --
> Regards,
>
> Laurent Pinchart
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

2013-10-30 00:13:16

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 01/12] clocksource: sh_cmt: Add clk_prepare/unprepare support

Hi Simon,

On Wednesday 30 October 2013 09:10:19 Simon Horman wrote:
> On Tue, Oct 29, 2013 at 10:55:05AM +0100, Laurent Pinchart wrote:
> > On Tuesday 29 October 2013 14:55:35 Simon Horman wrote:
> > > On Mon, Oct 28, 2013 at 11:49:18PM +0100, Laurent Pinchart wrote:
> > > > Prepare the clock at probe time, as there is no other appropriate
> > > > place in the driver where we're allowed to sleep.
> > > >
> > > > Cc: Daniel Lezcano <[email protected]>
> > > > Cc: [email protected]
> > > > Signed-off-by: Laurent Pinchart
> > > > <[email protected]>
> > >
> > > Thanks Laurent,
> > >
> > > I have queued this up in the clocksources branch of my renesas tree.
> > > I will send a pull request to Mike once v3.13-rc1 has hit the shelves.
> > > Mike, please let me know if you would prefer something earlier than
> > > that.
> >
> > I thought the clocksource patches had to go through Daniel's tree. If you
> > can take them directly that's easier, so I'm fine with that. Does this
> > imply your Acked-by (for patches 01 to 03) ?
>
> Sorry, my mistake. The do go through Daniel. As a convenience
> I have been picking up Renesas clocksource patches and passing
> them on to Daniel. I'm happy to keep doing this. And I'm happy to
> go the next step and add some entries to MAINTAINERS if that is
> useful to others.
>
> As I mentioned above I have queued these up (though not yet pushed them
> as I got bogged down yesterday afternoon). But if you would
> prefer Daniel to take them directly then please use the following:
>
> Patches 01 - 03:
>
> Acked-by: Simon Horman <[email protected]>

I'm certainly fine with you picking the patches up, that would be helpful.
Could I ask you to pick v2 up instead though ? :-)

> > > > ---
> > > >
> > > > drivers/clocksource/sh_cmt.c | 20 ++++++++++++++++----
> > > > 1 file changed, 16 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/drivers/clocksource/sh_cmt.c
> > > > b/drivers/clocksource/sh_cmt.c
> > > > index 0965e98..940341a 100644
> > > > --- a/drivers/clocksource/sh_cmt.c
> > > > +++ b/drivers/clocksource/sh_cmt.c
> > > > @@ -634,12 +634,18 @@ static int sh_cmt_clock_event_next(unsigned long
> > > > delta,>
> > > >
> > > > static void sh_cmt_clock_event_suspend(struct clock_event_device
> > > > *ced)
> > > > {
> > > >
> > > > - pm_genpd_syscore_poweroff(&ced_to_sh_cmt(ced)->pdev->dev);
> > > > + struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
> > > > +
> > > > + pm_genpd_syscore_poweroff(&p->pdev->dev);
> > > > + clk_unprepare(p->clk);
> > > >
> > > > }
> > > >
> > > > static void sh_cmt_clock_event_resume(struct clock_event_device *ced)
> > > > {
> > > >
> > > > - pm_genpd_syscore_poweron(&ced_to_sh_cmt(ced)->pdev->dev);
> > > > + struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
> > > > +
> > > > + clk_prepare(p->clk);
> > > > + pm_genpd_syscore_poweron(&p->pdev->dev);
> > > >
> > > > }
> > > >
> > > > static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
> > > >
> > > > @@ -737,6 +743,10 @@ static int sh_cmt_setup(struct sh_cmt_priv *p,
> > > > struct
> > > > platform_device *pdev)>
> > > >
> > > > goto err2;
> > > >
> > > > }
> > > >
> > > > + ret = clk_prepare(p->clk);
> > > > + if (ret < 0)
> > > > + goto err3;
> > > > +
> > > >
> > > > if (res2 && (resource_size(res2) == 4)) {
> > > >
> > > > /* assume both CMSTR and CMCSR to be 32-bit */
> > > > p->read_control = sh_cmt_read32;
> > > >
> > > > @@ -773,19 +783,21 @@ static int sh_cmt_setup(struct sh_cmt_priv *p,
> > > > struct platform_device *pdev)>
> > > >
> > > > cfg->clocksource_rating);
> > > >
> > > > if (ret) {
> > > >
> > > > dev_err(&p->pdev->dev, "registration failed\n");
> > > >
> > > > - goto err3;
> > > > + goto err4;
> > > >
> > > > }
> > > > p->cs_enabled = false;
> > > >
> > > > ret = setup_irq(irq, &p->irqaction);
> > > > if (ret) {
> > > >
> > > > dev_err(&p->pdev->dev, "failed to request irq %d\n", irq);
> > > >
> > > > - goto err3;
> > > > + goto err4;
> > > >
> > > > }
> > > >
> > > > platform_set_drvdata(pdev, p);
> > > >
> > > > return 0;
> > > >
> > > > +err4:
> > > > + clk_unprepare(p->clk);
> > > >
> > > > err3:
> > > > clk_put(p->clk);
> > > >
> > > > err2:
--
Regards,

Laurent Pinchart

2013-10-30 00:27:09

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH 01/12] clocksource: sh_cmt: Add clk_prepare/unprepare support

On Wed, Oct 30, 2013 at 01:13:40AM +0100, Laurent Pinchart wrote:
> Hi Simon,
>
> On Wednesday 30 October 2013 09:10:19 Simon Horman wrote:
> > On Tue, Oct 29, 2013 at 10:55:05AM +0100, Laurent Pinchart wrote:
> > > On Tuesday 29 October 2013 14:55:35 Simon Horman wrote:
> > > > On Mon, Oct 28, 2013 at 11:49:18PM +0100, Laurent Pinchart wrote:
> > > > > Prepare the clock at probe time, as there is no other appropriate
> > > > > place in the driver where we're allowed to sleep.
> > > > >
> > > > > Cc: Daniel Lezcano <[email protected]>
> > > > > Cc: [email protected]
> > > > > Signed-off-by: Laurent Pinchart
> > > > > <[email protected]>
> > > >
> > > > Thanks Laurent,
> > > >
> > > > I have queued this up in the clocksources branch of my renesas tree.
> > > > I will send a pull request to Mike once v3.13-rc1 has hit the shelves.
> > > > Mike, please let me know if you would prefer something earlier than
> > > > that.
> > >
> > > I thought the clocksource patches had to go through Daniel's tree. If you
> > > can take them directly that's easier, so I'm fine with that. Does this
> > > imply your Acked-by (for patches 01 to 03) ?
> >
> > Sorry, my mistake. The do go through Daniel. As a convenience
> > I have been picking up Renesas clocksource patches and passing
> > them on to Daniel. I'm happy to keep doing this. And I'm happy to
> > go the next step and add some entries to MAINTAINERS if that is
> > useful to others.
> >
> > As I mentioned above I have queued these up (though not yet pushed them
> > as I got bogged down yesterday afternoon). But if you would
> > prefer Daniel to take them directly then please use the following:
> >
> > Patches 01 - 03:
> >
> > Acked-by: Simon Horman <[email protected]>
>
> I'm certainly fine with you picking the patches up, that would be helpful.
> Could I ask you to pick v2 up instead though ? :-)

Sure. I have dropped v1 and will pick up v2 when I see them.

2013-10-31 05:23:17

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] clocksource: sh_mtu2: Release clock when sh_mtu2_register() fails

On Tue, Oct 29, 2013 at 03:30:44PM +0100, Laurent Pinchart wrote:
> Fix the probe error path to release the clock resource when the
> sh_mtu2_register() call fails.
>
> Cc: Daniel Lezcano <[email protected]>
> Cc: [email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>

Thanks, I have queued this up.

2013-10-31 05:23:29

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] clocksource: sh_mtu2: Add clk_prepare/unprepare support

On Tue, Oct 29, 2013 at 03:30:45PM +0100, Laurent Pinchart wrote:
> Prepare the clock at probe time, as there is no other appropriate place
> in the driver where we're allowed to sleep.
>
> Cc: Daniel Lezcano <[email protected]>
> Cc: [email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>

Thanks, I have queued this up.

2013-10-31 05:24:01

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] clocksource: sh_tmu: Release clock when sh_tmu_register() fails

On Tue, Oct 29, 2013 at 03:31:36PM +0100, Laurent Pinchart wrote:
> Fix the probe error path to release the clock resource when the
> sh_tmu_register() call fails.
>
> Cc: Daniel Lezcano <[email protected]>
> Cc: [email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>

Thanks, I have queued this up.

2013-10-31 05:24:11

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] clocksource: sh_tmu: Add clk_prepare/unprepare support

On Tue, Oct 29, 2013 at 03:31:37PM +0100, Laurent Pinchart wrote:
> Prepare the clock at probe time, as there is no other appropriate place
> in the driver where we're allowed to sleep.
>
> Cc: Daniel Lezcano <[email protected]>
> Cc: [email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>

Thanks, I have queued this up.