Subject: Re: [PATCH v3 04/27] ocxl: Remove unnecessary externs

From: 'Baoquan He' <[email-masked]>
Date: Wed, 26 Feb 2020 22:54:37 +0800

On 02/26/20 at 03:20pm, Greg Kurz wrote:
> On Wed, 26 Feb 2020 22:15:23 +0800
> 'Baoquan He' <[email-masked]> wrote:
> 
> > On 02/26/20 at 10:01am, Greg Kurz wrote:
> > > On Wed, 26 Feb 2020 19:26:34 +1100
> > > "Alastair D'Silva" <[email-masked]> wrote:
> > > 
> > > > > -----Original Message-----
> > > > > From: Baoquan He <[email-masked]>
> > > > > Sent: Wednesday, 26 February 2020 7:15 PM
> > > > > To: Alastair D'Silva <[email-masked]>
> > > > > Cc: [email-masked]; Aneesh Kumar K . V
> > > > > <[email-masked]>; Oliver O'Halloran <[email-masked]>;
> > > > > Benjamin Herrenschmidt <[email-masked]>; Paul Mackerras
> > > > > <[email-masked]>; Michael Ellerman <[email-masked]>; Frederic
> > > > > Barrat <[email-masked]>; Andrew Donnellan <[email-masked]>;
> > > > > Arnd Bergmann <[email-masked]>; Greg Kroah-Hartman
> > > > > <[email-masked]>; Dan Williams <[email-masked]>;
> > > > > Vishal Verma <[email-masked]>; Dave Jiang
> > > > > <[email-masked]>; Ira Weiny <[email-masked]>; Andrew Morton
> > > > > <[email-masked]>; Mauro Carvalho Chehab
> > > > > <[email-masked]>; David S. Miller <[email-masked]>;
> > > > > Rob Herring <[email-masked]>; Anton Blanchard <[email-masked]>;
> > > > > Krzysztof Kozlowski <[email-masked]>; Mahesh Salgaonkar
> > > > > <[email-masked]>; Madhavan Srinivasan
> > > > > <[email-masked]>; Cédric Le Goater <[email-masked]>; Anju T
> > > > > Sudhakar <[email-masked]>; Hari Bathini
> > > > > <[email-masked]>; Thomas Gleixner <[email-masked]>; Greg
> > > > > Kurz <[email-masked]>; Nicholas Piggin <[email-masked]>; Masahiro
> > > > > Yamada <[email-masked]>; Alexey Kardashevskiy
> > > > > <[email-masked]>; [email-masked]; linuxppc-
> > > > > [email-masked]; [email-masked]; [email-masked]
> > > > > Subject: Re: [PATCH v3 04/27] ocxl: Remove unnecessary externs
> > > > > 
> > > > > On 02/21/20 at 02:26pm, Alastair D'Silva wrote:
> > > > > > From: Alastair D'Silva <[email-masked]>
> > > > > >
> > > > > > Function declarations don't need externs, remove the existing ones so
> > > > > > they are consistent with newer code
> > > > > >
> > > > > > Signed-off-by: Alastair D'Silva <[email-masked]>
> > > > > > ---
> > > > > >  arch/powerpc/include/asm/pnv-ocxl.h | 32 ++++++++++++++---------------
> > > > > >  include/misc/ocxl.h                 |  6 +++---
> > > > > >  2 files changed, 18 insertions(+), 20 deletions(-)
> > > > > >
> > > > > > diff --git a/arch/powerpc/include/asm/pnv-ocxl.h
> > > > > > b/arch/powerpc/include/asm/pnv-ocxl.h
> > > > > > index 0b2a6707e555..b23c99bc0c84 100644
> > > > > > --- a/arch/powerpc/include/asm/pnv-ocxl.h
> > > > > > +++ b/arch/powerpc/include/asm/pnv-ocxl.h
> > > > > > @@ -9,29 +9,27 @@
> > > > > >  #define PNV_OCXL_TL_BITS_PER_RATE       4
> > > > > >  #define PNV_OCXL_TL_RATE_BUF_SIZE
> > > > > ((PNV_OCXL_TL_MAX_TEMPLATE+1) * PNV_OCXL_TL_BITS_PER_RATE / 8)
> > > > > >
> > > > > > -extern int pnv_ocxl_get_actag(struct pci_dev *dev, u16 *base, u16
> > > > > *enabled,
> > > > > > -			u16 *supported);
> > > > > 
> > > > > It works w or w/o extern when declare functions. Searching 'extern'
> > > > > under include can find so many functions with 'extern' adding. Do we have
> > > > a
> > > > > explicit standard if we should add or remove 'exter' in function
> > > > declaration?
> > > > > 
> > > > > I have no objection to this patch, just want to make clear so that I can
> > > > handle
> > > > > it w/o confusion.
> > > > > 
> > > > > Thanks
> > > > > Baoquan
> > > > > 
> > > > 
> > > > For the OpenCAPI driver, we have settled on not having 'extern' on
> > > > functions.
> > > > 
> > > > I don't think I've seen a standard that supports or refutes this, but it
> > > > does not value add.
> > > > 
> > > 
> > > FWIW this is a warning condition for checkpatch:
> > > 
> > > $ ./scripts/checkpatch.pl --strict -f include/misc/ocxl.h
> > 
> > Good to know, thanks.
> > 
> > I didn't know checkpatch.pl can run on header file directly. Tried to
> > check patch with '--strict -f', the below info doesn't appear. But it
> 
> Hmm... -f is to check a source file, not a patch... What did you try
> exactly ?

OK, that's it. I can see the 'CHECK' line when run checkpatch.pl on
patch with '--strict' only. I think this can be a good reason that we
should not add extern when add function declaration into header file.
Thanks.

> 
> > does give out below information when run on header file.
> > 
> > > 
> > > [...]
> > > 
> > > CHECK: extern prototypes should be avoided in .h files
> > > #176: FILE: include/misc/ocxl.h:176:
> > > +extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
> > > 
> > > [...]
> > > 
> > 
> 
>