summaryrefslogtreecommitdiff
path: root/drivers/media/usb/pulse8-cec
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-12-11 19:22:26 +0300
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2019-12-16 13:59:59 +0300
commitb7d0567f552a46c965d9cc30d5f7afa73a88450a (patch)
treef7a1f49685a1245552a4e16a49e396a83c409c86 /drivers/media/usb/pulse8-cec
parent92eee37d398cc738369b5a073b4f596e36958641 (diff)
downloadlinux-b7d0567f552a46c965d9cc30d5f7afa73a88450a.tar.xz
media: pulse8-cec: set tx_done_status for transmit_done status
Instead of translating work_result to a transmit_done status in pulse8_irq_work_handler(), pass the CEC_TX_STATUS via a new tx_done_status field. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/usb/pulse8-cec')
-rw-r--r--drivers/media/usb/pulse8-cec/pulse8-cec.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/drivers/media/usb/pulse8-cec/pulse8-cec.c b/drivers/media/usb/pulse8-cec/pulse8-cec.c
index 5ac257d01243..68bc2462c829 100644
--- a/drivers/media/usb/pulse8-cec/pulse8-cec.c
+++ b/drivers/media/usb/pulse8-cec/pulse8-cec.c
@@ -174,6 +174,7 @@ struct pulse8 {
u8 work_result;
struct delayed_work ping_eeprom_work;
struct cec_msg rx_msg;
+ u32 tx_done_status;
u8 data[DATA_SIZE];
unsigned int len;
u8 buf[DATA_SIZE];
@@ -266,30 +267,20 @@ static void pulse8_irq_work_handler(struct work_struct *work)
struct pulse8 *pulse8 =
container_of(work, struct pulse8, work);
u8 result = pulse8->work_result;
+ u32 status;
pulse8->work_result = 0;
switch (result & 0x3f) {
case MSGCODE_FRAME_DATA:
cec_received_msg(pulse8->adap, &pulse8->rx_msg);
break;
- case MSGCODE_TRANSMIT_SUCCEEDED:
- mutex_lock(&pulse8->lock);
- cec_transmit_attempt_done(pulse8->adap, CEC_TX_STATUS_OK);
- mutex_unlock(&pulse8->lock);
- break;
- case MSGCODE_TRANSMIT_FAILED_ACK:
- mutex_lock(&pulse8->lock);
- cec_transmit_attempt_done(pulse8->adap, CEC_TX_STATUS_NACK);
- mutex_unlock(&pulse8->lock);
- break;
- case MSGCODE_TRANSMIT_FAILED_LINE:
- case MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA:
- case MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE:
- mutex_lock(&pulse8->lock);
- cec_transmit_attempt_done(pulse8->adap, CEC_TX_STATUS_ERROR);
- mutex_unlock(&pulse8->lock);
- break;
}
+ mutex_lock(&pulse8->lock);
+ status = pulse8->tx_done_status;
+ pulse8->tx_done_status = 0;
+ mutex_unlock(&pulse8->lock);
+ if (status)
+ cec_transmit_attempt_done(pulse8->adap, status);
}
static irqreturn_t pulse8_interrupt(struct serio *serio, unsigned char data,
@@ -331,12 +322,20 @@ static irqreturn_t pulse8_interrupt(struct serio *serio, unsigned char data,
}
break;
case MSGCODE_TRANSMIT_SUCCEEDED:
- case MSGCODE_TRANSMIT_FAILED_LINE:
+ WARN_ON(pulse8->tx_done_status);
+ pulse8->tx_done_status = CEC_TX_STATUS_OK;
+ schedule_work(&pulse8->work);
+ break;
case MSGCODE_TRANSMIT_FAILED_ACK:
+ WARN_ON(pulse8->tx_done_status);
+ pulse8->tx_done_status = CEC_TX_STATUS_NACK;
+ schedule_work(&pulse8->work);
+ break;
+ case MSGCODE_TRANSMIT_FAILED_LINE:
case MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA:
case MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE:
- WARN_ON(pulse8->work_result);
- pulse8->work_result = msgcode;
+ WARN_ON(pulse8->tx_done_status);
+ pulse8->tx_done_status = CEC_TX_STATUS_ERROR;
schedule_work(&pulse8->work);
break;
case MSGCODE_HIGH_ERROR:
@@ -383,6 +382,8 @@ static int pulse8_cec_adap_enable(struct cec_adapter *adap, bool enable)
cmd[1] = enable;
err = pulse8_send_and_wait(pulse8, cmd, 2,
MSGCODE_COMMAND_ACCEPTED, 1);
+ if (!enable)
+ pulse8->tx_done_status = 0;
mutex_unlock(&pulse8->lock);
return enable ? err : 0;
}