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

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6:
  devtmpfs: unlock mutex in case of string allocation error
  Driver core: export platform_device_register_data as a GPL symbol
  driver core: Prevent reference to freed memory on error path
  Driver-core: Fix bogus 0 error return in device_add()
  Driver core: driver_attribute parameters can often be const*
  Driver core: bin_attribute parameters can often be const*
  Driver core: device_attribute parameters can often be const*
  Doc/stable rules: add new cherry-pick logic
  vfs: get_sb_single() - do not pass options twice
  devtmpfs: Convert dirlock to a mutex
This commit is contained in:
Linus Torvalds 2009-12-23 13:35:03 -08:00
commit f793067eb9
12 changed files with 72 additions and 40 deletions

View file

@ -226,5 +226,5 @@ struct driver_attribute driver_attr_debug;
This can then be used to add and remove the attribute from the This can then be used to add and remove the attribute from the
driver's directory using: driver's directory using:
int driver_create_file(struct device_driver *, struct driver_attribute *); int driver_create_file(struct device_driver *, const struct driver_attribute *);
void driver_remove_file(struct device_driver *, struct driver_attribute *); void driver_remove_file(struct device_driver *, const struct driver_attribute *);

View file

@ -91,8 +91,8 @@ struct device_attribute {
const char *buf, size_t count); const char *buf, size_t count);
}; };
int device_create_file(struct device *, struct device_attribute *); int device_create_file(struct device *, const struct device_attribute *);
void device_remove_file(struct device *, struct device_attribute *); void device_remove_file(struct device *, const struct device_attribute *);
It also defines this helper for defining device attributes: It also defines this helper for defining device attributes:
@ -316,8 +316,8 @@ DEVICE_ATTR(_name, _mode, _show, _store);
Creation/Removal: Creation/Removal:
int device_create_file(struct device *device, struct device_attribute * attr); int device_create_file(struct device *dev, const struct device_attribute * attr);
void device_remove_file(struct device * dev, struct device_attribute * attr); void device_remove_file(struct device *dev, const struct device_attribute * attr);
- bus drivers (include/linux/device.h) - bus drivers (include/linux/device.h)
@ -358,7 +358,7 @@ DRIVER_ATTR(_name, _mode, _show, _store)
Creation/Removal: Creation/Removal:
int driver_create_file(struct device_driver *, struct driver_attribute *); int driver_create_file(struct device_driver *, const struct driver_attribute *);
void driver_remove_file(struct device_driver *, struct driver_attribute *); void driver_remove_file(struct device_driver *, const struct driver_attribute *);

View file

@ -26,13 +26,33 @@ Procedure for submitting patches to the -stable tree:
- Send the patch, after verifying that it follows the above rules, to - Send the patch, after verifying that it follows the above rules, to
stable@kernel.org. stable@kernel.org.
- To have the patch automatically included in the stable tree, add the
the tag
Cc: stable@kernel.org
in the sign-off area. Once the patch is merged it will be applied to
the stable tree without anything else needing to be done by the author
or subsystem maintainer.
- If the patch requires other patches as prerequisites which can be
cherry-picked than this can be specified in the following format in
the sign-off area:
Cc: <stable@kernel.org> # .32.x: a1f84a3: sched: Check for idle
Cc: <stable@kernel.org> # .32.x: 1b9508f: sched: Rate-limit newidle
Cc: <stable@kernel.org> # .32.x: fd21073: sched: Fix affinity logic
Cc: <stable@kernel.org> # .32.x
Signed-off-by: Ingo Molnar <mingo@elte.hu>
The tag sequence has the meaning of:
git cherry-pick a1f84a3
git cherry-pick 1b9508f
git cherry-pick fd21073
git cherry-pick <this commit>
- The sender will receive an ACK when the patch has been accepted into the - The sender will receive an ACK when the patch has been accepted into the
queue, or a NAK if the patch is rejected. This response might take a few queue, or a NAK if the patch is rejected. This response might take a few
days, according to the developer's schedules. days, according to the developer's schedules.
- If accepted, the patch will be added to the -stable queue, for review by - If accepted, the patch will be added to the -stable queue, for review by
other developers and by the relevant subsystem maintainer. other developers and by the relevant subsystem maintainer.
- If the stable@kernel.org address is added to a patch, when it goes into
Linus's tree it will automatically be emailed to the stable team.
- Security patches should not be sent to this alias, but instead to the - Security patches should not be sent to this alias, but instead to the
documented security@kernel.org address. documented security@kernel.org address.

View file

@ -703,9 +703,9 @@ int bus_add_driver(struct device_driver *drv)
return 0; return 0;
out_unregister: out_unregister:
kobject_put(&priv->kobj);
kfree(drv->p); kfree(drv->p);
drv->p = NULL; drv->p = NULL;
kobject_put(&priv->kobj);
out_put_bus: out_put_bus:
bus_put(bus); bus_put(bus);
return error; return error;

