diff mbox series

[v6,3/6] m68k: coldfire: Add clk_get_optional() function

Message ID 20181116145937.27660-4-phil.edworthy@renesas.com (mailing list archive)
State Awaiting Upstream
Delegated to: Geert Uytterhoeven
Headers show
Series clk: Add functions to get optional clocks | expand

Commit Message

Phil Edworthy Nov. 16, 2018, 2:59 p.m. UTC
clk_get_optional() returns NULL if not found instead of -ENOENT,
otherwise the behaviour is the same as clk_get().

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
---
 arch/m68k/coldfire/clk.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Greg Ungerer Nov. 29, 2018, 11:54 a.m. UTC | #1
Hi Phil,

On 17/11/18 12:59 am, Phil Edworthy wrote:
> clk_get_optional() returns NULL if not found instead of -ENOENT,
> otherwise the behaviour is the same as clk_get().
> 
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>

Acked-by: Greg Ungerer <gerg@@linux-m68k.org>

Looks good. Do you want me to take this in the m68knommu git tree?
Or is the whole series going through some other tree?

Regards
Greg



> ---
>   arch/m68k/coldfire/clk.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c
> index 7bc666e482eb..b221cabc7f54 100644
> --- a/arch/m68k/coldfire/clk.c
> +++ b/arch/m68k/coldfire/clk.c
> @@ -87,6 +87,17 @@ struct clk *clk_get(struct device *dev, const char *id)
>   }
>   EXPORT_SYMBOL(clk_get);
>   
> +struct clk *clk_get_optional(struct device *dev, const char *id)
> +{
> +	struct clk *clk = clk_get(dev, id);
> +
> +	if (clk == ERR_PTR(-ENOENT))
> +		clk = NULL;
> +
> +	return clk;
> +}
> +EXPORT_SYMBOL(clk_get_optional);
> +
>   int clk_enable(struct clk *clk)
>   {
>   	unsigned long flags;
>
Phil Edworthy Nov. 29, 2018, 12:02 p.m. UTC | #2
Hi Greq,

On 29 November 2018 11:55, Greg Ungerer wrote:
> On 17/11/18 12:59 am, Phil Edworthy wrote:
> > clk_get_optional() returns NULL if not found instead of -ENOENT,
> > otherwise the behaviour is the same as clk_get().
> >
> > Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> 
> Acked-by: Greg Ungerer <gerg@@linux-m68k.org>
> 
> Looks good. Do you want me to take this in the m68knommu git tree?
> Or is the whole series going through some other tree?
This patch is no longer needed as I found a better way to implement this:
[PATCH v8] clk: Add (devm_)clk_get_optional() functions
https://patchwork.kernel.org/patch/10690437/

Apologies for any confusion,
Phil

> Regards
> Greg
> 
> 
> 
> > ---
> >   arch/m68k/coldfire/clk.c | 11 +++++++++++
> >   1 file changed, 11 insertions(+)
> >
> > diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c index
> > 7bc666e482eb..b221cabc7f54 100644
> > --- a/arch/m68k/coldfire/clk.c
> > +++ b/arch/m68k/coldfire/clk.c
> > @@ -87,6 +87,17 @@ struct clk *clk_get(struct device *dev, const char *id)
> >   }
> >   EXPORT_SYMBOL(clk_get);
> >
> > +struct clk *clk_get_optional(struct device *dev, const char *id) {
> > +	struct clk *clk = clk_get(dev, id);
> > +
> > +	if (clk == ERR_PTR(-ENOENT))
> > +		clk = NULL;
> > +
> > +	return clk;
> > +}
> > +EXPORT_SYMBOL(clk_get_optional);
> > +
> >   int clk_enable(struct clk *clk)
> >   {
> >   	unsigned long flags;
> >
Greg Ungerer Nov. 29, 2018, 12:10 p.m. UTC | #3
Hi Phil,

On 29/11/18 10:02 pm, Phil Edworthy wrote:
> On 29 November 2018 11:55, Greg Ungerer wrote:
>> On 17/11/18 12:59 am, Phil Edworthy wrote:
>>> clk_get_optional() returns NULL if not found instead of -ENOENT,
>>> otherwise the behaviour is the same as clk_get().
>>>
>>> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
>>
>> Acked-by: Greg Ungerer <gerg@@linux-m68k.org>
>>
>> Looks good. Do you want me to take this in the m68knommu git tree?
>> Or is the whole series going through some other tree?
> This patch is no longer needed as I found a better way to implement this:
> [PATCH v8] clk: Add (devm_)clk_get_optional() functions
> https://patchwork.kernel.org/patch/10690437/
> 
> Apologies for any confusion,

No problem, I'll just drop it then.

Regards
Greg


>>> ---
>>>    arch/m68k/coldfire/clk.c | 11 +++++++++++
>>>    1 file changed, 11 insertions(+)
>>>
>>> diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c index
>>> 7bc666e482eb..b221cabc7f54 100644
>>> --- a/arch/m68k/coldfire/clk.c
>>> +++ b/arch/m68k/coldfire/clk.c
>>> @@ -87,6 +87,17 @@ struct clk *clk_get(struct device *dev, const char *id)
>>>    }
>>>    EXPORT_SYMBOL(clk_get);
>>>
>>> +struct clk *clk_get_optional(struct device *dev, const char *id) {
>>> +	struct clk *clk = clk_get(dev, id);
>>> +
>>> +	if (clk == ERR_PTR(-ENOENT))
>>> +		clk = NULL;
>>> +
>>> +	return clk;
>>> +}
>>> +EXPORT_SYMBOL(clk_get_optional);
>>> +
>>>    int clk_enable(struct clk *clk)
>>>    {
>>>    	unsigned long flags;
>>>
Christoph Hellwig Nov. 29, 2018, 4:32 p.m. UTC | #4
On Thu, Nov 29, 2018 at 09:54:37PM +1000, Greg Ungerer wrote:
> Hi Phil,
> 
> On 17/11/18 12:59 am, Phil Edworthy wrote:
> > clk_get_optional() returns NULL if not found instead of -ENOENT,
> > otherwise the behaviour is the same as clk_get().
> > 
> > Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> 
> Acked-by: Greg Ungerer <gerg@@linux-m68k.org>
> 
> Looks good. Do you want me to take this in the m68knommu git tree?
> Or is the whole series going through some other tree?

Any chance we could just get coldfire moved over to the common clock
framework?
Greg Ungerer Dec. 3, 2018, 12:29 p.m. UTC | #5
Hi Christoph,

On 30/11/18 2:32 am, Christoph Hellwig wrote:
> On Thu, Nov 29, 2018 at 09:54:37PM +1000, Greg Ungerer wrote:
>> Hi Phil,
>>
>> On 17/11/18 12:59 am, Phil Edworthy wrote:
>>> clk_get_optional() returns NULL if not found instead of -ENOENT,
>>> otherwise the behaviour is the same as clk_get().
>>>
>>> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
>>
>> Acked-by: Greg Ungerer <gerg@@linux-m68k.org>
>>
>> Looks good. Do you want me to take this in the m68knommu git tree?
>> Or is the whole series going through some other tree?
> 
> Any chance we could just get coldfire moved over to the common clock
> framework?

Sure, I will have a look at it.

Regards
Greg
diff mbox series

Patch

diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c
index 7bc666e482eb..b221cabc7f54 100644
--- a/arch/m68k/coldfire/clk.c
+++ b/arch/m68k/coldfire/clk.c
@@ -87,6 +87,17 @@  struct clk *clk_get(struct device *dev, const char *id)
 }
 EXPORT_SYMBOL(clk_get);
 
+struct clk *clk_get_optional(struct device *dev, const char *id)
+{
+	struct clk *clk = clk_get(dev, id);
+
+	if (clk == ERR_PTR(-ENOENT))
+		clk = NULL;
+
+	return clk;
+}
+EXPORT_SYMBOL(clk_get_optional);
+
 int clk_enable(struct clk *clk)
 {
 	unsigned long flags;