linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: dw: support for clockless platforms
@ 2015-01-20 12:57 Heikki Krogerus
  2015-01-20 14:18 ` Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Heikki Krogerus @ 2015-01-20 12:57 UTC (permalink / raw)
  To: Viresh Kumar, Andy Shevchenko; +Cc: Vinod Koul, linux-kernel, dmaengine

When requesting clock in the platform driver, leaving
chip->clk value as NULL if -ENOENT is returned, and
continue. With other errors returning failure. It makes the
driver usable on platforms that do not provide the clock.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/dma/dw/platform.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
index 32ea1ac..b183bc0 100644
--- a/drivers/dma/dw/platform.c
+++ b/drivers/dma/dw/platform.c
@@ -180,8 +180,12 @@ static int dw_probe(struct platform_device *pdev)
 	chip->dev = dev;
 
 	chip->clk = devm_clk_get(chip->dev, "hclk");
-	if (IS_ERR(chip->clk))
-		return PTR_ERR(chip->clk);
+	if (IS_ERR(chip->clk)) {
+		if (PTR_ERR(chip->clk) == -ENOENT)
+			chip->clk = NULL;
+		else
+			return PTR_ERR(chip->clk);
+	}
 	err = clk_prepare_enable(chip->clk);
 	if (err)
 		return err;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: dw: support for clockless platforms
  2015-01-20 12:57 [PATCH] dmaengine: dw: support for clockless platforms Heikki Krogerus
@ 2015-01-20 14:18 ` Andy Shevchenko
  2015-02-11  1:20 ` Vinod Koul
  2015-02-11  2:10 ` Viresh Kumar
  2 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2015-01-20 14:18 UTC (permalink / raw)
  To: Heikki Krogerus; +Cc: Viresh Kumar, Vinod Koul, linux-kernel, dmaengine

On Tue, 2015-01-20 at 14:57 +0200, Heikki Krogerus wrote:
> When requesting clock in the platform driver, leaving
> chip->clk value as NULL if -ENOENT is returned, and
> continue. With other errors returning failure. It makes the
> driver usable on platforms that do not provide the clock.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> ---
>  drivers/dma/dw/platform.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
> index 32ea1ac..b183bc0 100644
> --- a/drivers/dma/dw/platform.c
> +++ b/drivers/dma/dw/platform.c
> @@ -180,8 +180,12 @@ static int dw_probe(struct platform_device *pdev)
>  	chip->dev = dev;
>  
>  	chip->clk = devm_clk_get(chip->dev, "hclk");
> -	if (IS_ERR(chip->clk))
> -		return PTR_ERR(chip->clk);
> +	if (IS_ERR(chip->clk)) {
> +		if (PTR_ERR(chip->clk) == -ENOENT)
> +			chip->clk = NULL;
> +		else
> +			return PTR_ERR(chip->clk);
> +	}
>  	err = clk_prepare_enable(chip->clk);
>  	if (err)
>  		return err;


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: dw: support for clockless platforms
  2015-01-20 12:57 [PATCH] dmaengine: dw: support for clockless platforms Heikki Krogerus
  2015-01-20 14:18 ` Andy Shevchenko
@ 2015-02-11  1:20 ` Vinod Koul
  2015-02-11  2:10 ` Viresh Kumar
  2 siblings, 0 replies; 7+ messages in thread
From: Vinod Koul @ 2015-02-11  1:20 UTC (permalink / raw)
  To: Heikki Krogerus; +Cc: Viresh Kumar, Andy Shevchenko, linux-kernel, dmaengine

On Tue, Jan 20, 2015 at 02:57:57PM +0200, Heikki Krogerus wrote:
> When requesting clock in the platform driver, leaving
> chip->clk value as NULL if -ENOENT is returned, and
> continue. With other errors returning failure. It makes the
> driver usable on platforms that do not provide the clock.
Applied, thanks

-- 
~Vinod


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: dw: support for clockless platforms
  2015-01-20 12:57 [PATCH] dmaengine: dw: support for clockless platforms Heikki Krogerus
  2015-01-20 14:18 ` Andy Shevchenko
  2015-02-11  1:20 ` Vinod Koul
@ 2015-02-11  2:10 ` Viresh Kumar
  2015-02-11 12:02   ` Andy Shevchenko
  2 siblings, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2015-02-11  2:10 UTC (permalink / raw)
  To: Heikki Krogerus, Russell King
  Cc: Andy Shevchenko, Vinod Koul, linux-kernel, dmaengine

On Tue, Jan 20, 2015 at 8:57 PM, Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
> When requesting clock in the platform driver, leaving
> chip->clk value as NULL if -ENOENT is returned, and
> continue. With other errors returning failure. It makes the
> driver usable on platforms that do not provide the clock.
>
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  drivers/dma/dw/platform.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
> index 32ea1ac..b183bc0 100644
> --- a/drivers/dma/dw/platform.c
> +++ b/drivers/dma/dw/platform.c
> @@ -180,8 +180,12 @@ static int dw_probe(struct platform_device *pdev)
>         chip->dev = dev;
>
>         chip->clk = devm_clk_get(chip->dev, "hclk");
> -       if (IS_ERR(chip->clk))
> -               return PTR_ERR(chip->clk);
> +       if (IS_ERR(chip->clk)) {
> +               if (PTR_ERR(chip->clk) == -ENOENT)
> +                       chip->clk = NULL;

This is wrong and reasons are mentioned in this thread:

http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/088437.html

You don't need to set it to NULL, if CONFIG_HAVE_CLK isn't set
the dummy routines would take care of it.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: dw: support for clockless platforms
  2015-02-11  2:10 ` Viresh Kumar
