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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABD29C43334 for ; Fri, 10 Jun 2022 09:41:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 33FC38D0086; Fri, 10 Jun 2022 05:41:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2EF996B0159; Fri, 10 Jun 2022 05:41:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DDF98D0086; Fri, 10 Jun 2022 05:41:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0EEA96B0158 for ; Fri, 10 Jun 2022 05:41:19 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id CCB7D60998 for ; Fri, 10 Jun 2022 09:41:18 +0000 (UTC) X-FDA: 79561833036.05.AE71F63 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf07.hostedemail.com (Postfix) with ESMTP id E6B0540054 for ; Fri, 10 Jun 2022 09:41:17 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id DC1CFCE3473; Fri, 10 Jun 2022 09:41:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EBF3C34114; Fri, 10 Jun 2022 09:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654854072; bh=RFUzyhUSwzSu4iiHMiqKtHk3uhYnFdDUQekeZLUrGmk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WAJdh4OPIfIrsMMSyYq0pYDhh9+9rJgP2K/4RZHv6EPvUgWlk8QHEHDAGvr2rJK3V YGiwI6CK3/M+WgZBsTIFlfYQJfXnRpJBu0NXcSFJS4xBjPIs8OQ1HWYsy9coEJWm/c bihiPgSDbzv8rsP8yPuyzSCUHQqqr+jrY0fSFG1o= Date: Fri, 10 Jun 2022 11:41:09 +0200 From: Greg Kroah-Hartman To: Wang Wenhu Cc: Arnd Bergmann , Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , Bjorn Helgaas , Andrew Morton , open list , "open list:FPGA DFL DRIVERS" , "open list:PCI SUBSYSTEM" , "open list:MEMORY MANAGEMENT" , wenhu.wang@hotmail.com Subject: Re: [PATCH] mm: eliminate ifdef of HAVE_IOREMAP_PROT in .c files Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654854078; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qWJMaDqSxJaa2KL0dmHmVuIoFz3x2y2B1/8+nQSnLK4=; b=osAXC/xzRuNp3getP3QG2ageLtk3ouCH0nOhwiJiocjTSXXyPhVL2I5VTbR9VDXLDggtiE 1kzNuzcKJsx88mEJerGbgFUTjuefsQvtx+ACoNFjBwH8/aNmF3NZ35He6dA84ckadJxFrg RuW2ZRNk5Lu+kytY+Jbjc2Bc2etdS+I= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=WAJdh4OP; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf07.hostedemail.com: domain of gregkh@linuxfoundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654854078; a=rsa-sha256; cv=none; b=pc0/XR6IFbdxNGzXYGgth7/NP3NSnAnPz3Urmg3z+qa11NmDihrYgfqyEa0SWm2IezhXFU 1Z4YKErAtUIfl/sRn7KBjhEDtxJosalitDHkDmUr4C6S8Aws50bSRleStYuVWJTpiZZlsm g2Eq5RKMoi6Yd2Pw0xVSgw0G1njMigQ= X-Stat-Signature: ndrd663b6qawhymiszyg1h13wpfs68wb X-Rspamd-Queue-Id: E6B0540054 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=WAJdh4OP; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf07.hostedemail.com: domain of gregkh@linuxfoundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1654854077-400817 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jun 10, 2022 at 02:25:18AM -0700, Wang Wenhu wrote: > It is recommended in the "Conditional Compilation" chapter of kernel > coding-style documentation that preprocessor conditionals should not > be used in .c files wherever possible. > > As for the micro CONFIG_HAVE_IOREMAP_PROT, now it's a proper chance > to eliminate it in .c files as we add a no-op function defination > in the header file if the micro is not enabled. > > The main trigger for this patch is an UIO driver series and as Greg > commented we'd better not use such preprocessor contionals. > See: https://lore.kernel.org/lkml/YqHy1uXwCLlJmftr@kroah.com/ > For there is little work to do with the UIO driver, I try to push > this commit independently. > > Signed-off-by: Wang Wenhu > --- > drivers/char/mem.c | 2 -- > drivers/fpga/dfl-afu-main.c | 2 -- > drivers/pci/mmap.c | 2 -- > drivers/uio/uio.c | 2 -- > include/linux/mm.h | 8 ++++++++ > mm/memory.c | 4 ---- > 6 files changed, 8 insertions(+), 12 deletions(-) > > diff --git a/drivers/char/mem.c b/drivers/char/mem.c > index 84ca98ed1dad..40186a441e38 100644 > --- a/drivers/char/mem.c > +++ b/drivers/char/mem.c > @@ -354,9 +354,7 @@ static inline int private_mapping_ok(struct vm_area_struct *vma) > #endif > > static const struct vm_operations_struct mmap_mem_ops = { > -#ifdef CONFIG_HAVE_IOREMAP_PROT > .access = generic_access_phys > -#endif > }; > > static int mmap_mem(struct file *file, struct vm_area_struct *vma) > diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c > index 7f621e96d3b8..833e14806c7a 100644 > --- a/drivers/fpga/dfl-afu-main.c > +++ b/drivers/fpga/dfl-afu-main.c > @@ -797,9 +797,7 @@ static long afu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > } > > static const struct vm_operations_struct afu_vma_ops = { > -#ifdef CONFIG_HAVE_IOREMAP_PROT > .access = generic_access_phys, > -#endif > }; > > static int afu_mmap(struct file *filp, struct vm_area_struct *vma) > diff --git a/drivers/pci/mmap.c b/drivers/pci/mmap.c > index b8c9011987f4..1dcfabf80453 100644 > --- a/drivers/pci/mmap.c > +++ b/drivers/pci/mmap.c > @@ -35,9 +35,7 @@ int pci_mmap_page_range(struct pci_dev *pdev, int bar, > #endif > > static const struct vm_operations_struct pci_phys_vm_ops = { > -#ifdef CONFIG_HAVE_IOREMAP_PROT > .access = generic_access_phys, > -#endif > }; > > int pci_mmap_resource_range(struct pci_dev *pdev, int bar, > diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c > index 43afbb7c5ab9..c9205a121007 100644 > --- a/drivers/uio/uio.c > +++ b/drivers/uio/uio.c > @@ -719,9 +719,7 @@ static int uio_mmap_logical(struct vm_area_struct *vma) > } > > static const struct vm_operations_struct uio_physical_vm_ops = { > -#ifdef CONFIG_HAVE_IOREMAP_PROT > .access = generic_access_phys, > -#endif > }; > > static int uio_mmap_physical(struct vm_area_struct *vma) > diff --git a/include/linux/mm.h b/include/linux/mm.h > index bc8f326be0ce..66d0cff6054e 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1857,8 +1857,16 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address, > unsigned long *pfn); > int follow_phys(struct vm_area_struct *vma, unsigned long address, > unsigned int flags, unsigned long *prot, resource_size_t *phys); > +#ifdef CONFIG_HAVE_IOREMAP_PROT > int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, > void *buf, int len, int write); > +#else > +int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, > + void *buf, int len, int write) This needs to be an inline function, right? Did you test build this? thanks, greg k-h