public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org,
	Thierry Reding <thierry.reding@gmail.com>
Subject: Re: [PATCH v2 4/9] pwm: lpss: Include headers we are direct user of
Date: Mon, 26 Sep 2022 12:48:06 +0300	[thread overview]
Message-ID: <YzF1VmChe+MyXxJF@smile.fi.intel.com> (raw)
In-Reply-To: <20220924100453.hupbeotwqrehc4yq@pengutronix.de>

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



  reply	other threads:[~2022-09-26  9:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 13:56 [PATCH v2 0/9] pwm: lpss: Clean up and convert to a pure library Andy Shevchenko
2022-09-08 13:56 ` [PATCH v2 1/9] pwm: lpss: Deduplicate board info data structures Andy Shevchenko
2022-09-08 13:56 ` [PATCH v2 2/9] pwm: lpss: Move exported symbols to PWM_LPSS namespace Andy Shevchenko
2022-09-24  9:59   ` Uwe Kleine-König
2022-09-26  9:43     ` Andy Shevchenko
2022-09-26  9:55       ` Uwe Kleine-König
2022-09-26 10:10         ` Andy Shevchenko
2022-09-08 13:56 ` [PATCH v2 3/9] pwm: lpss: Move resource mapping to the glue drivers Andy Shevchenko
2022-09-24 10:01   ` Uwe Kleine-König
2022-09-08 13:56 ` [PATCH v2 4/9] pwm: lpss: Include headers we are direct user of Andy Shevchenko
2022-09-24 10:04   ` Uwe Kleine-König
2022-09-26  9:48     ` Andy Shevchenko [this message]
2022-09-08 13:56 ` [PATCH v2 5/9] pwm: lpss: Use device_get_match_data to get device data Andy Shevchenko
2022-09-24 10:05   ` Uwe Kleine-König
2022-09-08 13:56 ` [PATCH v2 6/9] pwm: lpss: Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() macros Andy Shevchenko
2022-09-24 10:07   ` Uwe Kleine-König
2022-09-26  9:51     ` Andy Shevchenko
2022-09-08 13:56 ` [PATCH v2 7/9] pwm: lpss: Make use of bits.h macros for all masks Andy Shevchenko
2022-09-24 10:07   ` Uwe Kleine-König
2022-09-08 13:56 ` [PATCH v2 8/9] pwm: lpss: Add a comment to the bypass field Andy Shevchenko
2022-09-24 10:09   ` Uwe Kleine-König
2022-09-08 13:56 ` [PATCH v2 9/9] pwm: lpss: Allow other drivers to enable PWM LPSS Andy Shevchenko
2022-09-24 10:14   ` Uwe Kleine-König
2022-09-26  9:54     ` Andy Shevchenko
2022-09-23 17:03 ` [PATCH v2 0/9] pwm: lpss: Clean up and convert to a pure library Andy Shevchenko
2022-09-24  7:29   ` Uwe Kleine-König
2022-09-27 14:13 ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YzF1VmChe+MyXxJF@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox