All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powernv: Search for new flash DT node location
@ 2016-08-01 20:50 Jack Miller
  2016-08-01 21:04 ` Jack Miller
  2016-08-03  7:16 ` Michael Ellerman
  0 siblings, 2 replies; 13+ messages in thread
From: Jack Miller @ 2016-08-01 20:50 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: jk

Skiboot will place the flash device tree node at ibm,opal/flash/flash@0
on P9 and later systems, so Linux needs to search for it there as well
as ibm,opal/flash@0 for backwards compatibility.

Signed-off-by: Jack Miller <jack@codezen.org>
---
 arch/powerpc/platforms/powernv/opal.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index ae29eaf..2847cb0 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -755,9 +755,14 @@ static int __init opal_init(void)
 
 	/* Initialize platform devices: IPMI backend, PRD & flash interface */
 	opal_pdev_init(opal_node, "ibm,opal-ipmi");
-	opal_pdev_init(opal_node, "ibm,opal-flash");
+	opal_pdev_init(opal_node, "ibm,opal-flash"); // old <= P8 flash location
 	opal_pdev_init(opal_node, "ibm,opal-prd");
 
+	/* New >= P9 flash location */
+	np = of_get_child_by_name(opal_node, "flash");
+	if (np)
+		opal_pdev_init(np, "ibm,opal-flash");
+
 	/* Initialise OPAL kmsg dumper for flushing console on panic */
 	opal_kmsg_init();
 
-- 
2.9.2

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

* Re: [PATCH] powernv: Search for new flash DT node location
  2016-08-01 20:50 [PATCH] powernv: Search for new flash DT node location Jack Miller
@ 2016-08-01 21:04 ` Jack Miller
  2016-08-03  7:16 ` Michael Ellerman
  1 sibling, 0 replies; 13+ messages in thread
From: Jack Miller @ 2016-08-01 21:04 UTC (permalink / raw)
  To: linuxppc-dev

For reference, here's a link to the skiboot patch on the list

https://lists.ozlabs.org/pipermail/skiboot/2016-August/004274.html

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

* Re: [PATCH] powernv: Search for new flash DT node location
  2016-08-01 20:50 [PATCH] powernv: Search for new flash DT node location Jack Miller
  2016-08-01 21:04 ` Jack Miller
@ 2016-08-03  7:16 ` Michael Ellerman
  2016-08-03 16:44   ` Jack Miller
  1 sibling, 1 reply; 13+ messages in thread
From: Michael Ellerman @ 2016-08-03  7:16 UTC (permalink / raw)
  To: Jack Miller, linuxppc-dev; +Cc: jk, stewart, benh

Quoting Jack Miller (2016-08-02 06:50:35)
> Skiboot will place the flash device tree node at ibm,opal/flash/flash@0
> on P9 and later systems, so Linux needs to search for it there as well
> as ibm,opal/flash@0 for backwards compatibility.
> =

> Signed-off-by: Jack Miller <jack@codezen.org>
> ---
>  arch/powerpc/platforms/powernv/opal.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> =

> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platfor=
ms/powernv/opal.c
> index ae29eaf..2847cb0 100644
> --- a/arch/powerpc/platforms/powernv/opal.c
> +++ b/arch/powerpc/platforms/powernv/opal.c
> @@ -755,9 +755,14 @@ static int __init opal_init(void)
>  =

>         /* Initialize platform devices: IPMI backend, PRD & flash interfa=
ce */
>         opal_pdev_init(opal_node, "ibm,opal-ipmi");
> -       opal_pdev_init(opal_node, "ibm,opal-flash");
> +       opal_pdev_init(opal_node, "ibm,opal-flash"); // old <=3D P8 flash=
 location
>         opal_pdev_init(opal_node, "ibm,opal-prd");
>  =

> +       /* New >=3D P9 flash location */
> +       np =3D of_get_child_by_name(opal_node, "flash");
> +       if (np)
> +               opal_pdev_init(np, "ibm,opal-flash");

We could instead just search for all nodes that are compatible with
"ibm,opal-flash". We do that for i2c, see opal_i2c_create_devs().

Is there a particular reason not to do that?

cheers

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

* Re: [PATCH] powernv: Search for new flash DT node location
  2016-08-03  7:16 ` Michael Ellerman
@ 2016-08-03 16:44   ` Jack Miller
  2016-08-03 16:44     ` [PATCH] powernv: Simplify searching for compatible device nodes Jack Miller
                       ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Jack Miller @ 2016-08-03 16:44 UTC (permalink / raw)
  To: mpe, linuxppc-dev; +Cc: jk, stewart, benh

On Wed, Aug 03, 2016 at 05:16:34PM +1000, Michael Ellerman wrote:
> We could instead just search for all nodes that are compatible with
> "ibm,opal-flash". We do that for i2c, see opal_i2c_create_devs().
> 
> Is there a particular reason not to do that?

I'm actually surprised that this is preferred. Jeremy mentioned something
similar, but I guess I just don't like the idea of finding devices in weird
places in the tree. Then again, if we can't trust the DT we're in bigger
trouble than erroneous flash nodes =).

If we really just want to find compatible nodes anywhere, let's simplify i2c
and pdev_init into one function and make that behavior consistent with this
new patch.

- Jack

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

* [PATCH] powernv: Simplify searching for compatible device nodes
  2016-08-03 16:44   ` Jack Miller
@ 2016-08-03 16:44     ` Jack Miller
  2016-08-03 17:18     ` [PATCH v2] " Jack Miller
  2016-08-04  3:28     ` [PATCH] powernv: Search for new flash DT node location Michael Ellerman
  2 siblings, 0 replies; 13+ messages in thread
From: Jack Miller @ 2016-08-03 16:44 UTC (permalink / raw)
  To: mpe, linuxppc-dev; +Cc: jk, stewart, benh

This condenses the opal node searching into a single function that finds
all compatible nodes, instead of just searching the ibm,opal children,
for ipmi, flash, and prd similar to how opal-i2c nodes are found.

Signed-off-by: Jack Miller <jack@codezen.org>
---
 arch/powerpc/platforms/powernv/opal.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index ae29eaf..86b7352 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -640,21 +640,11 @@ static void __init opal_dump_region_init(void)
 			"rc = %d\n", rc);
 }
 
-static void opal_pdev_init(struct device_node *opal_node,
-		const char *compatible)
+static void opal_pdev_init(const char *compatible)
 {
 	struct device_node *np;
 
-	for_each_child_of_node(opal_node, np)
-		if (of_device_is_compatible(np, compatible))
-			of_platform_device_create(np, NULL, NULL);
-}
-
-static void opal_i2c_create_devs(void)
-{
-	struct device_node *np;
-
-	for_each_compatible_node(np, NULL, "ibm,opal-i2c")
+	for_each_compatible_node(np, NULL, compatible)
 		of_platform_device_create(np, NULL, NULL);
 }
 
@@ -722,7 +712,7 @@ static int __init opal_init(void)
 	opal_hmi_handler_init();
 
 	/* Create i2c platform devices */
-	opal_i2c_create_devs();
+	opal_pdev_init("ibm,opal-i2c");
 
 	/* Setup a heatbeat thread if requested by OPAL */
 	opal_init_heartbeat();
@@ -754,9 +744,9 @@ static int __init opal_init(void)
 	}
 
 	/* Initialize platform devices: IPMI backend, PRD & flash interface */
-	opal_pdev_init(opal_node, "ibm,opal-ipmi");
-	opal_pdev_init(opal_node, "ibm,opal-flash");
-	opal_pdev_init(opal_node, "ibm,opal-prd");
+	opal_pdev_init("ibm,opal-ipmi");
+	opal_pdev_init("ibm,opal-flash");
+	opal_pdev_init("ibm,opal-prd");
 
 	/* Initialise OPAL kmsg dumper for flushing console on panic */
 	opal_kmsg_init();
-- 
2.9.2

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

* [PATCH v2] powernv: Simplify searching for compatible device nodes
  2016-08-03 16:44   ` Jack Miller
  2016-08-03 16:44     ` [PATCH] powernv: Simplify searching for compatible device nodes Jack Miller
