Skip to contentSkip to conversation

ata: libata: Move inclusion to where it belongs

PATCH In review Andy Shevchenko 2 participants 3 messages Apr 4, 2024 – Apr 5, 2024 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: libata: Move inclusion to where it belongs

Replace rather heavy acpi.h inclusion by a simple forward declaration in the public header. Update the local one to include acpi.h as some of the code requires it.

---
 drivers/ata/libata.h   | 3 +++
 include/linux/libata.h | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/ata/libata.h +3 -0
index 5c685bb1939e..29e9387eb249 100644
@@ -90,6 +90,9 @@ extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
 #define to_ata_port(d) container_of(d, struct ata_port, tdev)
 
 /* libata-acpi.c */
+
+#include <linux/acpi.h>
+
 #ifdef CONFIG_ATA_ACPI
 extern unsigned int ata_acpi_gtf_filter;
 extern void ata_acpi_dissociate(struct ata_host *host);
include/linux/libata.h +4 -1
index 66937b787cca..68b969de410f 100644
@@ -19,7 +19,6 @@
 #include <linux/ata.h>
 #include <linux/workqueue.h>
 #include <scsi/scsi_host.h>
-#include <linux/acpi.h>
 #include <linux/cdrom.h>
 #include <linux/sched.h>
 #include <linux/async.h>
@@ -660,6 +659,10 @@ struct ata_cpr_log {
 	struct ata_cpr		cpr[] __counted_by(nr_cpr);
 };
 
+#ifdef CONFIG_ATA_ACPI
+union acpi_object;
+#endif
+
 struct ata_device {
 	struct ata_link		*link;
 	unsigned int		devno;		/* 0 or 1 */
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
maintainer
#1 lore raw
Quoted 15 lines · Andy Shevchenko

Replace rather heavy acpi.h inclusion by a simple forward declaration in the public header. Update the local one to include acpi.h as some of the code requires it.

---
 drivers/ata/libata.h   | 3 +++
 include/linux/libata.h | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/ata/libata.h +0 -0
index 5c685bb1939e..29e9387eb249 100644

drivers/ata/libata.h extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log, · line 94

Quoted 5 lines
drivers/ata/libata.h +2 -0
@@ -90,6 +90,9 @@ extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
 #define to_ata_port(d) container_of(d, struct ata_port, tdev)
 
 /* libata-acpi.c */
+
+#include <linux/acpi.h>

I am really not a big fan of including files in the middle of a header file.

include/linux/libata.h line 22

Quoted 13 lines
drivers/ata/libata.h +1 -0
+
 #ifdef CONFIG_ATA_ACPI
 extern unsigned int ata_acpi_gtf_filter;
 extern void ata_acpi_dissociate(struct ata_host *host);
include/linux/libata.h +0 -1
index 66937b787cca..68b969de410f 100644
@@ -19,7 +19,6 @@
 #include <linux/ata.h>
 #include <linux/workqueue.h>
 #include <scsi/scsi_host.h>
-#include <linux/acpi.h>

Why not:

#ifdef CONFIG_ATA_ACPI
#include <linux/acpi.h>
#endif

Which avoids the union forward declaration below.

Quoted 14 lines
include/linux/libata.h +4 -0
 #include <linux/cdrom.h>
 #include <linux/sched.h>
 #include <linux/async.h>
@@ -660,6 +659,10 @@ struct ata_cpr_log {
 	struct ata_cpr		cpr[] __counted_by(nr_cpr);
 };
 
+#ifdef CONFIG_ATA_ACPI
+union acpi_object;
+#endif
+
 struct ata_device {
 	struct ata_link		*link;
 	unsigned int		devno;		/* 0 or 1 */
Signature · 2 lines
Damien Le Moal
Western Digital Research
#2 lore raw
Quoted 1 line · Damien Le Moal

On 4/5/24 04:21, Andy Shevchenko wrote:

...

Quoted 5 lines

drivers/ata/libata.h extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log, · line 94

Quoted 3 lines

/* libata-acpi.c */

drivers/ata/libata.h +2 -0
+
+#include <linux/acpi.h>

I am really not a big fan of including files in the middle of a header file.

I'm fine to place it at the top.

...

Quoted 9 lines
Quoted 1 line

-#include <linux/acpi.h>

Why not:

#ifdef CONFIG_ATA_ACPI
#include <linux/acpi.h>
#endif

Which avoids the union forward declaration below.

The point is to reduce dependency hell. The header does NOT dependent on ACPI guts, that's why I really prefer forward declaration over including a monstrous acpi.h.

Signature · 2 lines
With Best Regards,
Andy Shevchenko