Linux USB
 help / color / mirror / Atom feed
From: Jakub Lecki <lec.jakub@gmail.com>
To: Valentina Manea <valentina.manea.m@gmail.com>,
	 Shuah Khan <shuah@kernel.org>, Hongren Zheng <i@zenithal.me>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Jakub Lecki <lec.jakub@gmail.com>
Subject: [PATCH 1/2] usbip: Convert usbip_debug to driver attribute.
Date: Fri, 12 Jun 2026 00:10:58 +0200	[thread overview]
Message-ID: <20260612-usbip-attribute-cleanup-v1-1-8de3aa76867e@gmail.com> (raw)
In-Reply-To: <20260612-usbip-attribute-cleanup-v1-0-8de3aa76867e@gmail.com>

Changing configuration of the debug flag affects all of devices debug
prints. Move the attribute to a driver level to prevent duplication.

The attribute for given drivers is located under:
* /sys/bus/platform/drivers/vhci_hcd/usbip_debug
* /sys/bus/usb/drivers/usbip-host/usbip_debug

Signed-off-by: Jakub Lecki <lec.jakub@gmail.com>
---
 drivers/usb/usbip/stub_dev.c     | 10 +++++++++-
 drivers/usb/usbip/usbip_common.c | 14 ++++++--------
 drivers/usb/usbip/usbip_common.h |  2 +-
 drivers/usb/usbip/vhci_hcd.c     |  7 +++++++
 drivers/usb/usbip/vhci_sysfs.c   |  3 +--
 5 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index abfa11d6bde7..653d582de181 100644
--- a/drivers/usb/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -145,11 +145,16 @@ static DEVICE_ATTR_WO(usbip_sockfd);
 static struct attribute *usbip_attrs[] = {
 	&dev_attr_usbip_status.attr,
 	&dev_attr_usbip_sockfd.attr,
-	&dev_attr_usbip_debug.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(usbip);
 
+static struct attribute *usbip_drv_attrs[] = {
+	&driver_attr_usbip_debug.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(usbip_drv);
+
 static void stub_shutdown_connection(struct usbip_device *ud)
 {
 	struct stub_device *sdev = container_of(ud, struct stub_device, ud);
@@ -531,4 +536,7 @@ struct usb_device_driver stub_driver = {
 #endif
 	.supports_autosuspend	=	0,
 	.dev_groups	= usbip_groups,
+	.driver = {
+		.groups		= usbip_drv_groups,
+	}
 };
diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
index a5837c0feb05..6920c12f2863 100644
--- a/drivers/usb/usbip/usbip_common.c
+++ b/drivers/usb/usbip/usbip_common.c
@@ -30,24 +30,22 @@ module_param(usbip_debug_flag, ulong, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(usbip_debug_flag, "debug flags (defined in usbip_common.h)");
 
 /* FIXME */
-struct device_attribute dev_attr_usbip_debug;
-EXPORT_SYMBOL_GPL(dev_attr_usbip_debug);
+struct driver_attribute driver_attr_usbip_debug;
+EXPORT_SYMBOL_GPL(driver_attr_usbip_debug);
 
-static ssize_t usbip_debug_show(struct device *dev,
-				struct device_attribute *attr, char *buf)
+static ssize_t usbip_debug_show(struct device_driver *driver, char *buf)
 {
 	return sprintf(buf, "%lx\n", usbip_debug_flag);
 }
 
-static ssize_t usbip_debug_store(struct device *dev,
-				 struct device_attribute *attr, const char *buf,
-				 size_t count)
+static ssize_t usbip_debug_store(struct device_driver *driver,
+				 const char *buf, size_t count)
 {
 	if (sscanf(buf, "%lx", &usbip_debug_flag) != 1)
 		return -EINVAL;
 	return count;
 }
-DEVICE_ATTR_RW(usbip_debug);
+DRIVER_ATTR_RW(usbip_debug);
 
 static void usbip_dump_buffer(char *buff, int bufflen)
 {
diff --git a/drivers/usb/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h
index 282efca64a01..ee4114e44935 100644
--- a/drivers/usb/usbip/usbip_common.h
+++ b/drivers/usb/usbip/usbip_common.h
@@ -57,7 +57,7 @@ enum {
 #define usbip_dbg_flag_vhci_sysfs  (usbip_debug_flag & usbip_debug_vhci_sysfs)
 
 extern unsigned long usbip_debug_flag;
-extern struct device_attribute dev_attr_usbip_debug;
+extern struct driver_attribute driver_attr_usbip_debug;
 
 #define usbip_dbg_with_flag(flag, fmt, args...)		\
 	do {						\
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 39e8faf4c18c..bff752ac3183 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -1506,6 +1506,12 @@ static int vhci_hcd_resume(struct platform_device *pdev)
 
 #endif
 
+static struct attribute *vhci_attrs[] = {
+	&driver_attr_usbip_debug.attr,
+	NULL
+};
+ATTRIBUTE_GROUPS(vhci);
+
 static struct platform_driver vhci_driver = {
 	.probe	= vhci_hcd_probe,
 	.remove = vhci_hcd_remove,
@@ -1513,6 +1519,7 @@ static struct platform_driver vhci_driver = {
 	.resume	= vhci_hcd_resume,
 	.driver	= {
 		.name = driver_name,
+		.groups = vhci_groups,
 	},
 };
 
diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index 5bc8c47788d4..2742ab12f309 100644
--- a/drivers/usb/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
@@ -512,9 +512,8 @@ int vhci_init_attr_group(void)
 	*attrs = &dev_attr_nports.attr;
 	*(attrs + 1) = &dev_attr_detach.attr;
 	*(attrs + 2) = &dev_attr_attach.attr;
-	*(attrs + 3) = &dev_attr_usbip_debug.attr;
 	for (i = 0; i < vhci_num_controllers; i++)
-		*(attrs + i + 4) = &((status_attrs + i)->attr.attr);
+		*(attrs + i + 3) = &((status_attrs + i)->attr.attr);
 	vhci_attr_group.attrs = attrs;
 	return 0;
 }

-- 
2.53.0


  reply	other threads:[~2026-06-11 22:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11 22:10 [PATCH 0/2] usbip: Cleanup of sysfs attributes Jakub Lecki
2026-06-11 22:10 ` Jakub Lecki [this message]
2026-06-11 22:10 ` [PATCH 2/2] usbip: Cleanup of vhci_hcd attributes Jakub Lecki

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=20260612-usbip-attribute-cleanup-v1-1-8de3aa76867e@gmail.com \
    --to=lec.jakub@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=i@zenithal.me \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=valentina.manea.m@gmail.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