@ 2016-08-03 17:18     ` Jack Miller
  2016-08-04  7:27       ` Cyril Bur
  2016-08-04  3:28     ` [PATCH] powernv: Search for new flash DT node location Michael Ellerman
  2 siblings, 1 reply; 13+ messages in thread
From: Jack Miller @ 2016-08-03 17:18 UTC (permalink / raw)
  To: mpe, linuxppc-dev; +Cc: jk, stewart, benh

(rebased on powerpc/next)

This condenses the opal node searching into a single function that finds
all compatible nodes, instead of just searching the ibm,opal children,
for ipmi, flash, and prd similar to how opal-i2c nodes are found.

Signed-off-by: Jack Miller <jack@codezen.org>
---
 arch/powerpc/platforms/powernv/opal.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 8b4fc68..9db12ce 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -631,21 +631,11 @@ static void __init opal_dump_region_init(void)
 			"rc = %d\n", rc);
 }
 
-static void opal_pdev_init(struct device_node *opal_node,
-		const char *compatible)
+static void opal_pdev_init(const char *compatible)
 {
 	struct device_node *np;
 
-	for_each_child_of_node(opal_node, np)
-		if (of_device_is_compatible(np, compatible))
-			of_platform_device_create(np, NULL, NULL);
-}
-
-static void opal_i2c_create_devs(void)
-{
-	struct device_node *np;
-
-	for_each_compatible_node(np, NULL, "ibm,opal-i2c")
+	for_each_compatible_node(np, NULL, compatible)
 		of_platform_device_create(np, NULL, NULL);
 }
 
@@ -717,7 +707,7 @@ static int __init opal_init(void)
 	opal_hmi_handler_init();
 
 	/* Create i2c platform devices */
-	opal_i2c_create_devs();
+	opal_pdev_init("ibm,opal-i2c");
 
 	/* Setup a heatbeat thread if requested by OPAL */
 	opal_init_heartbeat();
@@ -752,12 +742,12 @@ static int __init opal_init(void)
 	}
 
 	/* Initialize platform devices: IPMI backend, PRD & flash interface */
-	opal_pdev_init(opal_node, "ibm,opal-ipmi");
-	opal_pdev_init(opal_node, "ibm,opal-flash");
-	opal_pdev_init(opal_node, "ibm,opal-prd");
+	opal_pdev_init("ibm,opal-ipmi");
+	opal_pdev_init("ibm,opal-flash");
+	opal_pdev_init("ibm,opal-prd");
 
 	/* Initialise platform device: oppanel interface */
-	opal_pdev_init(opal_node, "ibm,opal-oppanel");
+	opal_pdev_init("ibm,opal-oppanel");
 
 	/* Initialise OPAL kmsg dumper for flushing console on panic */
 	opal_kmsg_init();
-- 
2.9.2

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

* Re: [PATCH] powernv: Search for new flash DT node location
  2016-08-03 16:44   ` Jack Miller
  2016-08-03 16:44     ` [PATCH] powernv: Simplify searching for compatible device nodes Jack Miller
  2016-08-03 17:18     ` [PATCH v2] " Jack Miller
@ 2016-08-04  3:28     ` Michael Ellerman
  2016-09-27  4:44       ` Stewart Smith
  2 siblings, 1 reply; 13+ messages in thread
From: Michael Ellerman @ 2016-08-04  3:28 UTC (permalink / raw)
  To: Jack Miller, linuxppc-dev; +Cc: jk, stewart, benh

Jack Miller <jack@codezen.org> writes:

> On Wed, Aug 03, 2016 at 05:16:34PM +1000, Michael Ellerman wrote:
>> We could instead just search for all nodes that are compatible with
>> "ibm,opal-flash". We do that for i2c, see opal_i2c_create_devs().
>> 
>> Is there a particular reason not to do that?
>
> I'm actually surprised that this is preferred. Jeremy mentioned something
> similar, but I guess I just don't like the idea of finding devices in weird
> places in the tree.

But where is "weird". Arguably "/opal/flash" is weird. What does it
mean? There's a bus called "opal" and a device on it called "flash"? No.

Point being the structure is fairly arbitrary, or at least debatable, so
tying the code 100% to the structure is inflexible. As we have discovered.

Our other option is to tell skiboot to get stuffed, and leave the flash
node where it was on P8.

> Then again, if we can't trust the DT we're in bigger
> trouble than erroneous flash nodes =).

Quite :)

> If we really just want to find compatible nodes anywhere, let's simplify i2c
> and pdev_init into one function and make that behavior consistent with this
> new patch.

That seems OK to me.

We should get an ack from Stewart though for the other node types.

cheers

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

* Re: [PATCH v2] powernv: Simplify searching for compatible device nodes
  2016-08-03 17:18     ` [PATCH v2] " Jack Miller
@ 2016-08-04  7:27       ` Cyril Bur
  2016-08-04  8:39         ` Michael Ellerman
  0 siblings, 1 reply; 13+ messages in thread
From: Cyril Bur @ 2016-08-04  7:27 UTC (permalink / raw)
  To: Jack Miller, linuxppc-dev; +Cc: mpe, stewart, jk

On Wed,  3 Aug 2016 12:18:00 -0500
Jack Miller <jack@codezen.org> wrote:

> (rebased on powerpc/next)
> 
> This condenses the opal node searching into a single function that finds
> all compatible nodes, instead of just searching the ibm,opal children,
> for ipmi, flash, and prd similar to how opal-i2c nodes are found.
> 
> Signed-off-by: Jack Miller <jack@codezen.org>

Using a version of the related skiboot patch that may not be the final one:
Tested-by: Cyril Bur <cyrilbur@gmail.com>

> ---
>  arch/powerpc/platforms/powernv/opal.c | 24 +++++++-----------------
>  1 file changed, 7 insertions(+), 17 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> index 8b4fc68..9db12ce 100644
> --- a/arch/powerpc/platforms/powernv/opal.c
> +++ b/arch/powerpc/platforms/powernv/opal.c
> @@ -631,21 +631,11 @@ static void __init opal_dump_region_init(void)
>  			"rc = %d\n", rc);
>  }
>  
> -static void opal_pdev_init(struct device_node *opal_node,
> -		const char *compatible)
> +static void opal_pdev_init(const char *compatible)
>  {
>  	struct device_node *np;
>  
> -	for_each_child_of_node(opal_node, np)
> -		if (of_device_is_compatible(np, compatible))
> -			of_platform_device_create(np, NULL, NULL);
> -}
> -
> -static void opal_i2c_create_devs(void)
> -{
> -	struct device_node *np;
> -
> -	for_each_compatible_node(np, NULL, "ibm,opal-i2c")
> +	for_each_compatible_node(np, NULL, compatible)
>  		of_platform_device_create(np, NULL, NULL);
>  }
>  
> @@ -717,7 +707,7 @@ static int __init opal_init(void)
>  	opal_hmi_handler_init();
>  
>  	/* Create i2c platform devices */
> -	opal_i2c_create_devs();
> +	opal_pdev_init("ibm,opal-i2c");
>  
>  	/* Setup a heatbeat thread if requested by OPAL */
>  	opal_init_heartbeat();
> @@ -752,12 +742,12 @@ static int __init opal_init(void)
>  	}
>  
>  	/* Initialize platform devices: IPMI backend, PRD & flash interface */
> -	opal_pdev_init(opal_node, "ibm,opal-ipmi");
> -	opal_pdev_init(opal_node, "ibm,opal-flash");
> -	opal_pdev_init(opal_node, "ibm,opal-prd");
> +	opal_pdev_init("ibm,opal-ipmi");
> +	opal_pdev_init("ibm,opal-flash");
> +	opal_pdev_init("ibm,opal-prd");
>  
>  	/* Initialise platform device: oppanel interface */
> -	opal_pdev_init(opal_node, "ibm,opal-oppanel");
> +	opal_pdev_init("ibm,opal-oppanel");
>  
>  	/* Initialise OPAL kmsg dumper for flushing console on panic */
>  	opal_kmsg_init();

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

* Re: [PATCH v2] powernv: Simplify searching for compatible device nodes
  2016-08-04  7:27       ` Cyril Bur
@ 2016-08-04  8:39         ` Michael Ellerman
  2016-08-04 16:03           ` Jack Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Ellerman @ 2016-08-04  8:39 UTC (permalink / raw)
  To: Cyril Bur, Jack Miller, linuxppc-dev; +Cc: stewart, jk

Cyril Bur <cyrilbur@gmail.com> writes:

> On Wed,  3 Aug 2016 12:18:00 -0500
> Jack Miller <jack@codezen.org> wrote:
>
>> (rebased on powerpc/next)
>> 
>> This condenses the opal node searching into a single function that finds
>> all compatible nodes, instead of just searching the ibm,opal children,
>> for ipmi, flash, and prd similar to how opal-i2c nodes are found.
>> 
>> Signed-off-by: Jack Miller <jack@codezen.org>
>
> Using a version of the related skiboot patch that may not be the final one:
> Tested-by: Cyril Bur <cyrilbur@gmail.com>

Thanks. The part I'm still not clear on is *why* we're moving them in
skiboot?

cheers

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

* Re: [PATCH v2] powernv: Simplify searching for compatible device nodes
  2016-08-04  8:39         ` Michael Ellerman
@ 2016-08-04 16:03           ` Jack Miller
  0 siblings, 0 replies; 13+ messages in thread
From: Jack Miller @ 2016-08-04 16:03 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Cyril Bur, linuxppc-dev, stewart, jk

On Thu, Aug 04, 2016 at 06:39:24PM +1000, Michael Ellerman wrote:
> Cyril Bur <cyrilbur@gmail.com> writes:
> 
> > On Wed,  3 Aug 2016 12:18:00 -0500
> > Jack Miller <jack@codezen.org> wrote:
> >
> >> (rebased on powerpc/next)
> >> 
> >> This condenses the opal node searching into a single function that finds
> >> all compatible nodes, instead of just searching the ibm,opal children,
> >> for ipmi, flash, and prd similar to how opal-i2c nodes are found.
> >> 
> >> Signed-off-by: Jack Miller <jack@codezen.org>
> >
> > Using a version of the related skiboot patch that may not be the final one:
> > Tested-by: Cyril Bur <cyrilbur@gmail.com>
> 
> Thanks. The part I'm still not clear on is *why* we're moving them in
> skiboot?

Ostensibly so the actual flash device nodes can inherit the #size-cells /
#address-cells properties properly set in the flash parent node instead of
the ibm,opal node (which has them set to 0). This would be more correct if
anything actually started to honor these settings.

The only concrete effect though is stopping dtc (and thus fwts) from whinging
when you run skiboot's output DT through it.

- Jack

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

* Re: [PATCH] powernv: Search for new flash DT node location
  2016-08-04  3:28     ` [PATCH] powernv: Search for new flash DT node location Michael Ellerman
@ 2016-09-27  4:44       ` Stewart Smith
  0 siblings, 0 replies; 13+ messages in thread
From: Stewart Smith @ 2016-09-27  4:44 UTC (permalink / raw)
  To: Michael Ellerman, Jack Miller, linuxppc-dev; +Cc: jk, benh

Michael Ellerman <mpe@ellerman.id.au> writes:
> Jack Miller <jack@codezen.org> writes:
>
>> On Wed, Aug 03, 2016 at 05:16:34PM +1000, Michael Ellerman wrote:
>>> We could instead just search for all nodes that are compatible with
>>> "ibm,opal-flash". We do that for i2c, see opal_i2c_create_devs().
>>> 
>>> Is there a particular reason not to do that?
>>
>> I'm actually surprised that this is preferred. Jeremy mentioned something
>> similar, but I guess I just don't like the idea of finding devices in weird
>> places in the tree.
>
> But where is "weird". Arguably "/opal/flash" is weird. What does it
> mean? There's a bus called "opal" and a device on it called "flash"? No.
>
> Point being the structure is fairly arbitrary, or at least debatable, so
> tying the code 100% to the structure is inflexible. As we have discovered.
>
> Our other option is to tell skiboot to get stuffed, and leave the flash
> node where it was on P8.
>
>> Then again, if we can't trust the DT we're in bigger
>> trouble than erroneous flash nodes =).
>
> Quite :)
>
>> If we really just want to find compatible nodes anywhere, let's simplify i2c
>> and pdev_init into one function and make that behavior consistent with this
>> new patch.
>
> That seems OK to me.
>
> We should get an ack from Stewart though for the other node types.

