Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: CPS: Use bitfield helpers

Use the FIELD_GET() helper, instead of open-coding the same operation.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Geert Uytterhoeven and committed by
Thomas Bogendoerfer
4e1fc0a4 9d348f6b

+7 -12
+7 -12
arch/mips/include/asm/mips-cps.h
··· 7 7 #ifndef __MIPS_ASM_MIPS_CPS_H__ 8 8 #define __MIPS_ASM_MIPS_CPS_H__ 9 9 10 + #include <linux/bitfield.h> 10 11 #include <linux/io.h> 11 12 #include <linux/types.h> 12 13 ··· 113 112 */ 114 113 static inline unsigned int mips_cps_numclusters(void) 115 114 { 116 - unsigned int num_clusters; 117 - 118 115 if (mips_cm_revision() < CM_REV_CM3_5) 119 116 return 1; 120 117 121 - num_clusters = read_gcr_config() & CM_GCR_CONFIG_NUM_CLUSTERS; 122 - num_clusters >>= __ffs(CM_GCR_CONFIG_NUM_CLUSTERS); 123 - return num_clusters; 118 + return FIELD_GET(CM_GCR_CONFIG_NUM_CLUSTERS, read_gcr_config()); 124 119 } 125 120 126 121 /** ··· 166 169 return 0; 167 170 168 171 /* Add one before masking to handle 0xff indicating no cores */ 169 - return (mips_cps_cluster_config(cluster) + 1) & CM_GCR_CONFIG_PCORES; 172 + return FIELD_GET(CM_GCR_CONFIG_PCORES, 173 + mips_cps_cluster_config(cluster) + 1); 170 174 } 171 175 172 176 /** ··· 179 181 */ 180 182 static inline unsigned int mips_cps_numiocu(unsigned int cluster) 181 183 { 182 - unsigned int num_iocu; 183 - 184 184 if (!mips_cm_present()) 185 185 return 0; 186 186 187 - num_iocu = mips_cps_cluster_config(cluster) & CM_GCR_CONFIG_NUMIOCU; 188 - num_iocu >>= __ffs(CM_GCR_CONFIG_NUMIOCU); 189 - return num_iocu; 187 + return FIELD_GET(CM_GCR_CONFIG_NUMIOCU, 188 + mips_cps_cluster_config(cluster)); 190 189 } 191 190 192 191 /** ··· 225 230 226 231 mips_cm_unlock_other(); 227 232 228 - return (cfg + 1) & CM_GCR_Cx_CONFIG_PVPE; 233 + return FIELD_GET(CM_GCR_Cx_CONFIG_PVPE, cfg + 1); 229 234 } 230 235 231 236 #endif /* __MIPS_ASM_MIPS_CPS_H__ */