Commit 69f8d663 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] PCI Hotplug: fix core problem with kobject lifespans.

Added needed release function, now all pci hotplug drivers need to implement
it...
parent 5b528b00
...@@ -51,6 +51,8 @@ struct hotplug_slot_attribute { ...@@ -51,6 +51,8 @@ struct hotplug_slot_attribute {
ssize_t (*show)(struct hotplug_slot *, char *); ssize_t (*show)(struct hotplug_slot *, char *);
ssize_t (*store)(struct hotplug_slot *, const char *, size_t); ssize_t (*store)(struct hotplug_slot *, const char *, size_t);
}; };
#define to_hotplug_attr(n) container_of(n, struct hotplug_slot_attribute, attr);
/** /**
* struct hotplug_slot_ops -the callbacks that the hotplug pci core can use * struct hotplug_slot_ops -the callbacks that the hotplug pci core can use
* @owner: The module owner of this structure * @owner: The module owner of this structure
...@@ -130,12 +132,14 @@ struct hotplug_slot { ...@@ -130,12 +132,14 @@ struct hotplug_slot {
char *name; char *name;
struct hotplug_slot_ops *ops; struct hotplug_slot_ops *ops;
struct hotplug_slot_info *info; struct hotplug_slot_info *info;
void (*release) (struct hotplug_slot *slot);
void *private; void *private;
/* Variables below this are for use only by the hotplug pci core. */ /* Variables below this are for use only by the hotplug pci core. */
struct list_head slot_list; struct list_head slot_list;
struct kobject kobj; struct kobject kobj;
}; };
#define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj)
extern int pci_hp_register (struct hotplug_slot *slot); extern int pci_hp_register (struct hotplug_slot *slot);
extern int pci_hp_deregister (struct hotplug_slot *slot); extern int pci_hp_deregister (struct hotplug_slot *slot);
......
...@@ -74,20 +74,16 @@ static struct subsystem hotplug_slots_subsys; ...@@ -74,20 +74,16 @@ static struct subsystem hotplug_slots_subsys;
static ssize_t hotplug_slot_attr_show(struct kobject *kobj, static ssize_t hotplug_slot_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf) struct attribute *attr, char *buf)
{ {
struct hotplug_slot *slot=container_of(kobj, struct hotplug_slot *slot = to_hotplug_slot(kobj);
struct hotplug_slot,kobj); struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr);
struct hotplug_slot_attribute *attribute =
container_of(attr, struct hotplug_slot_attribute, attr);
return attribute->show ? attribute->show(slot, buf) : 0; return attribute->show ? attribute->show(slot, buf) : 0;
} }
static ssize_t hotplug_slot_attr_store(struct kobject *kobj, static ssize_t hotplug_slot_attr_store(struct kobject *kobj,
struct attribute *attr, const char *buf, size_t len) struct attribute *attr, const char *buf, size_t len)
{ {
struct hotplug_slot *slot=container_of(kobj, struct hotplug_slot *slot = to_hotplug_slot(kobj);
struct hotplug_slot,kobj); struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr);
struct hotplug_slot_attribute *attribute =
container_of(attr, struct hotplug_slot_attribute, attr);
return attribute->store ? attribute->store(slot, buf, len) : 0; return attribute->store ? attribute->store(slot, buf, len) : 0;
} }
...@@ -96,8 +92,16 @@ static struct sysfs_ops hotplug_slot_sysfs_ops = { ...@@ -96,8 +92,16 @@ static struct sysfs_ops hotplug_slot_sysfs_ops = {
.store = hotplug_slot_attr_store, .store = hotplug_slot_attr_store,
}; };
static void hotplug_slot_release(struct kobject *kobj)
{
struct hotplug_slot *slot = to_hotplug_slot(kobj);
if (slot->release)
slot->release(slot);
}
static struct kobj_type hotplug_slot_ktype = { static struct kobj_type hotplug_slot_ktype = {
.sysfs_ops = &hotplug_slot_sysfs_ops .sysfs_ops = &hotplug_slot_sysfs_ops,
.release = &hotplug_slot_release,
}; };
static decl_subsys(hotplug_slots, &hotplug_slot_ktype, NULL); static decl_subsys(hotplug_slots, &hotplug_slot_ktype, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment