lkml.org 
[lkml]   [2022]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 4/9] pwm: lpss: Include headers we are direct user of
On Sat, Sep 24, 2022 at 12:04:53PM +0200, Uwe Kleine-König wrote:
> On Thu, Sep 08, 2022 at 04:56:53PM +0300, Andy Shevchenko wrote:
> > For the sake of integrity, include headers we are direct user of.
> >
> > While at it, replace device.h with a forward declaration and add
> > missed struct pwm_lpss_boardinfo one.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> > drivers/pwm/pwm-lpss.h | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h
> > index c344921b2cab..839622964b2a 100644
> > --- a/drivers/pwm/pwm-lpss.h
> > +++ b/drivers/pwm/pwm-lpss.h
> > @@ -10,11 +10,15 @@
> > #ifndef __PWM_LPSS_H
> > #define __PWM_LPSS_H
> >
> > -#include <linux/device.h>
> > #include <linux/pwm.h>
> > +#include <linux/types.h>
> >
> > #define MAX_PWMS 4
> >
> > +struct device;
>
> It's not clear to me how this is an improvment. Isn't it saner to
> include <linux/device.h>?

The compilation time improvement. You don't need to include entire
train of unrelated stuff when compile something.

Moreover, the rule of thumb for the headers is avoid as much as possible
unrelated inclusions not only due to compilation time rising, but also
due to potential circular dependencies and increasing dependency hell
of headers. Believe me, we suffer a lot in the kernel due to this
(I have an example). Also you may check the Ingo's work of improving
headers breakage (APIs vs. implementation vs. data types, etc) to see
the achievement(s).

> > +struct pwm_lpss_boardinfo;
>
> Why is this necessary? The struct is defined a few lines below the
> context of this patch and I see no user that would benefit.

This is clean way of how we program in C. We should forward declare
the types _before_ using them. Since this is a pointer, forward
declaration is enough.

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2022-09-26 11:49    [W:0.076 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site