[PATCH v2 2/5] ata: libata-transport: inline ata_attach|release_transport

Heiner Kallweit
2026-04-02T13:30:09Z

Both functions are helpers which are used only once. So remove them and
merge their code into libata_transport_init() and libata_transport_exit()
respectively.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/ata/libata-core.c | 2 --
drivers/ata/libata-transport.c | 34 +++++++++++-----------------------
drivers/ata/libata-transport.h | 3 ---
3 files changed, 11 insertions(+), 28 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index ae56567af..e76d15411 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -6778,7 +6778,6 @@ static int __init ata_init(void)
}

libata_transport_init();
- ata_scsi_transport_template = ata_attach_transport();

printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");

@@ -6787,7 +6786,6 @@ static int __init ata_init(void)

static void __exit ata_exit(void)
{
- ata_release_transport();
libata_transport_exit();
ata_sff_exit();
ata_free_force_param();
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
index 0c7ce278e..9d594562c 100644
--- a/drivers/ata/libata-transport.c
+++ b/drivers/ata/libata-transport.c
@@ -766,29 +766,6 @@ static struct ata_internal ata_transport_internal = {
* Setup / Teardown code
*/

-/**
- * ata_attach_transport -- instantiate ATA transport template
- */
-struct scsi_transport_template *ata_attach_transport(void)
-{
- transport_container_register(&ata_transport_internal.t.host_attrs);
- transport_container_register(&ata_transport_internal.link_attr_cont);
- transport_container_register(&ata_transport_internal.dev_attr_cont);
-
- return &ata_transport_internal.t;
-}
-
-/**
- * ata_release_transport -- release ATA transport template instance
- * @t: transport template instance
- */
-void ata_release_transport(void)
-{
- transport_container_unregister(&ata_transport_internal.t.host_attrs);
- transport_container_unregister(&ata_transport_internal.link_attr_cont);
- transport_container_unregister(&ata_transport_internal.dev_attr_cont);
-}
-
__init int libata_transport_init(void)
{
int error;
@@ -802,6 +779,13 @@ __init int libata_transport_init(void)
error = transport_class_register(&ata_dev_class);
if (error)
goto out_unregister_port;
+
+ transport_container_register(&ata_transport_internal.t.host_attrs);
+ transport_container_register(&ata_transport_internal.link_attr_cont);
+ transport_container_register(&ata_transport_internal.dev_attr_cont);
+
+ ata_scsi_transport_template = &ata_transport_internal.t;
+
return 0;

out_unregister_port:
@@ -815,6 +799,10 @@ __init int libata_transport_init(void)

void __exit libata_transport_exit(void)
{
+ transport_container_unregister(&ata_transport_internal.t.host_attrs);
+ transport_container_unregister(&ata_transport_internal.link_attr_cont);
+ transport_container_unregister(&ata_transport_internal.dev_attr_cont);
+
transport_class_unregister(&ata_link_class);
transport_class_unregister(&ata_port_class);
transport_class_unregister(&ata_dev_class);
diff --git a/drivers/ata/libata-transport.h b/drivers/ata/libata-transport.h
index a464b8fcd..fe5ca66fc 100644
--- a/drivers/ata/libata-transport.h
+++ b/drivers/ata/libata-transport.h
@@ -8,9 +8,6 @@ extern struct scsi_transport_template *ata_scsi_transport_template;
int ata_tlink_add(struct ata_link *link);
void ata_tlink_delete(struct ata_link *link);

-struct scsi_transport_template *ata_attach_transport(void);
-void ata_release_transport(void);
-
__init int libata_transport_init(void);
void __exit libata_transport_exit(void);
#endif
--
2.53.0