From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC6FFC433FE for ; Fri, 29 Apr 2022 14:06:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352824AbiD2OKD (ORCPT ); Fri, 29 Apr 2022 10:10:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242095AbiD2OJf (ORCPT ); Fri, 29 Apr 2022 10:09:35 -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 CEA9BD17DA for ; Fri, 29 Apr 2022 07:02:32 -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-pci@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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 |