--- drivers/base/core.c | 33 ++++++++------------------------- include/linux/device.h | 1 - 2 files changed, 8 insertions(+), 26 deletions(-) Index: tree0/drivers/base/core.c =================================================================== --- tree0.orig/drivers/base/core.c +++ tree0/drivers/base/core.c @@ -287,6 +287,8 @@ static ssize_t show_dev(struct device *d return print_dev_t(buf, dev->devt); } +static struct device_attribute devt_attr = __ATTR(dev, S_IRUGO, show_dev, NULL ); + /* * devices_subsys - structure to be registered with kobject core. */ @@ -490,24 +492,9 @@ int device_add(struct device *dev) goto attrError; if (MAJOR(dev->devt)) { - struct device_attribute *attr; - attr = kzalloc(sizeof(*attr), GFP_KERNEL); - if (!attr) { - error = -ENOMEM; - goto ueventattrError; - } - attr->attr.name = "dev"; - attr->attr.mode = S_IRUGO; - if (dev->driver) - attr->attr.owner = dev->driver->owner; - attr->show = show_dev; - error = device_create_file(dev, attr); - if (error) { - kfree(attr); + error = device_create_file(dev, &devt_attr); + if (error) goto ueventattrError; - } - - dev->devt_attr = attr; } if (dev->class) { @@ -568,10 +555,8 @@ int device_add(struct device *dev) GroupError: device_remove_attrs(dev); AttrsError: - if (dev->devt_attr) { - device_remove_file(dev, dev->devt_attr); - kfree(dev->devt_attr); - } + if (MAJOR(dev->devt)) + device_remove_file(dev, &devt_attr); ueventattrError: device_remove_file(dev, &dev->uevent_attr); attrError: @@ -650,10 +635,8 @@ void device_del(struct device * dev) if (parent) klist_del(&dev->knode_parent); - if (dev->devt_attr) { - device_remove_file(dev, dev->devt_attr); - kfree(dev->devt_attr); - } + if (MAJOR(dev->devt)) + device_remove_file(dev, &devt_attr); if (dev->class) { sysfs_remove_link(&dev->kobj, "subsystem"); /* If this is not a "fake" compatible device, remove the Index: tree0/include/linux/device.h =================================================================== --- tree0.orig/include/linux/device.h +++ tree0/include/linux/device.h @@ -357,7 +357,6 @@ struct device { char bus_id[BUS_ID_SIZE]; /* position on parent bus */ unsigned is_registered:1; struct device_attribute uevent_attr; - struct device_attribute *devt_attr; struct semaphore sem; /* semaphore to synchronize calls to * its driver.