[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YzF1VmChe+MyXxJF@smile.fi.intel.com>
Date: Mon, 26 Sep 2022 12:48:06 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
Cc: linux-kernel@...r.kernel.org, linux-pwm@...r.kernel.org,
Thierry Reding <thierry.reding@...il.com>
Subject: Re: [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@...ux.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
Powered by blists - more mailing lists