Commit 4e1fc0a4 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Thomas Bogendoerfer

MIPS: CPS: Use bitfield helpers

Use the FIELD_GET() helper, instead of open-coding the same operation.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
parent 9d348f6b
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#ifndef __MIPS_ASM_MIPS_CPS_H__ #ifndef __MIPS_ASM_MIPS_CPS_H__
#define __MIPS_ASM_MIPS_CPS_H__ #define __MIPS_ASM_MIPS_CPS_H__
#include <linux/bitfield.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -112,14 +113,10 @@ static inline void clear_##unit##_##name(uint##sz##_t val) \ ...@@ -112,14 +113,10 @@ static inline void clear_##unit##_##name(uint##sz##_t val) \
*/ */
static inline unsigned int mips_cps_numclusters(void) static inline unsigned int mips_cps_numclusters(void)
{ {
unsigned int num_clusters;
if (mips_cm_revision() < CM_REV_CM3_5) if (mips_cm_revision() < CM_REV_CM3_5)
return 1; return 1;
num_clusters = read_gcr_config() & CM_GCR_CONFIG_NUM_CLUSTERS; return FIELD_GET(CM_GCR_CONFIG_NUM_CLUSTERS, read_gcr_config());
num_clusters >>= __ffs(CM_GCR_CONFIG_NUM_CLUSTERS);
return num_clusters;
} }
/** /**
...@@ -169,7 +166,8 @@ static inline unsigned int mips_cps_numcores(unsigned int cluster) ...@@ -169,7 +166,8 @@ static inline unsigned int mips_cps_numcores(unsigned int cluster)
return 0; return 0;
/* Add one before masking to handle 0xff indicating no cores */ /* Add one before masking to handle 0xff indicating no cores */
return (mips_cps_cluster_config(cluster) + 1) & CM_GCR_CONFIG_PCORES; return FIELD_GET(CM_GCR_CONFIG_PCORES,
mips_cps_cluster_config(cluster) + 1);
} }
/** /**
...@@ -181,14 +179,11 @@ static inline unsigned int mips_cps_numcores(unsigned int cluster) ...@@ -181,14 +179,11 @@ static inline unsigned int mips_cps_numcores(unsigned int cluster)
*/ */
static inline unsigned int mips_cps_numiocu(unsigned int cluster) static inline unsigned int mips_cps_numiocu(unsigned int cluster)
{ {
unsigned int num_iocu;
if (!mips_cm_present()) if (!mips_cm_present())
return 0; return 0;
num_iocu = mips_cps_cluster_config(cluster) & CM_GCR_CONFIG_NUMIOCU; return FIELD_GET(CM_GCR_CONFIG_NUMIOCU,
num_iocu >>= __ffs(CM_GCR_CONFIG_NUMIOCU); mips_cps_cluster_config(cluster));
return num_iocu;
} }
/** /**
...@@ -230,7 +225,7 @@ static inline unsigned int mips_cps_numvps(unsigned int cluster, unsigned int co ...@@ -230,7 +225,7 @@ static inline unsigned int mips_cps_numvps(unsigned int cluster, unsigned int co
mips_cm_unlock_other(); mips_cm_unlock_other();
return (cfg + 1) & CM_GCR_Cx_CONFIG_PVPE; return FIELD_GET(CM_GCR_Cx_CONFIG_PVPE, cfg + 1);
} }
#endif /* __MIPS_ASM_MIPS_CPS_H__ */ #endif /* __MIPS_ASM_MIPS_CPS_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment