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

parisc: factor out sid to protid conversion

Create a new __space_to_prot inline to convert the space id (mmu context)
to a protection id. Sadly it doesn't look like the #ifdef can be eliminated
since relying on the compiler to not truncate a bit on
return (ctx >> SPACEID_SHIFT) << 1;
seems a little dodgy.

Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>

authored by

Kyle McMartin and committed by
Kyle McMartin
a60715f5 0ca5506d

+10 -5
+10 -5
arch/parisc/include/asm/mmu_context.h
··· 34 34 mm->context = 0; 35 35 } 36 36 37 + static inline unsigned long __space_to_prot(mm_context_t ctx) 38 + { 39 + #if SPACEID_SHIFT == 0 40 + return context << 1; 41 + #else 42 + return context >> (SPACEID_SHIFT - 1); 43 + #endif 44 + } 45 + 37 46 static inline void load_context(mm_context_t context) 38 47 { 39 48 mtsp(context, 3); 40 - #if SPACEID_SHIFT == 0 41 - mtctl(context << 1,8); 42 - #else 43 - mtctl(context >> (SPACEID_SHIFT - 1),8); 44 - #endif 49 + mtctl(__space_to_prot(context), 8); 45 50 } 46 51 47 52 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)