For finding nodes based on compatible no matter where they are in the tree,

Acked-by: Stewart Smith <stewart@linux.vnet.ibm.com>

(and yes, includes other nodes too)

The exact location then isn't too important, and having a /flash that's
ibm,opal-flash and allows for some other driver to bind to it I think is
also something we shouldn't rule out.

-- 
Stewart Smith
OPAL Architect, IBM.

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

* Re: [PATCH v2] powernv: Simplify searching for compatible device nodes
  2016-08-11  0:32 [PATCH v2] powernv: Simplify searching for compatible device nodes Jack Miller
@ 2016-10-19  5:58 ` Cyril Bur
  0 siblings, 0 replies; 13+ messages in thread
From: Cyril Bur @ 2016-10-19  5:58 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: stable, Jack Miller, stewart, linuxppc-dev

On Wed, 2016-08-10 at 19:32 -0500, Jack Miller wrote:
> This condenses the opal node searching into a single function that
> finds
> all compatible nodes, instead of just searching the ibm,opal
> children,
> for ipmi, flash, and prd similar to how opal-i2c nodes are found.
> 

Hi Michael,

It seems this patch hasn't made it in. Without it linux cannot find the
flash on p9 as skiboot has moved the node to a more appropriate place.

Thanks,

Cyril

Cc: stable@vger.kernel.org # v4.6+

> Signed-off-by: Jack Miller <jack@codezen.org>
> ---
>  arch/powerpc/platforms/powernv/opal.c | 24 +++++++-----------------
>  1 file changed, 7 insertions(+), 17 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/opal.c
> b/arch/powerpc/platforms/powernv/opal.c
> index 8b4fc68..9db12ce 100644
> --- a/arch/powerpc/platforms/powernv/opal.c
> +++ b/arch/powerpc/platforms/powernv/opal.c
> @@ -631,21 +631,11 @@ static void __init opal_dump_region_init(void)
>  			"rc = %d\n", rc);
>  }
>  
> -static void opal_pdev_init(struct device_node *opal_node,
> -		const char *compatible)
> +static void opal_pdev_init(const char *compatible)
>  {
>  	struct device_node *np;
>  
> -	for_each_child_of_node(opal_node, np)
> -		if (of_device_is_compatible(np, compatible))
> -			of_platform_device_create(np, NULL, NULL);
> -}
> -
> -static void opal_i2c_create_devs(void)
> -{
> -	struct device_node *np;
> -
> -	for_each_compatible_node(np, NULL, "ibm,opal-i2c")
> +	for_each_compatible_node(np, NULL, compatible)
>  		of_platform_device_create(np, NULL, NULL);
>  }
>  
> @@ -717,7 +707,7 @@ static int __init opal_init(void)
>  	opal_hmi_handler_init();
>  
>  	/* Create i2c platform devices */
> -	opal_i2c_create_devs();
> +	opal_pdev_init("ibm,opal-i2c");
>  
>  	/* Setup a heatbeat thread if requested by OPAL */
>  	opal_init_heartbeat();
> @@ -752,12 +742,12 @@ static int __init opal_init(void)
>  	}
>  
>  	/* Initialize platform devices: IPMI backend, PRD & flash
> interface */
> -	opal_pdev_init(opal_node, "ibm,opal-ipmi");
> -	opal_pdev_init(opal_node, "ibm,opal-flash");
> -	opal_pdev_init(opal_node, "ibm,opal-prd");
> +	opal_pdev_init("ibm,opal-ipmi");
> +	opal_pdev_init("ibm,opal-flash");
> +	opal_pdev_init("ibm,opal-prd");
>  
>  	/* Initialise platform device: oppanel interface */
> -	opal_pdev_init(opal_node, "ibm,opal-oppanel");
> +	opal_pdev_init("ibm,opal-oppanel");
>  
>  	/* Initialise OPAL kmsg dumper for flushing console on panic
> */
>  	opal_kmsg_init();

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

* [PATCH v2] powernv: Simplify searching for compatible device nodes
@ 2016-08-11  0:32 Jack Miller
  2016-10-19  5:58 ` Cyril Bur
  0 siblings, 1 reply; 13+ messages in thread
From: Jack Miller @ 2016-08-11  0:32 UTC (permalink / raw)
  To: stewart, linuxppc-dev

This condenses the opal node searching into a single function that finds
all compatible nodes, instead of just searching the ibm,opal children,
for ipmi, flash, and prd similar to how opal-i2c nodes are found.

Signed-off-by: Jack Miller <jack@codezen.org>
---
 arch/powerpc/platforms/powernv/opal.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 8b4fc68..9db12ce 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -631,21 +631,11 @@ static void __init opal_dump_region_init(void)
 			"rc = %d\n", rc);
 }
 
-static void opal_pdev_init(struct device_node *opal_node,
-		const char *compatible)
+static void opal_pdev_init(const char *compatible)
 {
 	struct device_node *np;
 
-	for_each_child_of_node(opal_node, np)
-		if (of_device_is_compatible(np, compatible))
-			of_platform_device_create(np, NULL, NULL);
-}
-
-static void opal_i2c_create_devs(void)
-{
-	struct device_node *np;
-
-	for_each_compatible_node(np, NULL, "ibm,opal-i2c")
+	for_each_compatible_node(np, NULL, compatible)
 		of_platform_device_create(np, NULL, NULL);
 }
 
@@ -717,7 +707,7 @@ static int __init opal_init(void)
 	opal_hmi_handler_init();
 
 	/* Create i2c platform devices */
-	opal_i2c_create_devs();
+	opal_pdev_init("ibm,opal-i2c");
 
 	/* Setup a heatbeat thread if requested by OPAL */
 	opal_init_heartbeat();
@@ -752,12 +742,12 @@ static int __init opal_init(void)
 	}
 
 	/* Initialize platform devices: IPMI backend, PRD & flash interface */
-	opal_pdev_init(opal_node, "ibm,opal-ipmi");
-	opal_pdev_init(opal_node, "ibm,opal-flash");
-	opal_pdev_init(opal_node, "ibm,opal-prd");
+	opal_pdev_init("ibm,opal-ipmi");
+	opal_pdev_init("ibm,opal-flash");
+	opal_pdev_init("ibm,opal-prd");
 
 	/* Initialise platform device: oppanel interface */
-	opal_pdev_init(opal_node, "ibm,opal-oppanel");
+	opal_pdev_init("ibm,opal-oppanel");
 
 	/* Initialise OPAL kmsg dumper for flushing console on panic */
 	opal_kmsg_init();
-- 
2.9.2

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

end of thread, other threads:[~2016-10-19  5:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-01 20:50 [PATCH] powernv: Search for new flash DT node location Jack Miller
2016-08-01 21:04 ` Jack Miller
2016-08-03  7:16 ` Michael Ellerman
2016-08-03 16:44   ` Jack Miller
2016-08-03 16:44     ` [PATCH] powernv: Simplify searching for compatible device nodes Jack Miller
2016-08-03 17:18     ` [PATCH v2] " Jack Miller
2016-08-04  7:27       ` Cyril Bur
2016-08-04  8:39         ` Michael Ellerman
2016-08-04 16:03           ` Jack Miller
2016-08-04  3:28     ` [PATCH] powernv: Search for new flash DT node location Michael Ellerman
2016-09-27  4:44       ` Stewart Smith
2016-08-11  0:32 [PATCH v2] powernv: Simplify searching for compatible device nodes Jack Miller
2016-10-19  5:58 ` Cyril Bur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.