From patchwork Thu Nov 10 15:25: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: 18170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp212116wru; Thu, 10 Nov 2022 07:29:05 -0800 (PST) X-Google-Smtp-Source: AMsMyM7Hj/YCQQSLyLwq9+Woh3fojVQQqFiOyccVJvBEIcHFwLRXHIQ0Nbc1vDKkpoZtF7qdNlOJ X-Received: by 2002:a17:906:3017:b0:78d:b598:bb6a with SMTP id 23-20020a170906301700b0078db598bb6amr2911705ejz.258.1668094145721; Thu, 10 Nov 2022 07:29:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668094145; cv=none; d=google.com; s=arc-20160816; b=U9TI5Ict4MiSo7cIhzW5d/xweC589MHMH6bMBPIqQoJmlB/mshjobrplIact65llVS BM7RwYiqvCaLS23jRMTnyqcnonQt1xfiNI5mIJmCnwD46QN2FE6San2orj1gJYp+p0Yq gcmUym7HaCpGst7qpGczGfgjLD8pGY9DOLKIw2gCojPvK6gchYxShEtFKAjXm1fSg5E8 alxl415LiwMoPqO95+Vms3taA3ucUEsd2dNk7nl0ZxrirPGqvIPALeGgDiZ1UQzU/SYh 8jXae0RSZX159Emccm1BQ5cS27nP54cv/2YHySCnxBv1wT2QoRgXpj4XWFd6t/794zo/ fyNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BzRmHyDjx6k9QxSMFomIGBOCh5qkOm5olPta9ZMqnS8=; b=ONHWPfpq7ztFDXxGFtwnK0RKS9yrFsiRT5DbzWCcKNwQqcMewqMK9rm4rNjq1pOaME 60p8oW+/kPh1OUwElANUHVjAFmvbrkWkGpGmCHidVFPwjPFw5ZZ08gpp+VAHz5z40u3C P8uHx6QKye1crHBpCIq8vTPTmI3RlMX4BLxI2RdqWY16gqK241DQIiw8Jobf9MpJhFd5 38asfeT1OaYYB7YA2R77BULv6skeyYXglnE9aHeDJWMw49ViNEKOmI+l7aRzAb60A/Zw hg4fUjoCQOTVAg871PO6g/LMQ7DxlEUGmuGrIUzN191ny8ypduVxXs8DozfA6w9gWApq 1z9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=oY6fc+MY; 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=pass (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 f12-20020a170906390c00b00780805b99ccsi14441639eje.648.2022.11.10.07.28.39; Thu, 10 Nov 2022 07:29:05 -0800 (PST) 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.de header.s=s31663417 header.b=oY6fc+MY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbiKJP0t (ORCPT + 99 others); Thu, 10 Nov 2022 10:26:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbiKJP0Z (ORCPT ); Thu, 10 Nov 2022 10:26:25 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E04063F057; Thu, 10 Nov 2022 07:26:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1668093944; bh=BzRmHyDjx6k9QxSMFomIGBOCh5qkOm5olPta9ZMqnS8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=oY6fc+MYBmRFOvgb1YCUuqd6X+pZtADhu3inWas+5FfA/rSVClrbBWfvPFhTl6djQ v9ej/mziiOQMsOxkFUgWGlsCSXzxAVhDPhKyN/xh6DQx6ieT6UHaNfa5bEEh4RxqPZ 51gng7vWATJ1935pn85laTRnf6KebPt66RJimf0sDUAYhUSkJSPu5ygNpHPKfQvIQo 2tzggNsFvU2TjLy4cg7roPmIBj5kZCnC0LkiKGIW96fL+6ZGaJkPOPMoA6Tp4+II4k fekEygrmS32NeEQ63LVuuiffk2hKMO7o1zkJZ/yvo6wUrZnU0zzaPaXu+bVP/DxiYZ EPzKUdXv1OQpQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MXp9Y-1oTwV23BQS-00Y6S9; Thu, 10 Nov 2022 16:25:44 +0100 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 v9 06/12] tpm, tpm_tis: Move interrupt mask checks into own function Date: Thu, 10 Nov 2022 16:25:27 +0100 Message-Id: <20221110152533.24243-7-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221110152533.24243-1-LinoSanfilippo@gmx.de> References: <20221110152533.24243-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:cFLkuomk+v0SkP7u8SezZBP73KBGJZF+fzCImxN4pepHBu5mmiO WmkjjVnyKIMm8XUfP1CeWH7OAbdnoIbnWYanzNGiKAY+F+5PL/F41fRNg0sp9A8LZm136lk TtzqNt0X+LzYIX/bfXTtDWSsMgWA2dqaDIaMXq4pqBC7ZqVcWDnwMbDB+bNeoE+/2+E3TMV EfrSj4atodSK8n4KR2JQQ== UI-OutboundReport: notjunk:1;M01:P0:lP6ySNlNswI=;hZlaPPrCIuE9fbdQsSy5xcOLm7o Y1+ZA49ssqiuYcDb/0XdwAYWFCM/yHjRT7WOgAZz4xtX/36EriSQ4RH/btxVIpaCr9htSdkoN jhLfjOYF4i1pPetZSWJS0q7aRUT9D9xKXwBDKXtwsUIgePBl5GNo41756hkkmtitsgfz/a8nF omkPJvjMsYJpwIiG73JeziCK/0gGNZMgYsYtlJHITM6PE1iyHQK+yxrsSVnRvTBNffSN0t0IY WQeVmAuykY/ThW6ikbSw3kQYla3AWQyvIDEM4LsGfLJM0NbphDsJKcX52MM1oyLzeEQGlImap 9qMH7eZcX0eqGZa+uNc5ZsKa/yjNQlkDGYaOrYBw3Po0p2o+xWIcuCb57D6js0uyy3mbKD0RK i8lQUZwh8OhyUFUDB1dhpIvJsmtIB+dB+FXIftHyThgll0VGGQbe8F+DtaHmx0/ydK8C7Exmf A7+vIW4uW3U8vm0O8xESS1di+xUfYPcggfx6uY/6E2vBrw2Rj8a2UwLvr9eg661GfY/Q7YQYY c6SpyuqU+x35azXxgAbnrZQFsNIL6CsfsgFJlzs4O8lB4ECIBoahX1p5QZzpRCkG6vJkeoQ+Q /jS7JLe7s1hD6B1mmG7UOGF4hQ9gG1s2P6aSaAfvUSrfWJUpSs3moni+o8/iFneVkGt6+26yH uDDum/OKxZs8Y3s5AKkPf1J50bDcbJzlBjtD76qjWBzZ/ZMVyNfIGK9QiAt1vizPZci08/mHx U92021RTCnjcwUylWhSIdpeMZ96n/527q4Tg0Rvcl32INyOwk7cYxYu3OHZ54kcQbiRNhkfQX rB8oisujW1e2g8ajYu85rspxHXrCOSdHbUS6HMJzdEqqum9QKm6QxqdvfWmREgxuzqhLMs9Pu 9Z1d2u5OBaZtU2RqekAaso2rxQGi6m75eN3nTPFEF107etCkQlVbmJYpI71JacBuf/PCZ6MGY NkI2hU4tEm5o2mTBKoB3rg5X9gw= X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1749123486943549719?= X-GMAIL-MSGID: =?utf-8?q?1749123486943549719?= 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 */