mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: quic_zijuhu <quic_zijuhu@quicinc.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 1/5] driver core: Sort headers
Date: Thu, 22 Aug 2024 11:30:07 +0800	[thread overview]
Message-ID: <36bc2da3-80c2-467d-bcdd-0797809ace72@quicinc.com> (raw)
In-Reply-To: <20240821154839.604259-2-andriy.shevchenko@linux.intel.com>

On 8/21/2024 11:48 PM, Andy Shevchenko wrote:
> Sort the headers in alphabetic order in order to ease
> the maintenance for this part.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/base/core.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 144cb8c201fb..6b9d3d255135 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -9,29 +9,29 @@
>   */
>  
>  #include <linux/acpi.h>
> +#include <linux/blkdev.h>
>  #include <linux/cpufreq.h>
>  #include <linux/device.h>
> +#include <linux/dma-map-ops.h> /* for dma_default_coherent */
>  #include <linux/err.h>
>  #include <linux/fwnode.h>
>  #include <linux/init.h>
> +#include <linux/kdev_t.h>
>  #include <linux/kstrtox.h>
>  #include <linux/module.h>
> -#include <linux/slab.h>
> -#include <linux/kdev_t.h>
> +#include <linux/mutex.h>
> +#include <linux/netdevice.h>
>  #include <linux/notifier.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> -#include <linux/blkdev.h>
> -#include <linux/mutex.h>
>  #include <linux/pm_runtime.h>
> -#include <linux/netdevice.h>
>  #include <linux/rcupdate.h>
> -#include <linux/sched/signal.h>
>  #include <linux/sched/mm.h>
> +#include <linux/sched/signal.h>
> +#include <linux/slab.h>
>  #include <linux/string_helpers.h>
>  #include <linux/swiotlb.h>
>  #include <linux/sysfs.h>
> -#include <linux/dma-map-ops.h> /* for dma_default_coherent */
>  
>  #include "base.h"
>  #include "physical_location.h"

Hi Andy,

i don't think it is good idea to sort headers by alphabetic order.

why ?

1) header's dependency is not related to its file (name|path), their
dependency are related to # includes order.

2) it maybe be easy to cause build error.

3) header's path or name maybe be related to subsystem, it is not good
to sort one subsystem's headers before the other.


For header's order, my points is that:

1) sort by their dependency.
   #include <b_header.h>
   #include <a_header.h>
   if
   a_header.h:
   #include <b_header.h>

2) all #include <> block before all #include "" block.

3) sort headers related to source file at the last.

   prefix_xyz.c:

   #include <>
   .....
   #include <prefix_xyz.h>   // it is the last if it is exposed.

   #include "internal_header.h"
   ....

4)
sort relevant header together as far as possible, for example, they
belong to the same subsystem.





  reply	other threads:[~2024-08-22  3:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-21 15:48 [PATCH v1 0/5] driver core: fw_devlink: Clean up strings and mutex usages Andy Shevchenko
2024-08-21 15:48 ` [PATCH v1 1/5] driver core: Sort headers Andy Shevchenko
2024-08-22  3:30   ` quic_zijuhu [this message]
2024-08-22 11:50     ` Andy Shevchenko
2024-08-21 15:48 ` [PATCH v1 2/5] driver core: Use kasprintf() instead of fixed buffer formatting Andy Shevchenko
2024-08-21 15:48 ` [PATCH v1 3/5] driver core: Use guards for simple mutex locks Andy Shevchenko
2024-08-21 15:48 ` [PATCH v1 4/5] driver core: Make use of returned value of dev_err_probe() Andy Shevchenko
2024-08-21 15:48 ` [PATCH v1 5/5] driver core: Use 2-argument strscpy() Andy Shevchenko
2024-08-22  7:39 ` [PATCH v1 0/5] driver core: fw_devlink: Clean up strings and mutex usages Greg Kroah-Hartman

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=36bc2da3-80c2-467d-bcdd-0797809ace72@quicinc.com \
    --to=quic_zijuhu@quicinc.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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

all inboxes | Powered by JetHome®