diff mbox series

[v2,9/9] misc: atmel_tclib: do not probe already used TCBs

Message ID 20190415150856.9384-10-alexandre.belloni@bootlin.com (mailing list archive)
State New, archived
Headers show
Series clocksource: improve Atmel TCB timer driver | expand

Commit Message

Alexandre Belloni April 15, 2019, 3:08 p.m. UTC
The TCBs that have children are using the proper DT bindings and don't need
to be handled by tclib.

Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/misc/atmel_tclib.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Romain Izard April 17, 2019, 11:50 a.m. UTC | #1
On Mon, Apr 15, 2019 at 05:08:56PM +0200, Alexandre Belloni wrote:
> The TCBs that have children are using the proper DT bindings and don't need
> to be handled by tclib.
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
>  drivers/misc/atmel_tclib.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
> index 194f774ab3a1..c1f5aba1c6f2 100644
> --- a/drivers/misc/atmel_tclib.c
> +++ b/drivers/misc/atmel_tclib.c
> @@ -111,6 +111,9 @@ static int __init tc_probe(struct platform_device *pdev)
>  	struct resource	*r;
>  	unsigned int	i;
>  
> +	if (of_get_child_count(pdev->dev.of_node))
> +		return 0;
> +
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
>  		return -EINVAL;

This lead to a panic during shutdown, as tc_shutdown is called on the
device that has not been initialized and it has not been designed for
this.
Alexandre Belloni April 17, 2019, noon UTC | #2
On 17/04/2019 13:50:25+0200, Romain Izard wrote:
> On Mon, Apr 15, 2019 at 05:08:56PM +0200, Alexandre Belloni wrote:
> > The TCBs that have children are using the proper DT bindings and don't need
> > to be handled by tclib.
> > 
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > ---
> >  drivers/misc/atmel_tclib.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
> > index 194f774ab3a1..c1f5aba1c6f2 100644
> > --- a/drivers/misc/atmel_tclib.c
> > +++ b/drivers/misc/atmel_tclib.c
> > @@ -111,6 +111,9 @@ static int __init tc_probe(struct platform_device *pdev)
> >  	struct resource	*r;
> >  	unsigned int	i;
> >  
> > +	if (of_get_child_count(pdev->dev.of_node))
> > +		return 0;
> > +
> >  	irq = platform_get_irq(pdev, 0);
> >  	if (irq < 0)
> >  		return -EINVAL;
> 
> This lead to a panic during shutdown, as tc_shutdown is called on the
> device that has not been initialized and it has not been designed for
> this.
> 

Yes, I saw that yesterday, the solution is to return -EBUSY instead of
0. That's what I had in my original series and I changed it before
submitting to avoid the error message at boot but this was not a good
idea.
diff mbox series

Patch

diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
index 194f774ab3a1..c1f5aba1c6f2 100644
--- a/drivers/misc/atmel_tclib.c
+++ b/drivers/misc/atmel_tclib.c
@@ -111,6 +111,9 @@  static int __init tc_probe(struct platform_device *pdev)
 	struct resource	*r;
 	unsigned int	i;
 
+	if (of_get_child_count(pdev->dev.of_node))
+		return 0;
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return -EINVAL;