Commit e8596243 authored by Patrick Mochel's avatar Patrick Mochel

drver model: Add release method for class devices.

From Manuel Estrada Sainz <ranty@debian.org>

So device classes can intercept the generic object release method.
parent 07ca08b1
......@@ -4,3 +4,12 @@ extern void bus_remove_device(struct device * dev);
extern int bus_add_driver(struct device_driver *);
extern void bus_remove_driver(struct device_driver *);
static inline struct class_device *to_class_dev(struct kobject *obj)
{
return container_of(obj,struct class_device,kobj);
}
static inline
struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
{
return container_of(_attr,struct class_device_attribute,attr);
}
......@@ -148,9 +148,6 @@ static void class_device_driver_unlink(struct class_device * class_dev)
}
#define to_class_dev(obj) container_of(obj,struct class_device,kobj)
#define to_class_dev_attr(_attr) container_of(_attr,struct class_device_attribute,attr)
static ssize_t
class_device_attr_show(struct kobject * kobj, struct attribute * attr,
char * buf)
......@@ -182,7 +179,15 @@ static struct sysfs_ops class_dev_sysfs_ops = {
.store = class_device_attr_store,
};
static void class_dev_release(struct kobject * kobj)
{
struct class_device *class_dev = to_class_dev(kobj);
if (class_dev->release)
class_dev->release(class_dev);
}
static struct kobj_type ktype_class_device = {
.release = &class_dev_release,
.sysfs_ops = &class_dev_sysfs_ops,
};
......
......@@ -204,6 +204,7 @@ struct class_device {
void * class_data; /* class-specific data */
char class_id[BUS_ID_SIZE]; /* unique to this class */
void (*release)(struct class_device * class_dev);
};
static inline void *
......
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