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

2015-08-12 Thread Michael Ellerman
On Wed, 2015-29-07 at 07:10:03 UTC, Anshuman Khandual wrote:
 This patch just simplifies the existing code logic while fetching
 the SLB size property from the device tree. This also changes the
 function name from check_cpu_slb_size to init_mmu_slb_size as
 it just initializes the mmu_slb_size value.
 
 Signed-off-by: Anshuman Khandual khand...@linux.vnet.ibm.com

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/9c61f7a0ad6fdff85b0c

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

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

2015-07-29 Thread Anshuman Khandual
This patch just simplifies the existing code logic while fetching
the SLB size property from the device tree. This also changes the
function name from check_cpu_slb_size to init_mmu_slb_size as
it just initializes the mmu_slb_size value.

Signed-off-by: Anshuman Khandual khand...@linux.vnet.ibm.com
---
 arch/powerpc/kernel/prom.c | 18 +++---
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 8b888b1..4bb43c0 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -218,22 +218,18 @@ static void __init check_cpu_pa_features(unsigned long 
node)
 }
 
 #ifdef CONFIG_PPC_STD_MMU_64
-static void __init check_cpu_slb_size(unsigned long node)
+static void __init init_mmu_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) {
+   slb_size_ptr = of_get_flat_dt_prop(node, slb-size, NULL) ? :
+   of_get_flat_dt_prop(node, ibm,slb-size, NULL);
+
+   if (slb_size_ptr)
mmu_slb_size = be32_to_cpup(slb_size_ptr);
-   }
 }
 #else
-#define check_cpu_slb_size(node) do { } while(0)
+#define init_mmu_slb_size(node) do { } while(0)
 #endif
 
 static struct feature_property {
@@ -380,7 +376,7 @@ static int __init early_init_dt_scan_cpus(unsigned long 
node,
 
check_cpu_feature_properties(node);
check_cpu_pa_features(node);
-   check_cpu_slb_size(node);
+   init_mmu_slb_size(node);
 
 #ifdef CONFIG_PPC64
if (nthreads  1)
-- 
2.1.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

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

2015-07-21 Thread Michael Ellerman
On Tue, 2015-21-07 at 06:58:44 UTC, Anshuman Khandual wrote:
 From: khand...@linux.vnet.ibm.com khand...@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 khand...@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
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

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

2015-07-21 Thread Anshuman Khandual
On 07/21/2015 03:51 PM, Michael Ellerman wrote:
 On Tue, 2015-21-07 at 06:58:44 UTC, Anshuman Khandual wrote:
  From: khand...@linux.vnet.ibm.com khand...@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 khand...@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.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

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

2015-07-21 Thread Anshuman Khandual
From: khand...@linux.vnet.ibm.com khand...@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 khand...@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);
 }
 #else
 #define check_cpu_slb_size(node) do { } while(0)
-- 
2.1.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev