Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 7207
b: refs/heads/master
c: 76d1ce0
h: refs/heads/master
i:
  7205: 13758aa
  7203: e3ee4e1
  7199: 0463b11
v: v3
  • Loading branch information
Dmitry Torokhov authored and Greg Kroah-Hartman committed Sep 5, 2005
1 parent b5d8236 commit e037d67
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d65da6eae10cc77f93ead0188cde0b45f124d912
refs/heads/master: 76d1ce00bdd76c2987fbfb763cd40447413a55b3
33 changes: 31 additions & 2 deletions trunk/drivers/base/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,29 @@ void class_device_initialize(struct class_device *class_dev)
INIT_LIST_HEAD(&class_dev->node);
}

static char *make_class_name(struct class_device *class_dev)
{
char *name;
int size;

size = strlen(class_dev->class->name) +
strlen(kobject_name(&class_dev->kobj)) + 2;

name = kmalloc(size, GFP_KERNEL);
if (!name)
return ERR_PTR(-ENOMEM);

strcpy(name, class_dev->class->name);
strcat(name, ":");
strcat(name, kobject_name(&class_dev->kobj));
return name;
}

int class_device_add(struct class_device *class_dev)
{
struct class * parent = NULL;
struct class_interface * class_intf;
char *class_name = NULL;
int error;

class_dev = class_device_get(class_dev);
Expand Down Expand Up @@ -500,9 +519,13 @@ int class_device_add(struct class_device *class_dev)
}

class_device_add_attrs(class_dev);
if (class_dev->dev)
if (class_dev->dev) {
class_name = make_class_name(class_dev);
sysfs_create_link(&class_dev->kobj,
&class_dev->dev->kobj, "device");
sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj,
class_name);
}

/* notify any interfaces this device is now here */
if (parent) {
Expand All @@ -519,6 +542,7 @@ int class_device_add(struct class_device *class_dev)
if (error && parent)
class_put(parent);
class_device_put(class_dev);
kfree(class_name);
return error;
}

Expand Down Expand Up @@ -584,6 +608,7 @@ void class_device_del(struct class_device *class_dev)
{
struct class * parent = class_dev->class;
struct class_interface * class_intf;
char *class_name = NULL;

if (parent) {
down(&parent->sem);
Expand All @@ -594,8 +619,11 @@ void class_device_del(struct class_device *class_dev)
up(&parent->sem);
}

if (class_dev->dev)
if (class_dev->dev) {
class_name = make_class_name(class_dev);
sysfs_remove_link(&class_dev->kobj, "device");
sysfs_remove_link(&class_dev->dev->kobj, class_name);
}
if (class_dev->devt_attr)
class_device_remove_file(class_dev, class_dev->devt_attr);
class_device_remove_attrs(class_dev);
Expand All @@ -605,6 +633,7 @@ void class_device_del(struct class_device *class_dev)

if (parent)
class_put(parent);
kfree(class_name);
}

void class_device_unregister(struct class_device *class_dev)
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/usb/core/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ static int usb_register_bus(struct usb_bus *bus)
return -E2BIG;
}

bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb%d", busnum);
bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb_host%d", busnum);
if (IS_ERR(bus->class_dev)) {
clear_bit(busnum, busmap.busmap);
up(&usb_bus_list_lock);
Expand Down

0 comments on commit e037d67

Please sign in to comment.