Commit f7ceec4f authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Mauro Carvalho Chehab

[media] media: rc: nuvoton: eliminate nvt->tx.lock

Using a separate spinlock to protect access to substruct tx of struct
nvt_dev doesn't provide any actual benefit. We can use spinlock
nvt_lock to protect all access to struct nvt_dev and get rid of
nvt->tx.lock.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent b24cccca
...@@ -688,7 +688,7 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n) ...@@ -688,7 +688,7 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n)
u8 iren; u8 iren;
int ret; int ret;
spin_lock_irqsave(&nvt->tx.lock, flags); spin_lock_irqsave(&nvt->nvt_lock, flags);
ret = min((unsigned)(TX_BUF_LEN / sizeof(unsigned)), n); ret = min((unsigned)(TX_BUF_LEN / sizeof(unsigned)), n);
nvt->tx.buf_count = (ret * sizeof(unsigned)); nvt->tx.buf_count = (ret * sizeof(unsigned));
...@@ -712,13 +712,13 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n) ...@@ -712,13 +712,13 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n)
for (i = 0; i < 9; i++) for (i = 0; i < 9; i++)
nvt_cir_reg_write(nvt, 0x01, CIR_STXFIFO); nvt_cir_reg_write(nvt, 0x01, CIR_STXFIFO);
spin_unlock_irqrestore(&nvt->tx.lock, flags); spin_unlock_irqrestore(&nvt->nvt_lock, flags);
wait_event(nvt->tx.queue, nvt->tx.tx_state == ST_TX_REQUEST); wait_event(nvt->tx.queue, nvt->tx.tx_state == ST_TX_REQUEST);
spin_lock_irqsave(&nvt->tx.lock, flags); spin_lock_irqsave(&nvt->nvt_lock, flags);
nvt->tx.tx_state = ST_TX_NONE; nvt->tx.tx_state = ST_TX_NONE;
spin_unlock_irqrestore(&nvt->tx.lock, flags); spin_unlock_irqrestore(&nvt->nvt_lock, flags);
/* restore enabled interrupts to prior state */ /* restore enabled interrupts to prior state */
nvt_cir_reg_write(nvt, iren, CIR_IREN); nvt_cir_reg_write(nvt, iren, CIR_IREN);
...@@ -832,14 +832,7 @@ static void nvt_cir_log_irqs(u8 status, u8 iren) ...@@ -832,14 +832,7 @@ static void nvt_cir_log_irqs(u8 status, u8 iren)
static bool nvt_cir_tx_inactive(struct nvt_dev *nvt) static bool nvt_cir_tx_inactive(struct nvt_dev *nvt)
{ {
unsigned long flags; return nvt->tx.tx_state == ST_TX_NONE;
u8 tx_state;
spin_lock_irqsave(&nvt->tx.lock, flags);
tx_state = nvt->tx.tx_state;
spin_unlock_irqrestore(&nvt->tx.lock, flags);
return tx_state == ST_TX_NONE;
} }
/* interrupt service routine for incoming and outgoing CIR data */ /* interrupt service routine for incoming and outgoing CIR data */
...@@ -902,8 +895,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) ...@@ -902,8 +895,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
nvt_get_rx_ir_data(nvt); nvt_get_rx_ir_data(nvt);
} }
spin_unlock_irqrestore(&nvt->nvt_lock, flags);
if (status & CIR_IRSTS_TE) if (status & CIR_IRSTS_TE)
nvt_clear_tx_fifo(nvt); nvt_clear_tx_fifo(nvt);
...@@ -911,8 +902,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) ...@@ -911,8 +902,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
unsigned int pos, count; unsigned int pos, count;
u8 tmp; u8 tmp;
spin_lock_irqsave(&nvt->tx.lock, flags);
pos = nvt->tx.cur_buf_num; pos = nvt->tx.cur_buf_num;
count = nvt->tx.buf_count; count = nvt->tx.buf_count;
...@@ -925,20 +914,17 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) ...@@ -925,20 +914,17 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
tmp = nvt_cir_reg_read(nvt, CIR_IREN); tmp = nvt_cir_reg_read(nvt, CIR_IREN);
nvt_cir_reg_write(nvt, tmp & ~CIR_IREN_TTR, CIR_IREN); nvt_cir_reg_write(nvt, tmp & ~CIR_IREN_TTR, CIR_IREN);
} }
spin_unlock_irqrestore(&nvt->tx.lock, flags);
} }
if (status & CIR_IRSTS_TFU) { if (status & CIR_IRSTS_TFU) {
spin_lock_irqsave(&nvt->tx.lock, flags);
if (nvt->tx.tx_state == ST_TX_REPLY) { if (nvt->tx.tx_state == ST_TX_REPLY) {
nvt->tx.tx_state = ST_TX_REQUEST; nvt->tx.tx_state = ST_TX_REQUEST;
wake_up(&nvt->tx.queue); wake_up(&nvt->tx.queue);
} }
spin_unlock_irqrestore(&nvt->tx.lock, flags);
} }
spin_unlock_irqrestore(&nvt->nvt_lock, flags);
nvt_dbg_verbose("%s done", __func__); nvt_dbg_verbose("%s done", __func__);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -1052,7 +1038,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) ...@@ -1052,7 +1038,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
nvt->cr_efdr = CR_EFDR; nvt->cr_efdr = CR_EFDR;
spin_lock_init(&nvt->nvt_lock); spin_lock_init(&nvt->nvt_lock);
spin_lock_init(&nvt->tx.lock);
pnp_set_drvdata(pdev, nvt); pnp_set_drvdata(pdev, nvt);
...@@ -1152,12 +1137,10 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state) ...@@ -1152,12 +1137,10 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
nvt_dbg("%s called", __func__); nvt_dbg("%s called", __func__);
spin_lock_irqsave(&nvt->tx.lock, flags);
nvt->tx.tx_state = ST_TX_NONE;
spin_unlock_irqrestore(&nvt->tx.lock, flags);
spin_lock_irqsave(&nvt->nvt_lock, flags); spin_lock_irqsave(&nvt->nvt_lock, flags);
nvt->tx.tx_state = ST_TX_NONE;
/* disable all CIR interrupts */ /* disable all CIR interrupts */
nvt_cir_reg_write(nvt, 0, CIR_IREN); nvt_cir_reg_write(nvt, 0, CIR_IREN);
......
...@@ -87,7 +87,6 @@ struct nvt_dev { ...@@ -87,7 +87,6 @@ struct nvt_dev {
unsigned int pkts; unsigned int pkts;
struct { struct {
spinlock_t lock;
u8 buf[TX_BUF_LEN]; u8 buf[TX_BUF_LEN];
unsigned int buf_count; unsigned int buf_count;
unsigned int cur_buf_num; unsigned int cur_buf_num;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment