Commit 65740356 authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6:
  driver core: kmalloc() failure check in driver_probe_device
  Driver core: bus: remove indentation level
  Driver core: Don't ignore error returns from probing
  Driver core: Don't leak 'old_class_name' in drivers/base/core.c::device_rename()
  driver core fixes: sysfs_create_group() retval in topology.c
  driver core fixes: device_create_file() retval check in dmapool.c
  driver core fixes: device_add() cleanup on error
  driver core fixes: bus_add_device() cleanup on error
  driver core fixes: bus_add_attrs() retval check
  driver core fixes: sysfs_create_link() retval check in class.c
  sysfs: update obsolete comment in sysfs_update_file
  sysfs: remove duplicated dput in sysfs_update_file
  HOWTO: bug report addition
  Fix dev_printk() is now GPL-only
  Driver core: plug device probe memory leak
  Documentation: feature-removal-schedule typo
parents 6a13a857 4d664238
......@@ -395,6 +395,26 @@ bugme-janitor mailing list (every change in the bugzilla is mailed here)
Managing bug reports
--------------------
One of the best ways to put into practice your hacking skills is by fixing
bugs reported by other people. Not only you will help to make the kernel
more stable, you'll learn to fix real world problems and you will improve
your skills, and other developers will be aware of your presence. Fixing
bugs is one of the best ways to get merits among other developers, because
not many people like wasting time fixing other people's bugs.
To work in the already reported bug reports, go to http://bugzilla.kernel.org.
If you want to be advised of the future bug reports, you can subscribe to the
bugme-new mailing list (only new bug reports are mailed here) or to the
bugme-janitor mailing list (every change in the bugzilla is mailed here)
http://lists.osdl.org/mailman/listinfo/bugme-new
http://lists.osdl.org/mailman/listinfo/bugme-janitors
Mailing lists
-------------
......
......@@ -255,7 +255,7 @@ Who: Stephen Hemminger <shemminger@osdl.org>
What: PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment
When: Oktober 2008
When: October 2008
Why: The stacking of class devices makes these values misleading and
inconsistent.
Class devices should not carry any of these properties, and bus
......
......@@ -372,19 +372,30 @@ int bus_add_device(struct device * dev)
pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
error = device_add_attrs(bus, dev);
if (error)
goto out;
goto out_put;
error = sysfs_create_link(&bus->devices.kobj,
&dev->kobj, dev->bus_id);
if (error)
goto out;
goto out_id;
error = sysfs_create_link(&dev->kobj,
&dev->bus->subsys.kset.kobj, "subsystem");
if (error)
goto out;
goto out_subsys;
error = sysfs_create_link(&dev->kobj,
&dev->bus->subsys.kset.kobj, "bus");
if (error)
goto out_deprecated;
}
out:
return 0;
out_deprecated:
sysfs_remove_link(&dev->kobj, "subsystem");
out_subsys:
sysfs_remove_link(&bus->devices.kobj, dev->bus_id);
out_id:
device_remove_attrs(bus, dev);
out_put:
put_bus(dev->bus);
return error;
}
......@@ -428,8 +439,10 @@ void bus_remove_device(struct device * dev)
sysfs_remove_link(&dev->kobj, "bus");
sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
device_remove_attrs(dev->bus, dev);
dev->is_registered = 0;
klist_del(&dev->knode_bus);
if (dev->is_registered) {
dev->is_registered = 0;
klist_del(&dev->knode_bus);
}
pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
device_release_driver(dev);
put_bus(dev->bus);
......@@ -505,34 +518,36 @@ int bus_add_driver(struct device_driver *drv)
struct bus_type * bus = get_bus(drv->bus);
int error = 0;
if (bus) {
pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
error = kobject_set_name(&drv->kobj, "%s", drv->name);
if (error)
goto out_put_bus;
drv->kobj.kset = &bus->drivers;
if ((error = kobject_register(&drv->kobj)))
goto out_put_bus;
error = driver_attach(drv);
if (error)
goto out_unregister;
klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
module_add_driver(drv->owner, drv);
error = driver_add_attrs(bus, drv);
if (error) {
/* How the hell do we get out of this pickle? Give up */
printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n",
__FUNCTION__, drv->name);
}
error = add_bind_files(drv);
if (error) {
/* Ditto */
printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
__FUNCTION__, drv->name);
}
if (!bus)
return 0;
pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
error = kobject_set_name(&drv->kobj, "%s", drv->name);
if (error)
goto out_put_bus;
drv->kobj.kset = &bus->drivers;
if ((error = kobject_register(&drv->kobj)))
goto out_put_bus;
error = driver_attach(drv);
if (error)
goto out_unregister;
klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
module_add_driver(drv->owner, drv);
error = driver_add_attrs(bus, drv);
if (error) {
/* How the hell do we get out of this pickle? Give up */
printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n",
__FUNCTION__, drv->name);
}
error = add_bind_files(drv);
if (error) {
/* Ditto */
printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
__FUNCTION__, drv->name);
}
return error;
out_unregister:
kobject_unregister(&drv->kobj);
......@@ -552,16 +567,17 @@ int bus_add_driver(struct device_driver *drv)
void bus_remove_driver(struct device_driver * drv)
{
if (drv->bus) {
remove_bind_files(drv);
driver_remove_attrs(drv->bus, drv);
klist_remove(&drv->knode_bus);
pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
driver_detach(drv);
module_remove_driver(drv);
kobject_unregister(&drv->kobj);
put_bus(drv->bus);
}
if (!drv->bus)
return;
remove_bind_files(drv);
driver_remove_attrs(drv->bus, drv);
klist_remove(&drv->knode_bus);
pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
driver_detach(drv);
module_remove_driver(drv);
kobject_unregister(&drv->kobj);
put_bus(drv->bus);
}
......@@ -732,11 +748,15 @@ int bus_register(struct bus_type * bus)
klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
klist_init(&bus->klist_drivers, NULL, NULL);
bus_add_attrs(bus);
retval = bus_add_attrs(bus);
if (retval)
goto bus_attrs_fail;
pr_debug("bus type '%s' registered\n", bus->name);
return 0;
bus_attrs_fail:
kset_unregister(&bus->drivers);
bus_drivers_fail:
kset_unregister(&bus->devices);
bus_devices_fail:
......
......@@ -562,7 +562,10 @@ int class_device_add(struct class_device *class_dev)
goto out2;
/* add the needed attributes to this device */
sysfs_create_link(&class_dev->kobj, &parent_class->subsys.kset.kobj, "subsystem");
error = sysfs_create_link(&class_dev->kobj,
&parent_class->subsys.kset.kobj, "subsystem");
if (error)
goto out3;
class_dev->uevent_attr.attr.name = "uevent";
class_dev->uevent_attr.attr.mode = S_IWUSR;
class_dev->uevent_attr.attr.owner = parent_class->owner;
......
......@@ -44,7 +44,7 @@ const char *dev_driver_string(struct device *dev)
return dev->driver ? dev->driver->name :
(dev->bus ? dev->bus->name : "");
}
EXPORT_SYMBOL_GPL(dev_driver_string);
EXPORT_SYMBOL(dev_driver_string);
#define to_dev(obj) container_of(obj, struct device, kobj)
#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
......@@ -433,14 +433,16 @@ int device_add(struct device *dev)
if (dev->driver)
dev->uevent_attr.attr.owner = dev->driver->owner;
dev->uevent_attr.store = store_uevent;
device_create_file(dev, &dev->uevent_attr);
error = device_create_file(dev, &dev->uevent_attr);
if (error)
goto attrError;
if (MAJOR(dev->devt)) {
struct device_attribute *attr;
attr = kzalloc(sizeof(*attr), GFP_KERNEL);
if (!attr) {
error = -ENOMEM;
goto PMError;
goto ueventattrError;
}
attr->attr.name = "dev";
attr->attr.mode = S_IRUGO;
......@@ -450,7 +452,7 @@ int device_add(struct device *dev)
error = device_create_file(dev, attr);
if (error) {
kfree(attr);
goto attrError;
goto ueventattrError;
}
dev->devt_attr = attr;
......@@ -477,7 +479,8 @@ int device_add(struct device *dev)
if ((error = bus_add_device(dev)))
goto BusError;
kobject_uevent(&dev->kobj, KOBJ_ADD);
bus_attach_device(dev);
if ((error = bus_attach_device(dev)))
goto AttachError;
if (parent)
klist_add_tail(&dev->knode_parent, &parent->klist_children);
......@@ -496,6 +499,8 @@ int device_add(struct device *dev)
kfree(class_name);
put_device(dev);
return error;
AttachError:
bus_remove_device(dev);
BusError:
device_pm_remove(dev);
PMError:
......@@ -507,6 +512,8 @@ int device_add(struct device *dev)
device_remove_file(dev, dev->devt_attr);
kfree(dev->devt_attr);
}
ueventattrError:
device_remove_file(dev, &dev->uevent_attr);
attrError:
kobject_uevent(&dev->kobj, KOBJ_REMOVE);
kobject_del(&dev->kobj);
......@@ -805,8 +812,10 @@ int device_rename(struct device *dev, char *new_name)
if (dev->class) {
old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
if (!old_symlink_name)
return -ENOMEM;
if (!old_symlink_name) {
error = -ENOMEM;
goto out_free_old_class;
}
strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE);
}
......@@ -830,9 +839,10 @@ int device_rename(struct device *dev, char *new_name)
}
put_device(dev);
kfree(old_class_name);
kfree(new_class_name);
kfree(old_symlink_name);
out_free_old_class:
kfree(old_class_name);
return error;
}
......@@ -171,6 +171,8 @@ int driver_probe_device(struct device_driver * drv, struct device * dev)
drv->bus->name, dev->bus_id, drv->name);
data = kmalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->drv = drv;
data->dev = dev;
......@@ -178,7 +180,7 @@ int driver_probe_device(struct device_driver * drv, struct device * dev)
probe_task = kthread_run(really_probe, data,
"probe-%s", dev->bus_id);
if (IS_ERR(probe_task))
ret = PTR_ERR(probe_task);
ret = really_probe(data);
} else
ret = really_probe(data);
......
......@@ -141,11 +141,20 @@ dma_pool_create (const char *name, struct device *dev,
init_waitqueue_head (&retval->waitq);
if (dev) {
int ret;
down (&pools_lock);
if (list_empty (&dev->dma_pools))
device_create_file (dev, &dev_attr_pools);
ret = device_create_file (dev, &dev_attr_pools);
else
ret = 0;
/* note: not currently insisting "name" be unique */
list_add (&retval->pools, &dev->dma_pools);
if (!ret)
list_add (&retval->pools, &dev->dma_pools);
else {
kfree(retval);
retval = NULL;
}
up (&pools_lock);
} else
INIT_LIST_HEAD (&retval->pools);
......
......@@ -97,8 +97,7 @@ static struct attribute_group topology_attr_group = {
/* Add/Remove cpu_topology interface for CPU device */
static int __cpuinit topology_add_dev(struct sys_device * sys_dev)
{
sysfs_create_group(&sys_dev->kobj, &topology_attr_group);
return 0;
return sysfs_create_group(&sys_dev->kobj, &topology_attr_group);
}
static int __cpuinit topology_remove_dev(struct sys_device * sys_dev)
......
......@@ -483,17 +483,12 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
(victim->d_parent->d_inode == dir->d_inode)) {
victim->d_inode->i_mtime = CURRENT_TIME;
fsnotify_modify(victim);
/**
* Drop reference from initial sysfs_get_dentry().
*/
dput(victim);
res = 0;
} else
d_drop(victim);
/**
* Drop the reference acquired from sysfs_get_dentry() above.
* Drop the reference acquired from lookup_one_len() above.
*/
dput(victim);
}
......
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