diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2007-02-20 14:59:59 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-23 18:03:46 -0500 |
commit | aa084f3efe5fb7e9c0d5b54ce704f0de69bbf27c (patch) | |
tree | bd274b5561b2050cb8cd86ae37a3935f04e03de0 /drivers | |
parent | 7ceec1f1d26f966c0816b86a1aab1e0b3b208757 (diff) |
USB: minor cleanups for sysfs.c
This patch (as858) makes some minor cleanups to sysfs.c in usbcore.
Unnecessary tests are removed and a few temp variables are added.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/core/sysfs.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 8f5a764057cd..cad4fb323f6c 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -250,10 +250,7 @@ int usb_create_sysfs_dev_files(struct usb_device *udev) | |||
250 | goto error; | 250 | goto error; |
251 | return 0; | 251 | return 0; |
252 | error: | 252 | error: |
253 | usb_remove_ep_files(&udev->ep0); | 253 | usb_remove_sysfs_dev_files(udev); |
254 | device_remove_file(dev, &dev_attr_manufacturer); | ||
255 | device_remove_file(dev, &dev_attr_product); | ||
256 | device_remove_file(dev, &dev_attr_serial); | ||
257 | return retval; | 254 | return retval; |
258 | } | 255 | } |
259 | 256 | ||
@@ -262,14 +259,10 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev) | |||
262 | struct device *dev = &udev->dev; | 259 | struct device *dev = &udev->dev; |
263 | 260 | ||
264 | usb_remove_ep_files(&udev->ep0); | 261 | usb_remove_ep_files(&udev->ep0); |
262 | device_remove_file(dev, &dev_attr_manufacturer); | ||
263 | device_remove_file(dev, &dev_attr_product); | ||
264 | device_remove_file(dev, &dev_attr_serial); | ||
265 | sysfs_remove_group(&dev->kobj, &dev_attr_grp); | 265 | sysfs_remove_group(&dev->kobj, &dev_attr_grp); |
266 | |||
267 | if (udev->manufacturer) | ||
268 | device_remove_file(dev, &dev_attr_manufacturer); | ||
269 | if (udev->product) | ||
270 | device_remove_file(dev, &dev_attr_product); | ||
271 | if (udev->serial) | ||
272 | device_remove_file(dev, &dev_attr_serial); | ||
273 | } | 266 | } |
274 | 267 | ||
275 | /* Interface fields */ | 268 | /* Interface fields */ |
@@ -373,33 +366,28 @@ static inline void usb_remove_intf_ep_files(struct usb_interface *intf) | |||
373 | 366 | ||
374 | int usb_create_sysfs_intf_files(struct usb_interface *intf) | 367 | int usb_create_sysfs_intf_files(struct usb_interface *intf) |
375 | { | 368 | { |
369 | struct device *dev = &intf->dev; | ||
376 | struct usb_device *udev = interface_to_usbdev(intf); | 370 | struct usb_device *udev = interface_to_usbdev(intf); |
377 | struct usb_host_interface *alt = intf->cur_altsetting; | 371 | struct usb_host_interface *alt = intf->cur_altsetting; |
378 | int retval; | 372 | int retval; |
379 | 373 | ||
380 | retval = sysfs_create_group(&intf->dev.kobj, &intf_attr_grp); | 374 | retval = sysfs_create_group(&dev->kobj, &intf_attr_grp); |
381 | if (retval) | 375 | if (retval) |
382 | goto error; | 376 | return retval; |
383 | 377 | ||
384 | if (alt->string == NULL) | 378 | if (alt->string == NULL) |
385 | alt->string = usb_cache_string(udev, alt->desc.iInterface); | 379 | alt->string = usb_cache_string(udev, alt->desc.iInterface); |
386 | if (alt->string) | 380 | if (alt->string) |
387 | retval = device_create_file(&intf->dev, &dev_attr_interface); | 381 | retval = device_create_file(dev, &dev_attr_interface); |
388 | usb_create_intf_ep_files(intf, udev); | 382 | usb_create_intf_ep_files(intf, udev); |
389 | return 0; | 383 | return 0; |
390 | error: | ||
391 | if (alt->string) | ||
392 | device_remove_file(&intf->dev, &dev_attr_interface); | ||
393 | sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp); | ||
394 | usb_remove_intf_ep_files(intf); | ||
395 | return retval; | ||
396 | } | 384 | } |
397 | 385 | ||
398 | void usb_remove_sysfs_intf_files(struct usb_interface *intf) | 386 | void usb_remove_sysfs_intf_files(struct usb_interface *intf) |
399 | { | 387 | { |
400 | usb_remove_intf_ep_files(intf); | 388 | struct device *dev = &intf->dev; |
401 | sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp); | ||
402 | 389 | ||
403 | if (intf->cur_altsetting->string) | 390 | usb_remove_intf_ep_files(intf); |
404 | device_remove_file(&intf->dev, &dev_attr_interface); | 391 | device_remove_file(dev, &dev_attr_interface); |
392 | sysfs_remove_group(&dev->kobj, &intf_attr_grp); | ||
405 | } | 393 | } |