diff mbox

[v2] powernv: Simplify searching for compatible device nodes

Message ID 20160803171800.8999-1-jack@codezen.org (mailing list archive)
State Superseded
Headers show

Commit Message

Jack Miller Aug. 3, 2016, 5:18 p.m. UTC
(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(-)

Comments

Cyril Bur Aug. 4, 2016, 7:27 a.m. UTC | #1
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();
Michael Ellerman Aug. 4, 2016, 8:39 a.m. UTC | #2
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
Jack Miller Aug. 4, 2016, 4:03 p.m. UTC | #3
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
diff mbox

Patch

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();