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

Configure Feed

Select the types of activity you want to include in your feed.

clocksource/drivers/ingenic: Use bitfield macro helpers

Use "FIELD_GET()" and "FIELD_PREP()" to simplify the code.

[dlezcano] : Changed title

Signed-off-by: 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1627638188-116163-1-git-send-email-zhouyanjie@wanyeetech.com

authored by

周琰杰 (Zhou Yanjie) and committed by
Daniel Lezcano
3b87265d be83c3b6

+7 -6
+7 -6
drivers/clocksource/ingenic-sysost.c
··· 4 4 * Copyright (c) 2020 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com> 5 5 */ 6 6 7 + #include <linux/bitfield.h> 7 8 #include <linux/bitops.h> 8 9 #include <linux/clk.h> 9 10 #include <linux/clk-provider.h> ··· 35 34 /* bits within the OSTCCR register */ 36 35 #define OSTCCR_PRESCALE1_MASK 0x3 37 36 #define OSTCCR_PRESCALE2_MASK 0xc 38 - #define OSTCCR_PRESCALE1_LSB 0 39 - #define OSTCCR_PRESCALE2_LSB 2 40 37 41 38 /* bits within the OSTCR register */ 42 39 #define OSTCR_OST1CLR BIT(0) ··· 97 98 98 99 prescale = readl(ost_clk->ost->base + info->ostccr_reg); 99 100 100 - prescale = (prescale & OSTCCR_PRESCALE1_MASK) >> OSTCCR_PRESCALE1_LSB; 101 + prescale = FIELD_GET(OSTCCR_PRESCALE1_MASK, prescale); 101 102 102 103 return parent_rate >> (prescale * 2); 103 104 } ··· 111 112 112 113 prescale = readl(ost_clk->ost->base + info->ostccr_reg); 113 114 114 - prescale = (prescale & OSTCCR_PRESCALE2_MASK) >> OSTCCR_PRESCALE2_LSB; 115 + prescale = FIELD_GET(OSTCCR_PRESCALE2_MASK, prescale); 115 116 116 117 return parent_rate >> (prescale * 2); 117 118 } ··· 150 151 int val; 151 152 152 153 val = readl(ost_clk->ost->base + info->ostccr_reg); 153 - val = (val & ~OSTCCR_PRESCALE1_MASK) | (prescale << OSTCCR_PRESCALE1_LSB); 154 + val &= ~OSTCCR_PRESCALE1_MASK; 155 + val |= FIELD_PREP(OSTCCR_PRESCALE1_MASK, prescale); 154 156 writel(val, ost_clk->ost->base + info->ostccr_reg); 155 157 156 158 return 0; ··· 166 166 int val; 167 167 168 168 val = readl(ost_clk->ost->base + info->ostccr_reg); 169 - val = (val & ~OSTCCR_PRESCALE2_MASK) | (prescale << OSTCCR_PRESCALE2_LSB); 169 + val &= ~OSTCCR_PRESCALE2_MASK; 170 + val |= FIELD_PREP(OSTCCR_PRESCALE2_MASK, prescale); 170 171 writel(val, ost_clk->ost->base + info->ostccr_reg); 171 172 172 173 return 0;