2020-02-21 03:29:42

by Alastair D'Silva

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

From: Alastair D'Silva <[email protected]>

Function declarations don't need externs, remove the existing ones
so they are consistent with newer code

Signed-off-by: Alastair D'Silva <[email protected]>
---
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);
-extern int pnv_ocxl_get_pasid_count(struct pci_dev *dev, int *count);
+int pnv_ocxl_get_actag(struct pci_dev *dev, u16 *base, u16 *enabled, u16 *supported);
+int pnv_ocxl_get_pasid_count(struct pci_dev *dev, int *count);

-extern int pnv_ocxl_get_tl_cap(struct pci_dev *dev, long *cap,
+int pnv_ocxl_get_tl_cap(struct pci_dev *dev, long *cap,
char *rate_buf, int rate_buf_size);
-extern int pnv_ocxl_set_tl_conf(struct pci_dev *dev, long cap,
+int pnv_ocxl_set_tl_conf(struct pci_dev *dev, long cap,
uint64_t rate_buf_phys, int rate_buf_size);

-extern int pnv_ocxl_get_xsl_irq(struct pci_dev *dev, int *hwirq);
-extern void pnv_ocxl_unmap_xsl_regs(void __iomem *dsisr, void __iomem *dar,
- void __iomem *tfc, void __iomem *pe_handle);
-extern int pnv_ocxl_map_xsl_regs(struct pci_dev *dev, void __iomem **dsisr,
- void __iomem **dar, void __iomem **tfc,
- void __iomem **pe_handle);
+int pnv_ocxl_get_xsl_irq(struct pci_dev *dev, int *hwirq);
+void pnv_ocxl_unmap_xsl_regs(void __iomem *dsisr, void __iomem *dar,
+ void __iomem *tfc, void __iomem *pe_handle);
+int pnv_ocxl_map_xsl_regs(struct pci_dev *dev, void __iomem **dsisr,
+ void __iomem **dar, void __iomem **tfc,
+ void __iomem **pe_handle);

-extern int pnv_ocxl_spa_setup(struct pci_dev *dev, void *spa_mem, int PE_mask,
- void **platform_data);
-extern void pnv_ocxl_spa_release(void *platform_data);
-extern int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle);
+int pnv_ocxl_spa_setup(struct pci_dev *dev, void *spa_mem, int PE_mask, void **platform_data);
+void pnv_ocxl_spa_release(void *platform_data);
+int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle);

-extern int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr);
-extern void pnv_ocxl_free_xive_irq(u32 irq);
+int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr);
+void pnv_ocxl_free_xive_irq(u32 irq);
#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
u64 pnv_ocxl_platform_lpc_setup(struct pci_dev *pdev, u64 size);
void pnv_ocxl_platform_lpc_release(struct pci_dev *pdev);
diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
index 06dd5839e438..0a762e387418 100644
--- a/include/misc/ocxl.h
+++ b/include/misc/ocxl.h
@@ -173,7 +173,7 @@ int ocxl_context_detach(struct ocxl_context *ctx);
*
* Returns 0 on success, negative on failure
*/
-extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
+int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);

/**
* Frees an IRQ associated with an AFU context
@@ -182,7 +182,7 @@ extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
*
* Returns 0 on success, negative on failure
*/
-extern int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);
+int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);

/**
* Gets the address of the trigger page for an IRQ
@@ -193,7 +193,7 @@ extern int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);
*
* returns the trigger page address, or 0 if the IRQ is not valid
*/
-extern u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id);
+u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id);