View file

@ -446,7 +446,8 @@ struct kset *devices_kset;
* @dev: device. * @dev: device.
* @attr: device attribute descriptor. * @attr: device attribute descriptor.
*/ */
int device_create_file(struct device *dev, struct device_attribute *attr) int device_create_file(struct device *dev,
const struct device_attribute *attr)
{ {
int error = 0; int error = 0;
if (dev) if (dev)
@ -459,7 +460,8 @@ int device_create_file(struct device *dev, struct device_attribute *attr)
* @dev: device. * @dev: device.
* @attr: device attribute descriptor. * @attr: device attribute descriptor.
*/ */
void device_remove_file(struct device *dev, struct device_attribute *attr) void device_remove_file(struct device *dev,
const struct device_attribute *attr)
{ {
if (dev) if (dev)
sysfs_remove_file(&dev->kobj, &attr->attr); sysfs_remove_file(&dev->kobj, &attr->attr);
@ -470,7 +472,8 @@ void device_remove_file(struct device *dev, struct device_attribute *attr)
* @dev: device. * @dev: device.
* @attr: device binary attribute descriptor. * @attr: device binary attribute descriptor.
*/ */
int device_create_bin_file(struct device *dev, struct bin_attribute *attr) int device_create_bin_file(struct device *dev,
const struct bin_attribute *attr)
{ {
int error = -EINVAL; int error = -EINVAL;
if (dev) if (dev)
@ -484,7 +487,8 @@ EXPORT_SYMBOL_GPL(device_create_bin_file);
* @dev: device. * @dev: device.
* @attr: device binary attribute descriptor. * @attr: device binary attribute descriptor.
*/ */
void device_remove_bin_file(struct device *dev, struct bin_attribute *attr) void device_remove_bin_file(struct device *dev,
const struct bin_attribute *attr)
{ {
if (dev) if (dev)
sysfs_remove_bin_file(&dev->kobj, attr); sysfs_remove_bin_file(&dev->kobj, attr);
@ -905,8 +909,10 @@ int device_add(struct device *dev)
dev->init_name = NULL; dev->init_name = NULL;
} }
if (!dev_name(dev)) if (!dev_name(dev)) {
error = -EINVAL;
goto name_error; goto name_error;
}
pr_debug("device: '%s': %s\n", dev_name(dev), __func__); pr_debug("device: '%s': %s\n", dev_name(dev), __func__);

View file

@ -32,7 +32,7 @@ static int dev_mount = 1;
static int dev_mount; static int dev_mount;
#endif #endif
static rwlock_t dirlock; static DEFINE_MUTEX(dirlock);
static int __init mount_param(char *str) static int __init mount_param(char *str)
{ {
@ -93,7 +93,7 @@ static int create_path(const char *nodepath)
{ {
int err; int err;
read_lock(&dirlock); mutex_lock(&dirlock);
err = dev_mkdir(nodepath, 0755); err = dev_mkdir(nodepath, 0755);
if (err == -ENOENT) { if (err == -ENOENT) {
char *path; char *path;
@ -101,8 +101,10 @@ static int create_path(const char *nodepath)
/* parent directories do not exist, create them */ /* parent directories do not exist, create them */
path = kstrdup(nodepath, GFP_KERNEL); path = kstrdup(nodepath, GFP_KERNEL);
if (!path) if (!path) {
return -ENOMEM; err = -ENOMEM;
goto out;
}
s = path; s = path;
for (;;) { for (;;) {
s = strchr(s, '/'); s = strchr(s, '/');
@ -117,7 +119,8 @@ static int create_path(const char *nodepath)
} }
kfree(path); kfree(path);
} }
read_unlock(&dirlock); out:
mutex_unlock(&dirlock);
return err; return err;
} }
@ -229,7 +232,7 @@ static int delete_path(const char *nodepath)
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
write_lock(&dirlock); mutex_lock(&dirlock);
for (;;) { for (;;) {
char *base; char *base;
@ -241,7 +244,7 @@ static int delete_path(const char *nodepath)
if (err) if (err)
break; break;
} }
write_unlock(&dirlock); mutex_unlock(&dirlock);
kfree(path); kfree(path);
return err; return err;
@ -352,8 +355,6 @@ int __init devtmpfs_init(void)
int err; int err;
struct vfsmount *mnt; struct vfsmount *mnt;
rwlock_init(&dirlock);
err = register_filesystem(&dev_fs_type); err = register_filesystem(&dev_fs_type);
if (err) { if (err) {
printk(KERN_ERR "devtmpfs: unable to register devtmpfs " printk(KERN_ERR "devtmpfs: unable to register devtmpfs "

View file

@ -98,7 +98,7 @@ EXPORT_SYMBOL_GPL(driver_find_device);
* @attr: driver attribute descriptor. * @attr: driver attribute descriptor.
*/ */
int driver_create_file(struct device_driver *drv, int driver_create_file(struct device_driver *drv,
struct driver_attribute *attr) const struct driver_attribute *attr)
{ {
int error; int error;
if (drv) if (drv)
@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(driver_create_file);
* @attr: driver attribute descriptor. * @attr: driver attribute descriptor.
*/ */
void driver_remove_file(struct device_driver *drv, void driver_remove_file(struct device_driver *drv,
struct driver_attribute *attr) const struct driver_attribute *attr)
{ {
if (drv) if (drv)
sysfs_remove_file(&drv->p->kobj, &attr->attr); sysfs_remove_file(&drv->p->kobj, &attr->attr);

View file

@ -441,6 +441,7 @@ error:
platform_device_put(pdev); platform_device_put(pdev);
return ERR_PTR(retval); return ERR_PTR(retval);
} }
EXPORT_SYMBOL_GPL(platform_device_register_data);
static int platform_drv_probe(struct device *_dev) static int platform_drv_probe(struct device *_dev)
{ {

View file

@ -901,8 +901,9 @@ int get_sb_single(struct file_system_type *fs_type,
return error; return error;
} }
s->s_flags |= MS_ACTIVE; s->s_flags |= MS_ACTIVE;
} else {
do_remount_sb(s, flags, data, 0);
} }
do_remount_sb(s, flags, data, 0);
simple_set_mnt(mnt, s); simple_set_mnt(mnt, s);
return 0; return 0;
} }

View file

@ -483,7 +483,8 @@ void unmap_bin_file(struct sysfs_dirent *attr_sd)
* @attr: attribute descriptor. * @attr: attribute descriptor.
*/ */
int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr) int sysfs_create_bin_file(struct kobject *kobj,
const struct bin_attribute *attr)
{ {
BUG_ON(!kobj || !kobj->sd || !attr); BUG_ON(!kobj || !kobj->sd || !attr);
@ -497,7 +498,8 @@ int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
* @attr: attribute descriptor. * @attr: attribute descriptor.
*/ */
void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr) void sysfs_remove_bin_file(struct kobject *kobj,
const struct bin_attribute *attr)
{ {
sysfs_hash_and_remove(kobj->sd, attr->attr.name); sysfs_hash_and_remove(kobj->sd, attr->attr.name);
} }

View file

@ -166,9 +166,9 @@ struct driver_attribute driver_attr_##_name = \
__ATTR(_name, _mode, _show, _store) __ATTR(_name, _mode, _show, _store)
extern int __must_check driver_create_file(struct device_driver *driver, extern int __must_check driver_create_file(struct device_driver *driver,
struct driver_attribute *attr); const struct driver_attribute *attr);
extern void driver_remove_file(struct device_driver *driver, extern void driver_remove_file(struct device_driver *driver,
struct driver_attribute *attr); const struct driver_attribute *attr);
extern int __must_check driver_add_kobj(struct device_driver *drv, extern int __must_check driver_add_kobj(struct device_driver *drv,
struct kobject *kobj, struct kobject *kobj,
@ -319,13 +319,13 @@ struct device_attribute {
struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
extern int __must_check device_create_file(struct device *device, extern int __must_check device_create_file(struct device *device,
struct device_attribute *entry); const struct device_attribute *entry);
extern void device_remove_file(struct device *dev, extern void device_remove_file(struct device *dev,
struct device_attribute *attr); const struct device_attribute *attr);
extern int __must_check device_create_bin_file(struct device *dev, extern int __must_check device_create_bin_file(struct device *dev,
struct bin_attribute *attr); const struct bin_attribute *attr);
extern void device_remove_bin_file(struct device *dev, extern void device_remove_bin_file(struct device *dev,
struct bin_attribute *attr); const struct bin_attribute *attr);
extern int device_schedule_callback_owner(struct device *dev, extern int device_schedule_callback_owner(struct device *dev,
void (*func)(struct device *dev), struct module *owner); void (*func)(struct device *dev), struct module *owner);

View file

@ -99,8 +99,9 @@ int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr,
void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr);
int __must_check sysfs_create_bin_file(struct kobject *kobj, int __must_check sysfs_create_bin_file(struct kobject *kobj,
struct bin_attribute *attr); const struct bin_attribute *attr);
void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr); void sysfs_remove_bin_file(struct kobject *kobj,
const struct bin_attribute *attr);
int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target, int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
const char *name); const char *name);
@ -175,13 +176,13 @@ static inline void sysfs_remove_file(struct kobject *kobj,
} }
static inline int sysfs_create_bin_file(struct kobject *kobj, static inline int sysfs_create_bin_file(struct kobject *kobj,
struct bin_attribute *attr) const struct bin_attribute *attr)
{ {
return 0; return 0;
} }
static inline void sysfs_remove_bin_file(struct kobject *kobj, static inline void sysfs_remove_bin_file(struct kobject *kobj,
struct bin_attribute *attr) const struct bin_attribute *attr)
{ {
} }