Re: [linux-usb-devel] usb+sysfs: duplicate filename 'bInterfaceNumber'

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Dave Young
Date: Thursday, October 25, 2007 - 2:06 am

On 10/19/07, Greg KH <greg@kroah.com> wrote:
Hi, greg

How about this patch (based on 2.6.24-rc1):

diff -upr linux/drivers/usb/core/message.c linux.new/drivers/usb/core/message.c
--- linux/drivers/usb/core/message.c	2007-10-25 16:41:32.000000000 +0800
+++ linux.new/drivers/usb/core/message.c	2007-10-25 16:39:38.000000000 +0800
@@ -1641,7 +1641,8 @@ free_interfaces:
 				intf->dev.bus_id, ret);
 			continue;
 		}
-		usb_create_sysfs_intf_files (intf);
+		if(!usb_sysfs_intf_exist(intf))
+			usb_create_sysfs_intf_files (intf);
 	}
 
 	usb_autosuspend_device(dev);
diff -upr linux/drivers/usb/core/sysfs.c linux.new/drivers/usb/core/sysfs.c
--- linux/drivers/usb/core/sysfs.c	2007-10-25 16:40:16.000000000 +0800
+++ linux.new/drivers/usb/core/sysfs.c	2007-10-25 16:39:32.000000000 +0800
@@ -728,6 +728,13 @@ static inline void usb_remove_intf_ep_fi
 		usb_remove_ep_files(&iface_desc->endpoint[i]);
 }
 
+int usb_sysfs_intf_exist(struct usb_interface *intf)
+{
+	struct device *dev = &intf->dev;
+	
+	return sysfs_dirent_exist(&dev->kobj, intf_attrs[0]->name);
+}
+
 int usb_create_sysfs_intf_files(struct usb_interface *intf)
 {
 	struct device *dev = &intf->dev;
diff -upr linux/drivers/usb/core/usb.h linux.new/drivers/usb/core/usb.h
--- linux/drivers/usb/core/usb.h	2007-10-25 16:41:02.000000000 +0800
+++ linux.new/drivers/usb/core/usb.h	2007-10-25 16:39:19.000000000 +0800
@@ -1,5 +1,6 @@
 /* Functions local to drivers/usb/core/ */
 
+extern int usb_sysfs_intf_exist(struct usb_interface *intf);
 extern int usb_create_sysfs_dev_files (struct usb_device *dev);
 extern void usb_remove_sysfs_dev_files (struct usb_device *dev);
 extern int usb_create_sysfs_intf_files (struct usb_interface *intf);
diff -upr linux/fs/sysfs/dir.c linux.new/fs/sysfs/dir.c
--- linux/fs/sysfs/dir.c	2007-10-25 16:40:43.000000000 +0800
+++ linux.new/fs/sysfs/dir.c	2007-10-25 16:39:00.000000000 +0800
@@ -583,6 +583,16 @@ struct sysfs_dirent *sysfs_find_dirent(s
 	return NULL;
 }
 
+int sysfs_dirent_exist(struct kobject *kobj, const unsigned char *name)
+{
+	struct sysfs_dirent *sd = kobj->sd;
+	
+	if (sysfs_find_dirent(sd, name))
+		return 1;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(sysfs_dirent_exist);
+
 /**
  *	sysfs_get_dirent - find and get sysfs_dirent with the given name
  *	@parent_sd: sysfs_dirent to search under
diff -upr linux/inclue/linux/sysfs.h linux.new/inclue/linux/sysfs.h
--- linux/inclue/linux/sysfs.h	2007-10-25 16:40:02.000000000 +0800
+++ linux.new/inclue/linux/sysfs.h	2007-10-25 16:38:40.000000000 +0800
@@ -112,6 +112,8 @@ void sysfs_remove_file_from_group(struct
 
 void sysfs_notify(struct kobject *kobj, char *dir, char *attr);
 
+int sysfs_dirent_exist(struct kobject *kobj, const unsigned char *name);
+
 extern int __must_check sysfs_init(void);
 
 #else /* CONFIG_SYSFS */
@@ -211,6 +213,11 @@ static inline void sysfs_notify(struct k
 {
 }
 
+static int sysfs_dirent_exist(struct kobject *kobj, const unsigned char *name)
+{
+	return 0;
+}
+
 static inline int __must_check sysfs_init(void)
 {
 	return 0;
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [linux-usb-devel] usb+sysfs: duplicate filename 'bInte ..., Dave Young, (Thu Oct 25, 2:06 am)