/**
* Provide a callback to be called when an IRQ is triggered
--
2.24.1


2020-02-21 06:08:02

by Andrew Donnellan

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

On 21/2/20 2:26 pm, Alastair D'Silva wrote:
> From: Alastair D'Silva <[email protected]>
>
> Function declarations don't need externs, remove the existing ones
> so they are consistent with newer code
>
> Signed-off-by: Alastair D'Silva <[email protected]>

Acked-by: Andrew Donnellan <[email protected]>


--
Andrew Donnellan OzLabs, ADL Canberra
[email protected] IBM Australia Limited

2020-02-25 13:25:07

by Frederic Barrat

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



Le 21/02/2020 à 04:26, Alastair D'Silva a écrit :
> From: Alastair D'Silva <[email protected]>
>
> Function declarations don't need externs, remove the existing ones
> so they are consistent with newer code
>
> Signed-off-by: Alastair D'Silva <[email protected]>
> ---

Thanks for the cleanup!
Acked-by: Frederic Barrat <[email protected]>




> 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);
> -extern int pnv_ocxl_get_pasid_count(struct pci_dev *dev, int *count);
> +int pnv_ocxl_get_actag(struct pci_dev *dev, u16 *base, u16 *enabled, u16 *supported);
> +int pnv_ocxl_get_pasid_count(struct pci_dev *dev, int *count);
>
> -extern int pnv_ocxl_get_tl_cap(struct pci_dev *dev, long *cap,
> +int pnv_ocxl_get_tl_cap(struct pci_dev *dev, long *cap,
> char *rate_buf, int rate_buf_size);
> -extern int pnv_ocxl_set_tl_conf(struct pci_dev *dev, long cap,
> +int pnv_ocxl_set_tl_conf(struct pci_dev *dev, long cap,
> uint64_t rate_buf_phys, int rate_buf_size);
>
> -extern int pnv_ocxl_get_xsl_irq(struct pci_dev *dev, int *hwirq);
> -extern void pnv_ocxl_unmap_xsl_regs(void __iomem *dsisr, void __iomem *dar,
> - void __iomem *tfc, void __iomem *pe_handle);
> -extern int pnv_ocxl_map_xsl_regs(struct pci_dev *dev, void __iomem **dsisr,
> - void __iomem **dar, void __iomem **tfc,
> - void __iomem **pe_handle);
> +int pnv_ocxl_get_xsl_irq(struct pci_dev *dev, int *hwirq);
> +void pnv_ocxl_unmap_xsl_regs(void __iomem *dsisr, void __iomem *dar,
> + void __iomem *tfc, void __iomem *pe_handle);
> +int pnv_ocxl_map_xsl_regs(struct pci_dev *dev, void __iomem **dsisr,
> + void __iomem **dar, void __iomem **tfc,
> + void __iomem **pe_handle);
>
> -extern int pnv_ocxl_spa_setup(struct pci_dev *dev, void *spa_mem, int PE_mask,
> - void **platform_data);
> -extern void pnv_ocxl_spa_release(void *platform_data);
> -extern int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle);
> +int pnv_ocxl_spa_setup(struct pci_dev *dev, void *spa_mem, int PE_mask, void **platform_data);
> +void pnv_ocxl_spa_release(void *platform_data);
> +int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle);
>
> -extern int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr);
> -extern void pnv_ocxl_free_xive_irq(u32 irq);
> +int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr);
> +void pnv_ocxl_free_xive_irq(u32 irq);
> #ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
> u64 pnv_ocxl_platform_lpc_setup(struct pci_dev *pdev, u64 size);
> void pnv_ocxl_platform_lpc_release(struct pci_dev *pdev);
> diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
> index 06dd5839e438..0a762e387418 100644
> --- a/include/misc/ocxl.h
> +++ b/include/misc/ocxl.h
> @@ -173,7 +173,7 @@ int ocxl_context_detach(struct ocxl_context *ctx);
> *
> * Returns 0 on success, negative on failure
> */
> -extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
> +int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
>
> /**
> * Frees an IRQ associated with an AFU context
> @@ -182,7 +182,7 @@ extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
> *
> * Returns 0 on success, negative on failure
> */
> -extern int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);
> +int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);
>
> /**
> * Gets the address of the trigger page for an IRQ
> @@ -193,7 +193,7 @@ extern int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);
> *
> * returns the trigger page address, or 0 if the IRQ is not valid
> */
> -extern u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id);
> +u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id);
>
> /**
> * Provide a callback to be called when an IRQ is triggered
>

2020-02-26 08:16:36

by Baoquan He

[permalink] [raw]
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 protected]>
>
> Function declarations don't need externs, remove the existing ones
> so they are consistent with newer code
>
> Signed-off-by: Alastair D'Silva <[email protected]>
> ---
> 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

2020-02-26 08:34:24

by Alastair D'Silva

[permalink] [raw]
Subject: RE: [PATCH v3 04/27] ocxl: Remove unnecessary externs

> -----Original Message-----
> From: Baoquan He <[email protected]>
> Sent: Wednesday, 26 February 2020 7:15 PM
> To: Alastair D'Silva <[email protected]>
> Cc: [email protected]; Aneesh Kumar K . V
> <[email protected]>; Oliver O'Halloran <[email protected]>;
> Benjamin Herrenschmidt <[email protected]>; Paul Mackerras
> <[email protected]>; Michael Ellerman <[email protected]>; Frederic
> Barrat <[email protected]>; Andrew Donnellan <[email protected]>;
> Arnd Bergmann <[email protected]>; Greg Kroah-Hartman
> <[email protected]>; Dan Williams <[email protected]>;
> Vishal Verma <[email protected]>; Dave Jiang
> <[email protected]>; Ira Weiny <[email protected]>; Andrew Morton
> <[email protected]>; Mauro Carvalho Chehab
> <[email protected]>; David S. Miller <[email protected]>;
> Rob Herring <[email protected]>; Anton Blanchard <[email protected]>;
> Krzysztof Kozlowski <[email protected]>; Mahesh Salgaonkar
> <[email protected]>; Madhavan Srinivasan
> <[email protected]>; C?dric Le Goater <[email protected]>; Anju T
> Sudhakar <[email protected]>; Hari Bathini
> <[email protected]>; Thomas Gleixner <[email protected]>; Greg
> Kurz <[email protected]>; Nicholas Piggin <[email protected]>; Masahiro
> Yamada <[email protected]>; Alexey Kardashevskiy
> <[email protected]>; [email protected]; linuxppc-
> [email protected]; [email protected]; [email protected]
> 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 protected]>
> >
> > Function declarations don't need externs, remove the existing ones so
> > they are consistent with newer code
> >
> > Signed-off-by: Alastair D'Silva <[email protected]>
> > ---
> > 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.

--
Alastair D'Silva mob: 0423 762 819
skype: alastair_dsilva msn: [email protected]
blog: http://alastair.d-silva.org Twitter: @EvilDeece




2020-02-26 11:31:12

by Greg Kurz

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

On Wed, 26 Feb 2020 19:26:34 +1100
"Alastair D'Silva" <[email protected]> wrote:

> > -----Original Message-----
> > From: Baoquan He <[email protected]>
> > Sent: Wednesday, 26 February 2020 7:15 PM
> > To: Alastair D'Silva <[email protected]>
> > Cc: [email protected]; Aneesh Kumar K . V
> > <[email protected]>; Oliver O'Halloran <[email protected]>;
> > Benjamin Herrenschmidt <[email protected]>; Paul Mackerras
> > <[email protected]>; Michael Ellerman <[email protected]>; Frederic
> > Barrat <[email protected]>; Andrew Donnellan <[email protected]>;
> > Arnd Bergmann <[email protected]>; Greg Kroah-Hartman
> > <[email protected]>; Dan Williams <[email protected]>;
> > Vishal Verma <[email protected]>; Dave Jiang
> > <[email protected]>; Ira Weiny <[email protected]>; Andrew Morton
> > <[email protected]>; Mauro Carvalho Chehab
> > <[email protected]>; David S. Miller <[email protected]>;
> > Rob Herring <[email protected]>; Anton Blanchard <[email protected]>;
> > Krzysztof Kozlowski <[email protected]>; Mahesh Salgaonkar
> > <[email protected]>; Madhavan Srinivasan
> > <[email protected]>; Cédric Le Goater <[email protected]>; Anju T
> > Sudhakar <[email protected]>; Hari Bathini
> > <[email protected]>; Thomas Gleixner <[email protected]>; Greg
> > Kurz <[email protected]>; Nicholas Piggin <[email protected]>; Masahiro
> > Yamada <[email protected]>; Alexey Kardashevskiy
> > <[email protected]>; [email protected]; linuxppc-
> > [email protected]; [email protected]; [email protected]
> > 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 protected]>
> > >
> > > Function declarations don't need externs, remove the existing ones so
> > > they are consistent with newer code
> > >
> > > Signed-off-by: Alastair D'Silva <[email protected]>
> > > ---
> > > 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

[...]

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);

[...]

2020-02-26 14:17:08

by Baoquan He

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

On 02/26/20 at 10:01am, Greg Kurz wrote:
> On Wed, 26 Feb 2020 19:26:34 +1100
> "Alastair D'Silva" <[email protected]> wrote:
>
> > > -----Original Message-----
> > > From: Baoquan He <[email protected]>
> > > Sent: Wednesday, 26 February 2020 7:15 PM
> > > To: Alastair D'Silva <[email protected]>
> > > Cc: [email protected]; Aneesh Kumar K . V
> > > <[email protected]>; Oliver O'Halloran <[email protected]>;
> > > Benjamin Herrenschmidt <[email protected]>; Paul Mackerras
> > > <[email protected]>; Michael Ellerman <[email protected]>; Frederic
> > > Barrat <[email protected]>; Andrew Donnellan <[email protected]>;
> > > Arnd Bergmann <[email protected]>; Greg Kroah-Hartman
> > > <[email protected]>; Dan Williams <[email protected]>;
> > > Vishal Verma <[email protected]>; Dave Jiang
> > > <[email protected]>; Ira Weiny <[email protected]>; Andrew Morton
> > > <[email protected]>; Mauro Carvalho Chehab
> > > <[email protected]>; David S. Miller <[email protected]>;
> > > Rob Herring <[email protected]>; Anton Blanchard <[email protected]>;
> > > Krzysztof Kozlowski <[email protected]>; Mahesh Salgaonkar
> > > <[email protected]>; Madhavan Srinivasan
> > > <[email protected]>; C?dric Le Goater <[email protected]>; Anju T
> > > Sudhakar <[email protected]>; Hari Bathini
> > > <[email protected]>; Thomas Gleixner <[email protected]>; Greg
> > > Kurz <[email protected]>; Nicholas Piggin <[email protected]>; Masahiro
> > > Yamada <[email protected]>; Alexey Kardashevskiy
> > > <[email protected]>; [email protected]; linuxppc-
> > > [email protected]; [email protected]; [email protected]
> > > 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 protected]>
> > > >
> > > > Function declarations don't need externs, remove the existing ones so
> > > > they are consistent with newer code
> > > >
> > > > Signed-off-by: Alastair D'Silva <[email protected]>
> > > > ---
> > > > 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
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);
>
> [...]
>

2020-02-26 14:55:32

by Baoquan He

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

On 02/26/20 at 03:20pm, Greg Kurz wrote:
> On Wed, 26 Feb 2020 22:15:23 +0800
> 'Baoquan He' <[email protected]> wrote:
>
> > On 02/26/20 at 10:01am, Greg Kurz wrote:
> > > On Wed, 26 Feb 2020 19:26:34 +1100
> > > "Alastair D'Silva" <[email protected]> wrote:
> > >
> > > > > -----Original Message-----
> > > > > From: Baoquan He <[email protected]>
> > > > > Sent: Wednesday, 26 February 2020 7:15 PM
> > > > > To: Alastair D'Silva <[email protected]>
> > > > > Cc: [email protected]; Aneesh Kumar K . V
> > > > > <[email protected]>; Oliver O'Halloran <[email protected]>;
> > > > > Benjamin Herrenschmidt <[email protected]>; Paul Mackerras
> > > > > <[email protected]>; Michael Ellerman <[email protected]>; Frederic
> > > > > Barrat <[email protected]>; Andrew Donnellan <[email protected]>;
> > > > > Arnd Bergmann <[email protected]>; Greg Kroah-Hartman
> > > > > <[email protected]>; Dan Williams <[email protected]>;
> > > > > Vishal Verma <[email protected]>; Dave Jiang
> > > > > <[email protected]>; Ira Weiny <[email protected]>; Andrew Morton
> > > > > <[email protected]>; Mauro Carvalho Chehab
> > > > > <[email protected]>; David S. Miller <[email protected]>;
> > > > > Rob Herring <[email protected]>; Anton Blanchard <[email protected]>;
> > > > > Krzysztof Kozlowski <[email protected]>; Mahesh Salgaonkar
> > > > > <[email protected]>; Madhavan Srinivasan
> > > > > <[email protected]>; C?dric Le Goater <[email protected]>; Anju T
> > > > > Sudhakar <[email protected]>; Hari Bathini
> > > > > <[email protected]>; Thomas Gleixner <[email protected]>; Greg
> > > > > Kurz <[email protected]>; Nicholas Piggin <[email protected]>; Masahiro
> > > > > Yamada <[email protected]>; Alexey Kardashevskiy
> > > > > <[email protected]>; [email protected]; linuxppc-
> > > > > [email protected]; [email protected]; [email protected]
> > > > > 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 protected]>
> > > > > >
> > > > > > Function declarations don't need externs, remove the existing ones so
> > > > > > they are consistent with newer code
> > > > > >
> > > > > > Signed-off-by: Alastair D'Silva <[email protected]>
> > > > > > ---
> > > > > > 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);
> > >
> > > [...]
> > >
> >
>
>

2020-02-26 17:57:19

by Greg Kurz

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

On Wed, 26 Feb 2020 22:15:23 +0800
'Baoquan He' <[email protected]> wrote:

> On 02/26/20 at 10:01am, Greg Kurz wrote:
> > On Wed, 26 Feb 2020 19:26:34 +1100
> > "Alastair D'Silva" <[email protected]> wrote:
> >
> > > > -----Original Message-----
> > > > From: Baoquan He <[email protected]>
> > > > Sent: Wednesday, 26 February 2020 7:15 PM
> > > > To: Alastair D'Silva <[email protected]>
> > > > Cc: [email protected]; Aneesh Kumar K . V
> > > > <[email protected]>; Oliver O'Halloran <[email protected]>;
> > > > Benjamin Herrenschmidt <[email protected]>; Paul Mackerras
> > > > <[email protected]>; Michael Ellerman <[email protected]>; Frederic
> > > > Barrat <[email protected]>; Andrew Donnellan <[email protected]>;
> > > > Arnd Bergmann <[email protected]>; Greg Kroah-Hartman
> > > > <[email protected]>; Dan Williams <[email protected]>;
> > > > Vishal Verma <[email protected]>; Dave Jiang
> > > > <[email protected]>; Ira Weiny <[email protected]>; Andrew Morton
> > > > <[email protected]>; Mauro Carvalho Chehab
> > > > <[email protected]>; David S. Miller <[email protected]>;
> > > > Rob Herring <[email protected]>; Anton Blanchard <[email protected]>;
> > > > Krzysztof Kozlowski <[email protected]>; Mahesh Salgaonkar
> > > > <[email protected]>; Madhavan Srinivasan
> > > > <[email protected]>; Cédric Le Goater <[email protected]>; Anju T
> > > > Sudhakar <[email protected]>; Hari Bathini
> > > > <[email protected]>; Thomas Gleixner <[email protected]>; Greg
> > > > Kurz <[email protected]>; Nicholas Piggin <[email protected]>; Masahiro
> > > > Yamada <[email protected]>; Alexey Kardashevskiy
> > > > <[email protected]>; [email protected]; linuxppc-
> > > > [email protected]; [email protected]; [email protected]
> > > > 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 protected]>
> > > > >
> > > > > Function declarations don't need externs, remove the existing ones so
> > > > > they are consistent with newer code
> > > > >
> > > > > Signed-off-by: Alastair D'Silva <[email protected]>
> > > > > ---
> > > > > 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 ?

> 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);
> >
> > [...]
> >
>