Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2277362iob; Sat, 30 Apr 2022 04:31:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9mrfAQUfnWdEv1Hf1vmGpZauWEipS0nrtU9nobfdnNlWfSDZx7OLRIQpUAiDmlZMywzI2 X-Received: by 2002:ac2:43a1:0:b0:472:1de:bbdc with SMTP id t1-20020ac243a1000000b0047201debbdcmr2758943lfl.48.1651318281061; Sat, 30 Apr 2022 04:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651318281; cv=none; d=google.com; s=arc-20160816; b=EGt9A62YbF50ordIF5Yo1vrCUqbp+N6JUBqmnnIUJFNdPuobqRpyYhE4i3XC0xI1Uw F4/TdzArpjQq5q8AGvRifKAxSJbQoeIyJAXVFx4Mz9VMhhtzSBuqw7axOfBACjTvwCgp oGmuHdclYaXPJE1ZaxEbtULRe7Q7c/kBTPxBYuM3DDIiTW+vb+bRQyf0fuXDD1euez43 Kn/iLZjtFZJYShxYoyOZfEJcdBIA918JEc0AO8omGVl3YSTNr2vZ8WK9s6pt7Z5nGgF+ FHC2C+XrwhCsjfXle4Ab5hH5t2+MpjmTTLeuOI4Ti/nmtl2dyenQKGrJDyAMKRp66ygG Toqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=FWGazNGHj9xJxAsoR+5g0YeI7XYshD5OEfjb0xUcjG8=; b=wirKmo1ma0nz/Y1JpJMs02a2tZuu8+21hhnLZ/1mTSb07Azl1jMvMRMaVrrR9oONhL dxvqhkIpTNyr2XsbfIM6ZsCwRmLP/iiOcpxLkgfUVnfuIoHZu4RH+qJ0/8dmFnFJ0HNM Teo6RXAuUYomE9iVxAEB1FxGy76NX3OqvRB7DH72uy+fMzdVT8TOUa4eB38g/ixEM4sU N3wbiFq+r3TKaUl80xo5WYexjOXot3wLATM29pKhDK5M6LckbadgHHCY4p858/sIji9H a8NolNQNICYKHLhJuPV1H3TrBkpkyDbXHZqAkxnwuXBkniSwADWn/AdxJOOCkeTf+iWa 7QIA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id by8-20020a05651c1a0800b0024dc44c54b7si10743253ljb.447.2022.04.30.04.30.54; Sat, 30 Apr 2022 04:31:21 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377050AbiD2OKF (ORCPT + 99 others); Fri, 29 Apr 2022 10:10:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376910AbiD2OJe (ORCPT ); Fri, 29 Apr 2022 10:09:34 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00E67D17D3 for ; Fri, 29 Apr 2022 07:02:29 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1nkRCT-0008Ln-N4; Fri, 29 Apr 2022 16:02:25 +0200 Message-ID: <251751c2-3d7a-db91-adbe-7d6a7e71f7e5@pengutronix.de> Date: Fri, 29 Apr 2022 16:02:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 05/37] char: impi, tpm: depend on HAS_IOPORT Content-Language: en-US To: Niklas Schnelle , Arnd Bergmann Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-pci@vger.kernel.org, Arnd Bergmann , Corey Minyard , Peter Huewe , Jarkko Sakkinen , "moderated list:IPMI SUBSYSTEM" , "open list:TPM DEVICE DRIVER" , Pengutronix Kernel Team References: <20220429135108.2781579-1-schnelle@linux.ibm.com> <20220429135108.2781579-9-schnelle@linux.ibm.com> From: Ahmad Fatoum In-Reply-To: <20220429135108.2781579-9-schnelle@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 Hello Niklas, On 29.04.22 15:50, Niklas Schnelle wrote: > In a future patch HAS_IOPORT=n will result in inb()/outb() and friends > not being declared. We thus need to add this dependency and ifdef > sections of code using inb()/outb() as alternative access methods. > > Co-developed-by: Arnd Bergmann > Signed-off-by: Niklas Schnelle [snip] > diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c > index 9c924a1440a9..2d2ae37153ba 100644 > --- a/drivers/char/tpm/tpm_infineon.c > +++ b/drivers/char/tpm/tpm_infineon.c > @@ -51,34 +51,40 @@ static struct tpm_inf_dev tpm_dev; > > static inline void tpm_data_out(unsigned char data, unsigned char offset) > { > +#ifdef CONFIG_HAS_IOPORT > if (tpm_dev.iotype == TPM_INF_IO_PORT) > outb(data, tpm_dev.data_regs + offset); > else > +#endif This looks ugly. Can't you declare inb/outb anyway and skip the definition, so you can use IS_ENABLED() here instead? You can mark the declarations with __compiletime_error("some message"), so if an IS_ENABLED() reference is not removed at compile time, you get some readable error message instead of a link error. Cheers, Ahmad > writeb(data, tpm_dev.mem_base + tpm_dev.data_regs + offset); > } > > static inline unsigned char tpm_data_in(unsigned char offset) > { > +#ifdef CONFIG_HAS_IOPORT > if (tpm_dev.iotype == TPM_INF_IO_PORT) > return inb(tpm_dev.data_regs + offset); > - else > - return readb(tpm_dev.mem_base + tpm_dev.data_regs + offset); > +#endif > + return readb(tpm_dev.mem_base + tpm_dev.data_regs + offset); > } > > static inline void tpm_config_out(unsigned char data, unsigned char offset) > { > +#ifdef CONFIG_HAS_IOPORT > if (tpm_dev.iotype == TPM_INF_IO_PORT) > outb(data, tpm_dev.config_port + offset); > else > +#endif > writeb(data, tpm_dev.mem_base + tpm_dev.index_off + offset); > } > > static inline unsigned char tpm_config_in(unsigned char offset) > { > +#ifdef CONFIG_HAS_IOPORT > if (tpm_dev.iotype == TPM_INF_IO_PORT) > return inb(tpm_dev.config_port + offset); > - else > - return readb(tpm_dev.mem_base + tpm_dev.index_off + offset); > +#endif > + return readb(tpm_dev.mem_base + tpm_dev.index_off + offset); > } > > /* TPM header definitions */ > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index dc56b976d816..1efb58dc1b41 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -879,11 +879,6 @@ static void tpm_tis_clkrun_enable(struct tpm_chip *chip, bool value) > clkrun_val &= ~LPC_CLKRUN_EN; > iowrite32(clkrun_val, data->ilb_base_addr + LPC_CNTRL_OFFSET); > > - /* > - * Write any random value on port 0x80 which is on LPC, to make > - * sure LPC clock is running before sending any TPM command. > - */ > - outb(0xCC, 0x80); > } else { > data->clkrun_enabled--; > if (data->clkrun_enabled) > @@ -894,13 +889,15 @@ static void tpm_tis_clkrun_enable(struct tpm_chip *chip, bool value) > /* Enable LPC CLKRUN# */ > clkrun_val |= LPC_CLKRUN_EN; > iowrite32(clkrun_val, data->ilb_base_addr + LPC_CNTRL_OFFSET); > - > - /* > - * Write any random value on port 0x80 which is on LPC, to make > - * sure LPC clock is running before sending any TPM command. > - */ > - outb(0xCC, 0x80); > } > + > +#ifdef CONFIG_HAS_IOPORT > + /* > + * Write any random value on port 0x80 which is on LPC, to make > + * sure LPC clock is running before sending any TPM command. > + */ > + outb(0xCC, 0x80); > +#endif > } > > static const struct tpm_class_ops tpm_tis = { -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |