Message ID | 20220908135658.64463-3-andriy.shevchenko@linux.intel.com |
---|---|
State | Changes Requested |
Headers | show |
Series | pwm: lpss: Clean up and convert to a pure library | expand |
Hello, On Thu, Sep 08, 2022 at 04:56:51PM +0300, Andy Shevchenko wrote: > Avoid unnecessary pollution of the global symbol namespace by > moving library functions in to a specific namespace and import > that into the drivers that make use of the functions. > > For more info: https://lwn.net/Articles/760045/ > > Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/pwm/pwm-lpss-pci.c | 1 + > drivers/pwm/pwm-lpss-platform.c | 1 + > drivers/pwm/pwm-lpss.c | 2 ++ > 3 files changed, 4 insertions(+) > > diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c > index 75b778e839b3..9f2c666b95ec 100644 > --- a/drivers/pwm/pwm-lpss-pci.c > +++ b/drivers/pwm/pwm-lpss-pci.c > @@ -92,3 +92,4 @@ module_pci_driver(pwm_lpss_driver_pci); > > MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS"); > MODULE_LICENSE("GPL v2"); > +MODULE_IMPORT_NS(PWM_LPSS); Each user of the lpss.h header needs that, right? Then the MODULE_IMPORT_NS statement can go into the header, too. Even without this change: Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Thanks Uwe
On Sat, Sep 24, 2022 at 11:59:45AM +0200, Uwe Kleine-König wrote: > Hello, > > On Thu, Sep 08, 2022 at 04:56:51PM +0300, Andy Shevchenko wrote: > > Avoid unnecessary pollution of the global symbol namespace by > > moving library functions in to a specific namespace and import > > that into the drivers that make use of the functions. > > > > For more info: https://lwn.net/Articles/760045/ > > > > Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > --- > > drivers/pwm/pwm-lpss-pci.c | 1 + > > drivers/pwm/pwm-lpss-platform.c | 1 + > > drivers/pwm/pwm-lpss.c | 2 ++ > > 3 files changed, 4 insertions(+) > > > > diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c > > index 75b778e839b3..9f2c666b95ec 100644 > > --- a/drivers/pwm/pwm-lpss-pci.c > > +++ b/drivers/pwm/pwm-lpss-pci.c > > @@ -92,3 +92,4 @@ module_pci_driver(pwm_lpss_driver_pci); > > > > MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS"); > > MODULE_LICENSE("GPL v2"); > > +MODULE_IMPORT_NS(PWM_LPSS); > > Each user of the lpss.h header needs that, right? Then the > MODULE_IMPORT_NS statement can go into the header, too. With the same answer as for v1: any user that might include the header for the sake of data types will get the NS inclusion even if they don't need that (yes, I don't think it's practical, but slightly better to make sure that if one uses an API, one adds necessary NS inclusions; also note that in case of stale header inclusion this again might bring unnecessary NS, while the header should be removed -- with that being said, I think we might need some kind of extended includecheck to see if the APIs and data structures are actually used when a certain header is included). > Even without this change: > > Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Thanks!
On Mon, Sep 26, 2022 at 12:43:47PM +0300, Andy Shevchenko wrote: > On Sat, Sep 24, 2022 at 11:59:45AM +0200, Uwe Kleine-König wrote: > > Hello, > > > > On Thu, Sep 08, 2022 at 04:56:51PM +0300, Andy Shevchenko wrote: > > > Avoid unnecessary pollution of the global symbol namespace by > > > moving library functions in to a specific namespace and import > > > that into the drivers that make use of the functions. > > > > > > For more info: https://lwn.net/Articles/760045/ > > > > > > Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > > --- > > > drivers/pwm/pwm-lpss-pci.c | 1 + > > > drivers/pwm/pwm-lpss-platform.c | 1 + > > > drivers/pwm/pwm-lpss.c | 2 ++ > > > 3 files changed, 4 insertions(+) > > > > > > diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c > > > index 75b778e839b3..9f2c666b95ec 100644 > > > --- a/drivers/pwm/pwm-lpss-pci.c > > > +++ b/drivers/pwm/pwm-lpss-pci.c > > > @@ -92,3 +92,4 @@ module_pci_driver(pwm_lpss_driver_pci); > > > > > > MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS"); > > > MODULE_LICENSE("GPL v2"); > > > +MODULE_IMPORT_NS(PWM_LPSS); > > > > Each user of the lpss.h header needs that, right? Then the > > MODULE_IMPORT_NS statement can go into the header, too. > > With the same answer as for v1: any user that might include the header for > the sake of data types will get the NS inclusion even if they don't need > that (yes, I don't think it's practical, but slightly better to make sure I'm not sure I understand you correctly here. For some headers you cannot assume that a file including the header also needs the namespace macro, but for pwm-lpss.h that should be a safe assumption. > that if one uses an API, one adds necessary NS inclusions; also note that > in case of stale header inclusion this again might bring unnecessary NS, > while the header should be removed -- with that being said, I think we > might need some kind of extended includecheck to see if the APIs and data > structures are actually used when a certain header is included). +1 for a check about unused headers. Best regards Uwe
On Mon, Sep 26, 2022 at 11:55:47AM +0200, Uwe Kleine-König wrote: > On Mon, Sep 26, 2022 at 12:43:47PM +0300, Andy Shevchenko wrote: > > On Sat, Sep 24, 2022 at 11:59:45AM +0200, Uwe Kleine-König wrote: > > > On Thu, Sep 08, 2022 at 04:56:51PM +0300, Andy Shevchenko wrote: ... > > > > +MODULE_IMPORT_NS(PWM_LPSS); > > > > > > Each user of the lpss.h header needs that, right? Then the > > > MODULE_IMPORT_NS statement can go into the header, too. > > > > With the same answer as for v1: any user that might include the header for > > the sake of data types will get the NS inclusion even if they don't need > > that (yes, I don't think it's practical, but slightly better to make sure > > I'm not sure I understand you correctly here. For some headers you > cannot assume that a file including the header also needs the namespace > macro, but for pwm-lpss.h that should be a safe assumption. Yes, it's a safe assumption for _this_ case (as I pointed out above that there is probably no practical to assume otherwise), in general it may be not the case.
diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c index 75b778e839b3..9f2c666b95ec 100644 --- a/drivers/pwm/pwm-lpss-pci.c +++ b/drivers/pwm/pwm-lpss-pci.c @@ -92,3 +92,4 @@ module_pci_driver(pwm_lpss_driver_pci); MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(PWM_LPSS); diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c index 834423c34f48..65154c0abab1 100644 --- a/drivers/pwm/pwm-lpss-platform.c +++ b/drivers/pwm/pwm-lpss-platform.c @@ -88,4 +88,5 @@ module_platform_driver(pwm_lpss_driver_platform); MODULE_DESCRIPTION("PWM platform driver for Intel LPSS"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(PWM_LPSS); MODULE_ALIAS("platform:pwm-lpss"); diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c index 9537aefd254a..74a296cb1af0 100644 --- a/drivers/pwm/pwm-lpss.c +++ b/drivers/pwm/pwm-lpss.c @@ -18,6 +18,8 @@ #include <linux/pm_runtime.h> #include <linux/time.h> +#define DEFAULT_SYMBOL_NAMESPACE PWM_LPSS + #include "pwm-lpss.h" #define PWM 0x00000000
Avoid unnecessary pollution of the global symbol namespace by moving library functions in to a specific namespace and import that into the drivers that make use of the functions. For more info: https://lwn.net/Articles/760045/ Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/pwm/pwm-lpss-pci.c | 1 + drivers/pwm/pwm-lpss-platform.c | 1 + drivers/pwm/pwm-lpss.c | 2 ++ 3 files changed, 4 insertions(+)