Re: [PATCH v2 03/10] usb: cdns3: Moves reusable code to separate module

From: gregkh@xxxxxxxxxxxxxxxxxxx
Date: Tue Nov 10 2020 - 06:38:47 EST


On Tue, Nov 10, 2020 at 11:21:22AM +0000, Peter Chen wrote:
> On 20-11-10 09:20:54, Pawel Laszczak wrote:
> > Hi,
> >
> > >>
> > >> int cdns3_hw_role_switch(struct cdns3 *cdns);
> > >> -int cdns3_init(struct cdns3 *cdns);
> > >> -int cdns3_remove(struct cdns3 *cdns);
> > >> +extern int cdns3_init(struct cdns3 *cdns);
> > >> +extern int cdns3_remove(struct cdns3 *cdns);
> > >
> > >Why add "extern" here and below?
> > >
> >
> > These functions are the API between cdnsp and cdns3 modules.
> > It's looks like a common approach in kernel.
> > Many or even most of API function in kernel has "extern".
> >
>
> Even you have not written "extern" keyword, the "extern" is
> added implicitly by compiler. Usually, we use "extern" for variable
> or the function is defined at assembly. You could see some
> "extern" keyword use cases at include/linux/device.h.

We are moving away from using this keyword for functions now, if at all
possible please. Only use it for variables, I think checkpatch now
catches it as well.

thanks,

greg k-h