public inbox for linux-modules@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Gomez <da.gomez@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 "Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	 "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	 "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
	Petr Pavlu <petr.pavlu@suse.com>,
	 Daniel Gomez <da.gomez@kernel.org>,
	Sami Tolvanen <samitolvanen@google.com>,
	 Aaron Tomlin <atomlin@atomlin.com>,
	Lucas De Marchi <demarchi@kernel.org>,
	 linux-scsi@vger.kernel.org, linux-modules@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Daniel Gomez <da.gomez@samsung.com>
Subject: [PATCH] driver core: attribute_container: change return type to void
Date: Sat, 20 Dec 2025 04:45:34 +0100	[thread overview]
Message-ID: <20251220-dev-attribute-container-linux-scsi-v1-1-d58fcd03bf21@samsung.com> (raw)

From: Daniel Gomez <da.gomez@samsung.com>

attribute_container_register() has always returned 0 since its
introduction in commit 06ff5a987e ("Add attribute container to generic
device model") in the historical Linux tree [1]. Convert the return type
to void and update all callers.

This removes dead code where callers checked for errors that could never
occur.

Link: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git [1]

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
Cleanup. Found while reviewing module_init() return values for the
-EEXIST issue [1] on the scsi spi transport module.

Link: https://lore.kernel.org/linux-modules/20251220-dev-module-init-eexists-linux-scsi-v1-0-5379db749d54@samsung.com/T/#t [1]
---
 drivers/base/attribute_container.c  | 4 +---
 drivers/base/transport_class.c      | 8 ++------
 drivers/scsi/scsi_transport_spi.c   | 2 +-
 include/linux/attribute_container.h | 2 +-
 include/linux/transport_class.h     | 6 +++---
 5 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
index b6f941a6ab69..72adbacc6554 100644
--- a/drivers/base/attribute_container.c
+++ b/drivers/base/attribute_container.c
@@ -69,7 +69,7 @@ static DEFINE_MUTEX(attribute_container_mutex);
  * @cont: The container to register.  This must be allocated by the
  *        callee and should also be zeroed by it.
  */
-int
+void
 attribute_container_register(struct attribute_container *cont)
 {
 	INIT_LIST_HEAD(&cont->node);
@@ -79,8 +79,6 @@ attribute_container_register(struct attribute_container *cont)
 	mutex_lock(&attribute_container_mutex);
 	list_add_tail(&cont->node, &attribute_container_list);
 	mutex_unlock(&attribute_container_mutex);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(attribute_container_register);
 
diff --git a/drivers/base/transport_class.c b/drivers/base/transport_class.c
index 09ee2a1e35bb..4b1e8820e764 100644
--- a/drivers/base/transport_class.c
+++ b/drivers/base/transport_class.c
@@ -88,17 +88,13 @@ static int anon_transport_dummy_function(struct transport_container *tc,
  * events.  Use prezero and then use DECLARE_ANON_TRANSPORT_CLASS() to
  * initialise the anon transport class storage.
  */
-int anon_transport_class_register(struct anon_transport_class *atc)
+void anon_transport_class_register(struct anon_transport_class *atc)
 {
-	int error;
 	atc->container.class = &atc->tclass.class;
 	attribute_container_set_no_classdevs(&atc->container);
-	error = attribute_container_register(&atc->container);
-	if (error)
-		return error;
+	attribute_container_register(&atc->container);
 	atc->tclass.setup = anon_transport_dummy_function;
 	atc->tclass.remove = anon_transport_dummy_function;
-	return 0;
 }
 EXPORT_SYMBOL_GPL(anon_transport_class_register);
 
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index fe47850a8258..17a4a0918fc4 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -1622,7 +1622,7 @@ static __init int spi_transport_init(void)
 	error = transport_class_register(&spi_transport_class);
 	if (error)
 		return error;
-	error = anon_transport_class_register(&spi_device_class);
+	anon_transport_class_register(&spi_device_class);
 	return transport_class_register(&spi_host_class);
 }
 
diff --git a/include/linux/attribute_container.h b/include/linux/attribute_container.h
index b3643de9931d..fa6520e192be 100644
--- a/include/linux/attribute_container.h
+++ b/include/linux/attribute_container.h
@@ -36,7 +36,7 @@ attribute_container_set_no_classdevs(struct attribute_container *atc)
 	atc->flags |= ATTRIBUTE_CONTAINER_NO_CLASSDEVS;
 }
 
-int attribute_container_register(struct attribute_container *cont);
+void attribute_container_register(struct attribute_container *cont);
 int __must_check attribute_container_unregister(struct attribute_container *cont);
 void attribute_container_create_device(struct device *dev,
 				       int (*fn)(struct attribute_container *,
diff --git a/include/linux/transport_class.h b/include/linux/transport_class.h
index 2efc271a96fa..9c2e03104461 100644
--- a/include/linux/transport_class.h
+++ b/include/linux/transport_class.h
@@ -87,9 +87,9 @@ transport_unregister_device(struct device *dev)
 	transport_destroy_device(dev);
 }
 
-static inline int transport_container_register(struct transport_container *tc)
+static inline void transport_container_register(struct transport_container *tc)
 {
-	return attribute_container_register(&tc->ac);
+	attribute_container_register(&tc->ac);
 }
 
 static inline void transport_container_unregister(struct transport_container *tc)
@@ -99,7 +99,7 @@ static inline void transport_container_unregister(struct transport_container *tc
 }
 
 int transport_class_register(struct transport_class *);
-int anon_transport_class_register(struct anon_transport_class *);
+void anon_transport_class_register(struct anon_transport_class *);
 void transport_class_unregister(struct transport_class *);
 void anon_transport_class_unregister(struct anon_transport_class *);
 

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251218-dev-attribute-container-linux-scsi-ef185a035eba

Best regards,
--  
Daniel Gomez <da.gomez@samsung.com>


                 reply	other threads:[~2025-12-20  3:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251220-dev-attribute-container-linux-scsi-v1-1-d58fcd03bf21@samsung.com \
    --to=da.gomez@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=atomlin@atomlin.com \
    --cc=da.gomez@samsung.com \
    --cc=dakr@kernel.org \
    --cc=demarchi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mcgrof@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=rafael@kernel.org \
    --cc=samitolvanen@google.com \
    /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