diff mbox

[RFC,6/8] powerpc/prom: Simplify the logic while fetching SLB size

Message ID 1437461926-8908-6-git-send-email-khandual@linux.vnet.ibm.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Anshuman Khandual July 21, 2015, 6:58 a.m. UTC
From: "khandual@linux.vnet.ibm.com" <khandual@linux.vnet.ibm.com>

This patch just simplifies the existing code logic while fetching
the SLB size property from the device tree.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/prom.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Michael Ellerman July 21, 2015, 10:21 a.m. UTC | #1
On Tue, 2015-21-07 at 06:58:44 UTC, Anshuman Khandual wrote:
> From: "khandual@linux.vnet.ibm.com" <khandual@linux.vnet.ibm.com>
> 
> This patch just simplifies the existing code logic while fetching
> the SLB size property from the device tree.
> 
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
>  arch/powerpc/kernel/prom.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 8b888b1..f6168e2 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -223,14 +223,12 @@ static void __init check_cpu_slb_size(unsigned long node)
>  	const __be32 *slb_size_ptr;
>  
>  	slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL);
> -	if (slb_size_ptr != NULL) {
> -		mmu_slb_size = be32_to_cpup(slb_size_ptr);
> -		return;
> -	}
> -	slb_size_ptr = of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
> -	if (slb_size_ptr != NULL) {
> -		mmu_slb_size = be32_to_cpup(slb_size_ptr);
> +	if (!slb_size_ptr) {
> +		slb_size_ptr = of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
> +		if (!slb_size_ptr)
> +			return;
>  	}
> +	mmu_slb_size = be32_to_cpup(slb_size_ptr);
>  }

It's still ugly. Why not go the whole way:


	p = of_get_flat_dt_prop(node, "slb-size", NULL) ? :
	    of_get_flat_dt_prop(node, "ibm,slb-size", NULL);

	if (p)
		mmu_slb_size = be32_to_cpup(p);


And while you're at it, rename the function, it doesn't check anything. It
initialises mmu_slb_size, so call it init_mmu_slb_size()?

cheers
Anshuman Khandual July 21, 2015, 11:24 a.m. UTC | #2
On 07/21/2015 03:51 PM, Michael Ellerman wrote:
> On Tue, 2015-21-07 at 06:58:44 UTC, Anshuman Khandual wrote:
>> > From: "khandual@linux.vnet.ibm.com" <khandual@linux.vnet.ibm.com>
>> > 
>> > This patch just simplifies the existing code logic while fetching
>> > the SLB size property from the device tree.
>> > 
>> > Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
>> > ---
>> >  arch/powerpc/kernel/prom.c | 12 +++++-------
>> >  1 file changed, 5 insertions(+), 7 deletions(-)
>> > 
>> > diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
>> > index 8b888b1..f6168e2 100644
>> > --- a/arch/powerpc/kernel/prom.c
>> > +++ b/arch/powerpc/kernel/prom.c
>> > @@ -223,14 +223,12 @@ static void __init check_cpu_slb_size(unsigned long node)
>> >  	const __be32 *slb_size_ptr;
>> >  
>> >  	slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL);
>> > -	if (slb_size_ptr != NULL) {
>> > -		mmu_slb_size = be32_to_cpup(slb_size_ptr);
>> > -		return;
>> > -	}
>> > -	slb_size_ptr = of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
>> > -	if (slb_size_ptr != NULL) {
>> > -		mmu_slb_size = be32_to_cpup(slb_size_ptr);
>> > +	if (!slb_size_ptr) {
>> > +		slb_size_ptr = of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
>> > +		if (!slb_size_ptr)
>> > +			return;
>> >  	}
>> > +	mmu_slb_size = be32_to_cpup(slb_size_ptr);
>> >  }
> It's still ugly. Why not go the whole way:
> 
> 
> 	p = of_get_flat_dt_prop(node, "slb-size", NULL) ? :
> 	    of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
> 
> 	if (p)
> 		mmu_slb_size = be32_to_cpup(p);

Yeah this is better.

> 
> 
> And while you're at it, rename the function, it doesn't check anything. It
> initialises mmu_slb_size, so call it init_mmu_slb_size()?

Sure, will do.
diff mbox

Patch

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 8b888b1..f6168e2 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -223,14 +223,12 @@  static void __init check_cpu_slb_size(unsigned long node)
 	const __be32 *slb_size_ptr;
 
 	slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL);
-	if (slb_size_ptr != NULL) {
-		mmu_slb_size = be32_to_cpup(slb_size_ptr);
-		return;
-	}
-	slb_size_ptr = of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
-	if (slb_size_ptr != NULL) {
-		mmu_slb_size = be32_to_cpup(slb_size_ptr);
+	if (!slb_size_ptr) {
+		slb_size_ptr = of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
+		if (!slb_size_ptr)
+			return;
 	}
+	mmu_slb_size = be32_to_cpup(slb_size_ptr);
 }
 #else
 #define check_cpu_slb_size(node) do { } while(0)