@ 2015-02-11 12:02   ` Andy Shevchenko
  2015-02-11 12:07     ` Russell King - ARM Linux
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2015-02-11 12:02 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Heikki Krogerus, Russell King, Vinod Koul, linux-kernel, dmaengine

On Wed, 2015-02-11 at 10:10 +0800, Viresh Kumar wrote:
> On Tue, Jan 20, 2015 at 8:57 PM, Heikki Krogerus
> <heikki.krogerus@linux.intel.com> wrote:
> > When requesting clock in the platform driver, leaving
> > chip->clk value as NULL if -ENOENT is returned, and
> > continue. With other errors returning failure. It makes the
> > driver usable on platforms that do not provide the clock.
> >
> > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > ---
> >  drivers/dma/dw/platform.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
> > index 32ea1ac..b183bc0 100644
> > --- a/drivers/dma/dw/platform.c
> > +++ b/drivers/dma/dw/platform.c
> > @@ -180,8 +180,12 @@ static int dw_probe(struct platform_device *pdev)
> >         chip->dev = dev;
> >
> >         chip->clk = devm_clk_get(chip->dev, "hclk");
> > -       if (IS_ERR(chip->clk))
> > -               return PTR_ERR(chip->clk);
> > +       if (IS_ERR(chip->clk)) {
> > +               if (PTR_ERR(chip->clk) == -ENOENT)
> > +                       chip->clk = NULL;
> 
> This is wrong and reasons are mentioned in this thread:
> 
> http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/088437.html

Thanks for the link.

> 
> You don't need to set it to NULL, if CONFIG_HAVE_CLK isn't set
> the dummy routines would take care of it.

Yeah, but in our case we have CONFIG_HAVE_CLK=y and no clk is provided
since IP is clockless. What could you suggest to do in such case?

-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: dw: support for clockless platforms
  2015-02-11 12:02   ` Andy Shevchenko
@ 2015-02-11 12:07     ` Russell King - ARM Linux
  2015-02-11 12:19       ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Russell King - ARM Linux @ 2015-02-11 12:07 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Viresh Kumar, Heikki Krogerus, Vinod Koul, linux-kernel, dmaengine

On Wed, Feb 11, 2015 at 02:02:39PM +0200, Andy Shevchenko wrote:
> On Wed, 2015-02-11 at 10:10 +0800, Viresh Kumar wrote:
> > >         chip->clk = devm_clk_get(chip->dev, "hclk");
> > > -       if (IS_ERR(chip->clk))
> > > -               return PTR_ERR(chip->clk);
> > > +       if (IS_ERR(chip->clk)) {
> > > +               if (PTR_ERR(chip->clk) == -ENOENT)
> > > +                       chip->clk = NULL;
> > 
> > You don't need to set it to NULL, if CONFIG_HAVE_CLK isn't set
> > the dummy routines would take care of it.
> 
> Yeah, but in our case we have CONFIG_HAVE_CLK=y and no clk is provided
> since IP is clockless. What could you suggest to do in such case?

	chip->clk = devm_clk_get(chip->dev, "hclk");
	if (IS_ERR(chip->clk) && PTR_ERR(chip->clk) != -ENOENT)
		return PTR_ERR(chip->clk);

You can then test for the presence of a clk via IS_ERR(chip->clk).

I'm just debating whether we should add a clk_is_valid() inline function
to linux/clk.h to avoid these shouting tests, and make it easier for
people test this in a generic manner.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dmaengine: dw: support for clockless platforms
  2015-02-11 12:07     ` Russell King - ARM Linux
@ 2015-02-11 12:19       ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2015-02-11 12:19 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Viresh Kumar, Heikki Krogerus, Vinod Koul, linux-kernel, dmaengine

On Wed, 2015-02-11 at 12:07 +0000, Russell King - ARM Linux wrote:
> On Wed, Feb 11, 2015 at 02:02:39PM +0200, Andy Shevchenko wrote:
> > On Wed, 2015-02-11 at 10:10 +0800, Viresh Kumar wrote:
> > > >         chip->clk = devm_clk_get(chip->dev, "hclk");
> > > > -       if (IS_ERR(chip->clk))
> > > > -               return PTR_ERR(chip->clk);
> > > > +       if (IS_ERR(chip->clk)) {
> > > > +               if (PTR_ERR(chip->clk) == -ENOENT)
> > > > +                       chip->clk = NULL;
> > > 
> > > You don't need to set it to NULL, if CONFIG_HAVE_CLK isn't set
> > > the dummy routines would take care of it.
> > 
> > Yeah, but in our case we have CONFIG_HAVE_CLK=y and no clk is provided
> > since IP is clockless. What could you suggest to do in such case?
> 
> 	chip->clk = devm_clk_get(chip->dev, "hclk");
> 	if (IS_ERR(chip->clk) && PTR_ERR(chip->clk) != -ENOENT)
> 		return PTR_ERR(chip->clk);
> 
> You can then test for the presence of a clk via IS_ERR(chip->clk).
> 
> I'm just debating whether we should add a clk_is_valid() inline function
> to linux/clk.h to avoid these shouting tests, and make it easier for
> people test this in a generic manner.

I guess clock framework may handle whatever is gotten from clk_get(). 
In driver much cleaner to use direct calls with exceptions (like you
can't get a valid clock rate from non-existing clock).
So, what about just passing by the error code and doing nothing?

-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-02-11 12:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-20 12:57 [PATCH] dmaengine: dw: support for clockless platforms Heikki Krogerus
2015-01-20 14:18 ` Andy Shevchenko
2015-02-11  1:20 ` Vinod Koul
2015-02-11  2:10 ` Viresh Kumar
2015-02-11 12:02   ` Andy Shevchenko
2015-02-11 12:07     ` Russell King - ARM Linux
2015-02-11 12:19       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).