Skip to content

Commit 63f9d9d

Browse files
chleroympe
authored andcommitted
powerpc/time: Remove ifdef in get_dec() and set_dec()
Move SPRN_PIT definition in reg.h. This allows to remove ifdef in get_dec() and set_dec() and makes them more readable. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/3c9a6eb0fc040868ac59be66f338d08fd017668d.1601549945.git.christophe.leroy@csgroup.eu
1 parent 6601ec1 commit 63f9d9d

3 files changed

Lines changed: 12 additions & 14 deletions

File tree

arch/powerpc/include/asm/reg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@
521521
#define SPRN_TSCR 0x399 /* Thread Switch Control Register */
522522

523523
#define SPRN_DEC 0x016 /* Decrement Register */
524+
#define SPRN_PIT 0x3DB /* Programmable Interval Timer (40x/BOOKE) */
525+
524526
#define SPRN_DER 0x095 /* Debug Enable Register */
525527
#define DER_RSTE 0x40000000 /* Reset Interrupt */
526528
#define DER_CHSTPE 0x20000000 /* Check Stop */

arch/powerpc/include/asm/reg_booke.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@
174174
#define SPRN_L1CSR1 0x3F3 /* L1 Cache Control and Status Register 1 */
175175
#define SPRN_MMUCSR0 0x3F4 /* MMU Control and Status Register 0 */
176176
#define SPRN_MMUCFG 0x3F7 /* MMU Configuration Register */
177-
#define SPRN_PIT 0x3DB /* Programmable Interval Timer */
178177
#define SPRN_BUCSR 0x3F5 /* Branch Unit Control and Status */
179178
#define SPRN_L2CSR0 0x3F9 /* L2 Data Cache Control and Status Register 0 */
180179
#define SPRN_L2CSR1 0x3FA /* L2 Data Cache Control and Status Register 1 */

arch/powerpc/include/asm/time.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,10 @@ static inline void set_tb(unsigned int upper, unsigned int lower)
100100
*/
101101
static inline u64 get_dec(void)
102102
{
103-
#if defined(CONFIG_40x)
104-
return (mfspr(SPRN_PIT));
105-
#else
106-
return (mfspr(SPRN_DEC));
107-
#endif
103+
if (IS_ENABLED(CONFIG_40x))
104+
return mfspr(SPRN_PIT);
105+
106+
return mfspr(SPRN_DEC);
108107
}
109108

110109
/*
@@ -114,14 +113,12 @@ static inline u64 get_dec(void)
114113
*/
115114
static inline void set_dec(u64 val)
116115
{
117-
#if defined(CONFIG_40x)
118-
mtspr(SPRN_PIT, (u32) val);
119-
#else
120-
#ifndef CONFIG_BOOKE
121-
--val;
122-
#endif
123-
mtspr(SPRN_DEC, val);
124-
#endif /* not 40x */
116+
if (IS_ENABLED(CONFIG_40x))
117+
mtspr(SPRN_PIT, (u32)val);
118+
else if (IS_ENABLED(CONFIG_BOOKE))
119+
mtspr(SPRN_DEC, val);
120+
else
121+
mtspr(SPRN_DEC, val - 1);
125122
}
126123

127124
static inline unsigned long tb_ticks_since(unsigned long tstamp)

0 commit comments

Comments
 (0)