Skip to content

Commit 7ff1172

Browse files
committed
tpm, tpm_tis: Move interrupt mask checks into own function
JIRA: https://issues.redhat.com/browse/RHEL-72765 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit 4303553 Author: Lino Sanfilippo <l.sanfilippo@kunbus.com> Date: Thu Nov 24 14:55:31 2022 +0100 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: Lino Sanfilippo <l.sanfilippo@kunbus.com> Suggested-by: Jarkko Sakkinen <jarkko@kernel.org> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
1 parent 8462dc1 commit 7ff1172

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

drivers/char/tpm/tpm_tis_core.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask,
4444
return false;
4545
}
4646

47+
static u8 tpm_tis_filter_sts_mask(u8 int_mask, u8 sts_mask)
48+
{
49+
if (!(int_mask & TPM_INTF_STS_VALID_INT))
50+
sts_mask &= ~TPM_STS_VALID;
51+
52+
if (!(int_mask & TPM_INTF_DATA_AVAIL_INT))
53+
sts_mask &= ~TPM_STS_DATA_AVAIL;
54+
55+
if (!(int_mask & TPM_INTF_CMD_READY_INT))
56+
sts_mask &= ~TPM_STS_COMMAND_READY;
57+
58+
return sts_mask;
59+
}
60+
4761
static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
4862
unsigned long timeout, wait_queue_head_t *queue,
4963
bool check_cancel)
@@ -53,25 +67,18 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
5367
long rc;
5468
u8 status;
5569
bool canceled = false;
56-
u8 sts_mask = 0;
70+
u8 sts_mask;
5771
int ret = 0;
5872

5973
/* check current status */
6074
status = chip->ops->status(chip);
6175
if ((status & mask) == mask)
6276
return 0;
6377

78+
sts_mask = mask & (TPM_STS_VALID | TPM_STS_DATA_AVAIL |
79+
TPM_STS_COMMAND_READY);
6480
/* check what status changes can be handled by irqs */
65-
if (priv->int_mask & TPM_INTF_STS_VALID_INT)
66-
sts_mask |= TPM_STS_VALID;
67-
68-
if (priv->int_mask & TPM_INTF_DATA_AVAIL_INT)
69-
sts_mask |= TPM_STS_DATA_AVAIL;
70-
71-
if (priv->int_mask & TPM_INTF_CMD_READY_INT)
72-
sts_mask |= TPM_STS_COMMAND_READY;
73-
74-
sts_mask &= mask;
81+
sts_mask = tpm_tis_filter_sts_mask(priv->int_mask, sts_mask);
7582

7683
stop = jiffies + timeout;
7784
/* process status changes with irq support */

0 commit comments

Comments
 (0)