Skip to content

Commit

Permalink
i2c: rcar: use flags instead of atomic_xfer
Browse files Browse the repository at this point in the history
i2c-rcar already has priv->flags.
This patch add new persistent flag ID_P_ATOMIC and use it
instead of atomic_xfer.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  • Loading branch information
morimoto committed Apr 15, 2022
1 parent 088237f commit 680cb6c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/i2c/busses/i2c-rcar.c
Expand Up @@ -106,11 +106,12 @@
#define ID_ARBLOST (1 << 3)
#define ID_NACK (1 << 4)
/* persistent flags */
#define ID_P_ATOMIC BIT(27)
#define ID_P_HOST_NOTIFY BIT(28)
#define ID_P_REP_AFTER_RD BIT(29)
#define ID_P_NO_RXDMA BIT(30) /* HW forbids RXDMA sometimes */
#define ID_P_PM_BLOCKED BIT(31)
#define ID_P_MASK GENMASK(31, 28)
#define ID_P_MASK GENMASK(31, 27)

enum rcar_i2c_type {
I2C_RCAR_GEN1,
Expand Down Expand Up @@ -141,7 +142,6 @@ struct rcar_i2c_priv {
enum dma_data_direction dma_direction;

struct reset_control *rstc;
bool atomic_xfer;
int irq;

struct i2c_client *host_notify_client;
Expand Down Expand Up @@ -339,7 +339,7 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
priv->flags |= ID_LAST_MSG;

rcar_i2c_write(priv, ICMAR, i2c_8bit_addr_from_msg(priv->msg));
if (!priv->atomic_xfer)
if (!(priv->flags & ID_P_ATOMIC))
rcar_i2c_write(priv, ICMIER, read ? RCAR_IRQ_RECV : RCAR_IRQ_SEND);

/*
Expand Down Expand Up @@ -413,7 +413,7 @@ static bool rcar_i2c_dma(struct rcar_i2c_priv *priv)
int len;

/* Do various checks to see if DMA is feasible at all */
if (priv->atomic_xfer || IS_ERR(chan) || msg->len < RCAR_MIN_DMA_LEN ||
if ((priv->flags & ID_P_ATOMIC) || IS_ERR(chan) || msg->len < RCAR_MIN_DMA_LEN ||
!(msg->flags & I2C_M_DMA_SAFE) || (read && priv->flags & ID_P_NO_RXDMA))
return false;

Expand Down Expand Up @@ -641,7 +641,7 @@ static irqreturn_t rcar_i2c_irq(int irq, struct rcar_i2c_priv *priv, u32 msr)
/* Nack */
if (msr & MNR) {
/* HW automatically sends STOP after received NACK */
if (!priv->atomic_xfer)
if (!(priv->flags & ID_P_ATOMIC))
rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP);
priv->flags |= ID_NACK;
goto out;
Expand All @@ -663,7 +663,7 @@ static irqreturn_t rcar_i2c_irq(int irq, struct rcar_i2c_priv *priv, u32 msr)
if (priv->flags & ID_DONE) {
rcar_i2c_write(priv, ICMIER, 0);
rcar_i2c_write(priv, ICMSR, 0);
if (!priv->atomic_xfer)
if (!(priv->flags & ID_P_ATOMIC))
wake_up(&priv->wait);
}

Expand All @@ -681,7 +681,7 @@ static irqreturn_t rcar_i2c_gen2_irq(int irq, void *ptr)

/* Only handle interrupts that are currently enabled */
msr = rcar_i2c_read(priv, ICMSR);
if (!priv->atomic_xfer)
if (!(priv->flags & ID_P_ATOMIC))
msr &= rcar_i2c_read(priv, ICMIER);

return rcar_i2c_irq(irq, priv, msr);
Expand All @@ -694,7 +694,7 @@ static irqreturn_t rcar_i2c_gen3_irq(int irq, void *ptr)

/* Only handle interrupts that are currently enabled */
msr = rcar_i2c_read(priv, ICMSR);
if (!priv->atomic_xfer)
if (!(priv->flags & ID_P_ATOMIC))
msr &= rcar_i2c_read(priv, ICMIER);

/*
Expand Down Expand Up @@ -803,7 +803,7 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
int i, ret;
long time_left;

priv->atomic_xfer = false;
priv->flags &= ~ID_P_ATOMIC

pm_runtime_get_sync(dev);

Expand Down Expand Up @@ -869,7 +869,7 @@ static int rcar_i2c_master_xfer_atomic(struct i2c_adapter *adap,
bool time_left;
int ret;

priv->atomic_xfer = true;
priv->flags |= ID_P_ATOMIC;

pm_runtime_get_sync(dev);

Expand Down

0 comments on commit 680cb6c

Please sign in to comment.