From patchwork Mon Oct 17 23:57:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 3851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1698076wrs; Mon, 17 Oct 2022 17:04:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jloy6eIUB3R34lT2Q76xQBu904HvwSinI7ezfRICyRtPejxWKX4dYIAngBkYN2RFGJZAb X-Received: by 2002:a17:906:5dce:b0:78d:e71a:6e0 with SMTP id p14-20020a1709065dce00b0078de71a06e0mr204264ejv.360.1666051460185; Mon, 17 Oct 2022 17:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666051460; cv=none; d=google.com; s=arc-20160816; b=nH6xKYtVN+rOU6RVlZ0nISePxMO/X46e5WbK+IQCVY+kcntEGqovlE4BHeNv4rSFU3 8A07zXAs/kgGl6xU1jbRO2NrX+fr52oGtKow7DINWdqp/e3tLU83GEJgQBVEqmCjtAaJ tgCSGQS7IXhW9bOPrYEd1DpXLSV+5EUfxzeqc+ix/p2+fx7lisb+5BmV0o9zrAP9YQba B1IPaygWFLGM2UO6umdrGeYvC20qf8xFE/VHIVQlee59R9JWPDyZkzwXdOM4pWYl/fde xEOwtacRQADdUWplWSYDVRkpvH8nqWPba5ajkwZim7ZqERNeIwHJBXa81uR+CiACvRzV H8GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BzRmHyDjx6k9QxSMFomIGBOCh5qkOm5olPta9ZMqnS8=; b=kHSCR++UTYyMJOXjmYtqPZhN0mFRHDgQ9cQt1LdbvBg+Lm77Fqqmu5WhsjeteOFytm xXdKUVSkOkJ2zMlDIuo38rgWXGzAk6l3QrBzPDTd6ojFnDvMSFLereOf80m17OZ+nkPT tPmc7qmGQQDUehIutrP7XpBp9StRBnGc7owXcPEwB2WuUcIr5rpMI5rnass+WUKQDUuJ hI1sZugD/wi2GusfRlQ4wDoB2o+YCay8p0GXCxj+iZltxsV0SqOKUKZ6Uyig3GP6vwif rWmJu68VZUIpAX4IRy3nvoGi4thop+iplFdXmMXE8qFVbD3JLPAKc1KqMOq/o388siDp m15A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b="j/khhM9e"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr40-20020a1709073fa800b00780cb1272eesi11920929ejc.466.2022.10.17.17.03.41; Mon, 17 Oct 2022 17:04:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b="j/khhM9e"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231310AbiJQX6q (ORCPT + 99 others); Mon, 17 Oct 2022 19:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231161AbiJQX6S (ORCPT ); Mon, 17 Oct 2022 19:58:18 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD047E03A; Mon, 17 Oct 2022 16:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1666051072; bh=BzRmHyDjx6k9QxSMFomIGBOCh5qkOm5olPta9ZMqnS8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=j/khhM9e5wP+lpawLuxx74yOycNZXoKBT8E+6UYh2N4nvDr3jZCVR2NR0MfC9UUjW v1i1nNtrlQNm/nxRPJFFAw4ffa+MKvNCqbgebowRaQWfqu5L/Azcw3JpSRH5ZbdwJx gpFcC52q61PtXpoYj5CU0gxa04wxFgo66VzPL03c= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.speedport.ip ([84.162.5.241]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MFKGP-1ovHNh1Lzd-00FhEt; Tue, 18 Oct 2022 01:57:52 +0200 From: Lino Sanfilippo To: peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca Cc: stefanb@linux.vnet.ibm.com, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, jandryuk@gmail.com, pmenzel@molgen.mpg.de, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH v8 06/11] tpm, tpm_tis: Move interrupt mask checks into own function Date: Tue, 18 Oct 2022 01:57:27 +0200 Message-Id: <20221017235732.10145-7-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221017235732.10145-1-LinoSanfilippo@gmx.de> References: <20221017235732.10145-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:WDob0q+nal8PS7PWDU+fKAFyHJK7IwCY8X4P/1Xsz/Pgvm8OM6r sl7h41ANDn+c6YsHCP7tPEqtOCh5M/LnOpygKNBlI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dTXbSBZ0WjDP4x1RD4UZntujYro2w+y+3bXAvrhfO1bWOR6FW3Ttgzd7AVnwqk36 /SB25OQG91xW/YynhPrMcKxqxQTU06ovB8RXVP9wBSoL+WO3PvAfN2eQFRUaKtqOo75IpZM0i El4YU9ghJashgo5A3YXUKR160KTVe85dohopTAB5wpC+dFNr+twCi/escG1ACDlsnsg7BrBh/ JHOLp7c4qZf/RusBoMu+dS1V6Qp0QDQ+8E/2k7Wloo0MPomWisYVxk5hJDUoqGqyq2MwUWF9R B4Ap4Bg9L3JI5TtMXJPDhlpPAj5p7SB4tpP3V5+taTwZe/Jt/f64x0xHbtgFjYtWT5w1m7sme ylSUAmTieYCCDulxjF7kt+7RU+rPM4FXnPBtRBknkBm+aG8LXGBM0/O9WlYS3aFMZ71cMkQaI 4HvckO10vJO4eYXF4Y3igLUysSkQSWHDjRgs/Kcp+jWDd4Weh0USfseA8LsYyOeAAu8swICPO httAa7pv8NvpbQbGMPJMVFGmeEECHUz4IGsm24e9yvhp/at05WhTkiiIZMCf1KD67PYO9kS6H veBKYlaiDEhhtXPT2eJUoQaY0jXrawG6xnwNVnhvXF7Z9XStCw8O+qI/uJXvcoUJKUxMHxfvb yUihLO8RDuJh2HJLB6DDV+6IS7jPIPErp/s9rfgnBjpVU X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,MIME_BASE64_TEXT,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746981576086655557?= X-GMAIL-MSGID: =?utf-8?q?1746981576086655557?= From: Lino Sanfilippo Clean up wait_for_tpm_stat() by moving multiple similar interrupt mask checks into an own function. Signed-off-by: Lino Sanfilippo Suggested-by: Jarkko Sakkinen Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index d07debc3182c..181c291b0bb8 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -44,6 +44,20 @@ static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask, 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, unsigned long timeout, wait_queue_head_t *queue, bool check_cancel) @@ -53,7 +67,7 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, long rc; u8 status; bool canceled = false; - u8 sts_mask = 0; + u8 sts_mask; int ret = 0; /* check current status */ @@ -61,17 +75,10 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, if ((status & mask) == mask) 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 */ - if (priv->int_mask & TPM_INTF_STS_VALID_INT) - 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; + sts_mask = tpm_tis_filter_sts_mask(priv->int_mask, sts_mask); stop = jiffies + timeout; /* process status changes with irq support */