Skip to content

Commit f0f0e07

Browse files
Wolfram Sangwsakernel
authored andcommitted
i2c: rcar: REP_AFTER_RD is not a persistent flag
Previous refactoring makes it easy now to convert the above flag to a non-persistent one. This is more appropriate and easier to maintain. Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 4c278db commit f0f0e07

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/i2c/busses/i2c-rcar.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,16 @@
9898
#define RCAR_IRQ_STOP (MST)
9999

100100
#define ID_LAST_MSG BIT(0)
101+
#define ID_REP_AFTER_RD BIT(1)
101102
#define ID_DONE BIT(2)
102103
#define ID_ARBLOST BIT(3)
103104
#define ID_NACK BIT(4)
104105
#define ID_EPROTO BIT(5)
105106
/* persistent flags */
106-
#define ID_P_HOST_NOTIFY BIT(28)
107-
#define ID_P_REP_AFTER_RD BIT(29)
107+
#define ID_P_HOST_NOTIFY BIT(29)
108108
#define ID_P_NO_RXDMA BIT(30) /* HW forbids RXDMA sometimes */
109109
#define ID_P_PM_BLOCKED BIT(31)
110-
#define ID_P_MASK GENMASK(31, 28)
110+
#define ID_P_MASK GENMASK(31, 29)
111111

112112
enum rcar_i2c_type {
113113
I2C_RCAR_GEN1,
@@ -341,6 +341,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
341341
static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
342342
{
343343
int read = !!rcar_i2c_is_recv(priv);
344+
bool rep_start = !(priv->flags & ID_REP_AFTER_RD);
344345

345346
priv->pos = 0;
346347
priv->flags &= ID_P_MASK;
@@ -352,9 +353,7 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
352353
if (!priv->atomic_xfer)
353354
rcar_i2c_write(priv, ICMIER, read ? RCAR_IRQ_RECV : RCAR_IRQ_SEND);
354355

355-
if (priv->flags & ID_P_REP_AFTER_RD)
356-
priv->flags &= ~ID_P_REP_AFTER_RD;
357-
else
356+
if (rep_start)
358357
rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START);
359358
}
360359

@@ -575,7 +574,7 @@ static void rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr)
575574
rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP);
576575
} else {
577576
rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START);
578-
priv->flags |= ID_P_REP_AFTER_RD;
577+
priv->flags |= ID_REP_AFTER_RD;
579578
}
580579
}
581580

@@ -706,7 +705,7 @@ static irqreturn_t rcar_i2c_gen2_irq(int irq, void *ptr)
706705
u32 msr;
707706

708707
/* Clear START or STOP immediately, except for REPSTART after read */
709-
if (likely(!(priv->flags & ID_P_REP_AFTER_RD)))
708+
if (likely(!(priv->flags & ID_REP_AFTER_RD)))
710709
rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA);
711710

712711
/* Only handle interrupts that are currently enabled */
@@ -731,7 +730,7 @@ static irqreturn_t rcar_i2c_gen3_irq(int irq, void *ptr)
731730
* Clear START or STOP immediately, except for REPSTART after read or
732731
* if a spurious interrupt was detected.
733732
*/
734-
if (likely(!(priv->flags & ID_P_REP_AFTER_RD) && msr))
733+
if (likely(!(priv->flags & ID_REP_AFTER_RD) && msr))
735734
rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA);
736735

737736
return rcar_i2c_irq(irq, priv, msr);

0 commit comments

Comments
 (0)