Commit 4303553b authored by Lino Sanfilippo's avatar Lino Sanfilippo Committed by Jarkko Sakkinen

tpm, tpm_tis: Move interrupt mask checks into own function

Clean up wait_for_tpm_stat() by moving multiple similar interrupt mask
checks into an own function.
Signed-off-by: default avatarLino Sanfilippo <l.sanfilippo@kunbus.com>
Suggested-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
parent e87fcf0d
...@@ -44,6 +44,20 @@ static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask, ...@@ -44,6 +44,20 @@ static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask,
return false; return false;
} }
static u8 tpm_tis_filter_sts_mask(u8 int_mask, u8 sts_mask)
{
if (!(int_mask & TPM_INTF_STS_VALID_INT))
sts_mask &= ~TPM_STS_VALID;
if (!(int_mask & TPM_INTF_DATA_AVAIL_INT))
sts_mask &= ~TPM_STS_DATA_AVAIL;
if (!(int_mask & TPM_INTF_CMD_READY_INT))
sts_mask &= ~TPM_STS_COMMAND_READY;
return sts_mask;
}
static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
unsigned long timeout, wait_queue_head_t *queue, unsigned long timeout, wait_queue_head_t *queue,
bool check_cancel) bool check_cancel)
...@@ -53,7 +67,7 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, ...@@ -53,7 +67,7 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
long rc; long rc;
u8 status; u8 status;
bool canceled = false; bool canceled = false;
u8 sts_mask = 0; u8 sts_mask;
int ret = 0; int ret = 0;
/* check current status */ /* check current status */
...@@ -61,17 +75,10 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, ...@@ -61,17 +75,10 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
if ((status & mask) == mask) if ((status & mask) == mask)
return 0; return 0;
sts_mask = mask & (TPM_STS_VALID | TPM_STS_DATA_AVAIL |
TPM_STS_COMMAND_READY);
/* check what status changes can be handled by irqs */ /* check what status changes can be handled by irqs */
if (priv->int_mask & TPM_INTF_STS_VALID_INT) sts_mask = tpm_tis_filter_sts_mask(priv->int_mask, sts_mask);
sts_mask |= TPM_STS_VALID;
if (priv->int_mask & TPM_INTF_DATA_AVAIL_INT)
sts_mask |= TPM_STS_DATA_AVAIL;
if (priv->int_mask & TPM_INTF_CMD_READY_INT)
sts_mask |= TPM_STS_COMMAND_READY;
sts_mask &= mask;
stop = jiffies + timeout; stop = jiffies + timeout;
/* process status changes with irq support */ /* process status changes with irq support */
......
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