Skip to content

Commit 32c4d9e

Browse files
Kars-de-Jongalexandrebelloni
authored andcommitted
rtc: msm6242: Remove unneeded msm6242_set()/msm6242_clear() functions
The msm6242_set()/msm6242_clear() functions are used when writing to Control Register D to set or clear the HOLD bit when reading the current time from the RTC. Doing this with a read-modify-write cycle will potentially clear an interrupt condition which occurs between the read and the write. The datasheet states the following about this: When writing the HOLD or 30 second adjust bits of register D, it is necessary to write the IRQ FLAG bit to a "1". Since the only other bits in the register are the 30 second adjust bit (which is not used) and the BUSY bit (which is read-only), the read-modify-write cycle can be replaced by a simple write with the IRQ FLAG bit set to 1 and the other bits (except HOLD) set to 0. Tested-by: Kars de Jong <[email protected]> Signed-off-by: Kars de Jong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
1 parent e34494c commit 32c4d9e

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

drivers/rtc/rtc-msm6242.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,16 @@ static inline void msm6242_write(struct msm6242_priv *priv, unsigned int val,
8888
__raw_writel(val, &priv->regs[reg]);
8989
}
9090

91-
static inline void msm6242_set(struct msm6242_priv *priv, unsigned int val,
92-
unsigned int reg)
93-
{
94-
msm6242_write(priv, msm6242_read(priv, reg) | val, reg);
95-
}
96-
97-
static inline void msm6242_clear(struct msm6242_priv *priv, unsigned int val,
98-
unsigned int reg)
99-
{
100-
msm6242_write(priv, msm6242_read(priv, reg) & ~val, reg);
101-
}
102-
10391
static void msm6242_lock(struct msm6242_priv *priv)
10492
{
10593
int cnt = 5;
10694

107-
msm6242_set(priv, MSM6242_CD_HOLD, MSM6242_CD);
95+
msm6242_write(priv, MSM6242_CD_HOLD|MSM6242_CD_IRQ_FLAG, MSM6242_CD);
10896

10997
while ((msm6242_read(priv, MSM6242_CD) & MSM6242_CD_BUSY) && cnt) {
110-
msm6242_clear(priv, MSM6242_CD_HOLD, MSM6242_CD);
98+
msm6242_write(priv, MSM6242_CD_IRQ_FLAG, MSM6242_CD);
11199
udelay(70);
112-
msm6242_set(priv, MSM6242_CD_HOLD, MSM6242_CD);
100+
msm6242_write(priv, MSM6242_CD_HOLD|MSM6242_CD_IRQ_FLAG, MSM6242_CD);
113101
cnt--;
114102
}
115103

@@ -120,7 +108,7 @@ static void msm6242_lock(struct msm6242_priv *priv)
120108

121109
static void msm6242_unlock(struct msm6242_priv *priv)
122110
{
123-
msm6242_clear(priv, MSM6242_CD_HOLD, MSM6242_CD);
111+
msm6242_write(priv, MSM6242_CD_IRQ_FLAG, MSM6242_CD);
124112
}
125113

126114
static int msm6242_read_time(struct device *dev, struct rtc_time *tm)

0 commit comments

Comments
 (0)