提交 f8868ed0 编写于 作者: A Andy Shevchenko 提交者: Greg Kroah-Hartman

usb: core: use kbasename() instead of open-coded variant

kbasename() helper is dedicated to find a last part of the filename or
pathname. USB core uses open-coded variant of that helper.

Replace some lines of code by kbasename() call.

The current users do not have trailing slash and we are on the safe side to
make such change. I dig a history of the code under question up and found the
patch [1] that brought it along with the same to tty layer. The check for
trailing slash looks like copy'n'paste thing and I consider it as redundant.

[1] http://www.kernel.org/pub/linux/kernel//people/akpm/patches/2.5/2.5.69/2.5.69-mm3/broken-out/linus.patchSigned-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 6f5429d9
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/string.h>
#include <linux/usb.h> #include <linux/usb.h>
#include "usb.h" #include "usb.h"
...@@ -155,7 +156,6 @@ int usb_register_dev(struct usb_interface *intf, ...@@ -155,7 +156,6 @@ int usb_register_dev(struct usb_interface *intf,
int minor_base = class_driver->minor_base; int minor_base = class_driver->minor_base;
int minor; int minor;
char name[20]; char name[20];
char *temp;
#ifdef CONFIG_USB_DYNAMIC_MINORS #ifdef CONFIG_USB_DYNAMIC_MINORS
/* /*
...@@ -192,14 +192,9 @@ int usb_register_dev(struct usb_interface *intf, ...@@ -192,14 +192,9 @@ int usb_register_dev(struct usb_interface *intf,
/* create a usb class device for this usb interface */ /* create a usb class device for this usb interface */
snprintf(name, sizeof(name), class_driver->name, minor - minor_base); snprintf(name, sizeof(name), class_driver->name, minor - minor_base);
temp = strrchr(name, '/');
if (temp && (temp[1] != '\0'))
++temp;
else
temp = name;
intf->usb_dev = device_create(usb_class->class, &intf->dev, intf->usb_dev = device_create(usb_class->class, &intf->dev,
MKDEV(USB_MAJOR, minor), class_driver, MKDEV(USB_MAJOR, minor), class_driver,
"%s", temp); "%s", kbasename(name));
if (IS_ERR(intf->usb_dev)) { if (IS_ERR(intf->usb_dev)) {
down_write(&minor_rwsem); down_write(&minor_rwsem);
usb_minors[minor] = NULL; usb_minors[minor] = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册