public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>, Al Viro <viro@zeniv.linux.org.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Marco Crivellari <marco.crivellari@suse.com>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] RDMA/hfi1: reduce namespace pollution
Date: Fri, 20 Mar 2026 16:12:39 +0100	[thread overview]
Message-ID: <20260320151511.3420818-3-arnd@kernel.org> (raw)
In-Reply-To: <20260320151511.3420818-1-arnd@kernel.org>

From: Arnd Bergmann <arnd@arndb.de>

While looking at an unrelated bug, I noticed that the global "class_name"
function is not suitable for a driver-internal interface. The same
file that declares this also has dev_init() and dev_exit() functions,
which are equally problematic.

Remove the class_name() function entirely and just hardcode the string
where it is used, and rename the other two functions to fit into the
hfi1 namespace.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
----
The driver contains many more functions that should not be in the global
namespace, but I decided not to fix the other ones. Maybe the maintainers
can continue renaming the rest.
---
 drivers/infiniband/hw/hfi1/debugfs.c  |  2 +-
 drivers/infiniband/hw/hfi1/device.c   | 11 ++---------
 drivers/infiniband/hw/hfi1/device.h   |  5 ++---
 drivers/infiniband/hw/hfi1/file_ops.c |  2 +-
 drivers/infiniband/hw/hfi1/init.c     |  8 ++++----
 5 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/debugfs.c b/drivers/infiniband/hw/hfi1/debugfs.c
index ac37ab7f8995..24346b74d5e0 100644
--- a/drivers/infiniband/hw/hfi1/debugfs.c
+++ b/drivers/infiniband/hw/hfi1/debugfs.c
@@ -1161,7 +1161,7 @@ void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd)
 
 	if (!hfi1_dbg_root)
 		return;
-	snprintf(name, sizeof(name), "%s_%d", class_name(), unit);
+	snprintf(name, sizeof(name), "hfi1_%d", unit);
 	snprintf(link, sizeof(link), "%d", unit);
 	root = debugfs_create_dir(name, hfi1_dbg_root);
 	ibd->hfi1_ibdev_dbg = root;
diff --git a/drivers/infiniband/hw/hfi1/device.c b/drivers/infiniband/hw/hfi1/device.c
index 1aac6c2f45b4..a26b71867a2a 100644
--- a/drivers/infiniband/hw/hfi1/device.c
+++ b/drivers/infiniband/hw/hfi1/device.c
@@ -86,14 +86,7 @@ void hfi1_cdev_cleanup(struct cdev *cdev, struct device **devp)
 	}
 }
 
-static const char *hfi1_class_name = "hfi1";
-
-const char *class_name(void)
-{
-	return hfi1_class_name;
-}
-
-int __init dev_init(void)
+int __init hfi1_dev_init(void)
 {
 	int ret;
 
@@ -123,7 +116,7 @@ int __init dev_init(void)
 	return ret;
 }
 
-void dev_cleanup(void)
+void hfi1_dev_cleanup(void)
 {
 	class_unregister(&class);
 	class_unregister(&user_class);
diff --git a/drivers/infiniband/hw/hfi1/device.h b/drivers/infiniband/hw/hfi1/device.h
index a91bea426ba5..d7775f92e0b1 100644
--- a/drivers/infiniband/hw/hfi1/device.h
+++ b/drivers/infiniband/hw/hfi1/device.h
@@ -12,8 +12,7 @@ int hfi1_cdev_init(int minor, const char *name,
 		   bool user_accessible,
 		   struct kobject *parent);
 void hfi1_cdev_cleanup(struct cdev *cdev, struct device **devp);
-const char *class_name(void);
-int __init dev_init(void);
-void dev_cleanup(void);
+int __init hfi1_dev_init(void);
+void hfi1_dev_cleanup(void);
 
 #endif                          /* _HFI1_DEVICE_H */
diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
index 56031becb273..2fe7f7df7d09 100644
--- a/drivers/infiniband/hw/hfi1/file_ops.c
+++ b/drivers/infiniband/hw/hfi1/file_ops.c
@@ -1686,7 +1686,7 @@ static int user_add(struct hfi1_devdata *dd)
 	char name[10];
 	int ret;
 
-	snprintf(name, sizeof(name), "%s_%d", class_name(), dd->unit);
+	snprintf(name, sizeof(name), "hfi1_%d", dd->unit);
 	ret = hfi1_cdev_init(dd->unit, name, &hfi1_file_ops,
 			     &dd->user_cdev, &dd->user_device,
 			     true, &dd->verbs_dev.rdi.ibdev.dev.kobj);
diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
index fb0a8325a43d..28213ddcf2e9 100644
--- a/drivers/infiniband/hw/hfi1/init.c
+++ b/drivers/infiniband/hw/hfi1/init.c
@@ -1236,7 +1236,7 @@ static struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev,
 	 * to work by setting the name manually here.
 	 */
 	ibdev = &dd->verbs_dev.rdi.ibdev;
-	dev_set_name(&ibdev->dev, "%s_%d", class_name(), dd->unit);
+	dev_set_name(&ibdev->dev, "hfi1_%d", dd->unit);
 	strscpy(&ibdev->name, dev_name(&ibdev->dev), IB_DEVICE_NAME_MAX);
 
 	/*
@@ -1387,7 +1387,7 @@ static int __init hfi1_mod_init(void)
 {
 	int ret;
 
-	ret = dev_init();
+	ret = hfi1_dev_init();
 	if (ret)
 		goto bail;
 
@@ -1460,7 +1460,7 @@ static int __init hfi1_mod_init(void)
 
 bail_dev:
 	hfi1_dbg_exit();
-	dev_cleanup();
+	hfi1_dev_cleanup();
 bail:
 	return ret;
 }
@@ -1479,7 +1479,7 @@ static void __exit hfi1_mod_cleanup(void)
 
 	WARN_ON(!xa_empty(&hfi1_dev_table));
 	dispose_firmware();	/* asymmetric with obtain_firmware() */
-	dev_cleanup();
+	hfi1_dev_cleanup();
 }
 
 module_exit(hfi1_mod_cleanup);
-- 
2.39.5


  parent reply	other threads:[~2026-03-20 15:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 15:12 [PATCH 1/3] [RESEND] RDMA/hfi1: use a struct group to avoid warning Arnd Bergmann
2026-03-20 15:12 ` [PATCH 2/3] RDMA/hfi1, rdmavt: open-code rvt_set_ibdev_name() Arnd Bergmann
2026-03-20 15:53   ` Arnd Bergmann
2026-03-23  8:08     ` Leon Romanovsky
2026-03-23  8:48       ` Arnd Bergmann
2026-03-23 11:01         ` Leon Romanovsky
2026-03-23 21:47           ` Dennis Dalessandro
2026-03-24  7:27             ` Arnd Bergmann
2026-03-24  7:51               ` Leon Romanovsky
2026-03-24  7:53             ` Leon Romanovsky
2026-03-23 21:54         ` Dennis Dalessandro
2026-03-22 18:29   ` kernel test robot
2026-03-22 20:12   ` kernel test robot
2026-03-24  1:29   ` kernel test robot
2026-03-20 15:12 ` Arnd Bergmann [this message]
2026-03-20 18:01 ` [PATCH 1/3] [RESEND] RDMA/hfi1: use a struct group to avoid warning Kees Cook
2026-03-20 21:49 ` yanjun.zhu

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=20260320151511.3420818-3-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=marco.crivellari@suse.com \
    --cc=viro@zeniv.linux.org.uk \
    /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