Commit 0a962657 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'driver-core-3.3-rc1-bugfixes' of...

Merge tag 'driver-core-3.3-rc1-bugfixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Here are some patches for the 3.3-rc1 tree.

It contains the removal of the sysdev code, now that all users of it are
gone, as well as some sysfs bugfixes that have been reported by users.
There are also some documentation updates here as well.

* tag 'driver-core-3.3-rc1-bugfixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
  sysfs: Complain bitterly about attempts to remove files from nonexistent directories.
  stable: update documentation to ask for kernel version
  base/core.c:fix typo in comment in function device_add
  Documentation: devres: add allocation functions to list of supported calls
  Documentation update for the driver model core
  kernel-doc: fix new warnings in driver-core
  kernel-doc: fix new warnings in debugfs
  kernel-doc: fix new warnings in device.h
  driver core: remove drivers/base/sys.c and include/linux/sysdev.h
parents e3b8369c ce597919
...@@ -233,6 +233,10 @@ certainly invest a bit more effort into libata core layer). ...@@ -233,6 +233,10 @@ certainly invest a bit more effort into libata core layer).
6. List of managed interfaces 6. List of managed interfaces
----------------------------- -----------------------------
MEM
devm_kzalloc()
devm_kfree()
IO region IO region
devm_request_region() devm_request_region()
devm_request_mem_region() devm_request_mem_region()
......
...@@ -25,7 +25,8 @@ Procedure for submitting patches to the -stable tree: ...@@ -25,7 +25,8 @@ 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@vger.kernel.org. You must note the upstream commit ID in the stable@vger.kernel.org. You must note the upstream commit ID in the
changelog of your submission. changelog of your submission, as well as the kernel version you wish
it to be applied to.
- To have the patch automatically included in the stable tree, add the tag - To have the patch automatically included in the stable tree, add the tag
Cc: stable@vger.kernel.org Cc: stable@vger.kernel.org
in the sign-off area. Once the patch is merged it will be applied to in the sign-off area. Once the patch is merged it will be applied to
......
# Makefile for the Linux device tree # Makefile for the Linux device tree
obj-y := core.o sys.o bus.o dd.o syscore.o \ obj-y := core.o bus.o dd.o syscore.o \
driver.o class.o platform.o \ driver.o class.o platform.o \
cpu.o firmware.o init.o map.o devres.o \ cpu.o firmware.o init.o map.o devres.o \
attribute_container.o transport_class.o \ attribute_container.o transport_class.o \
......
...@@ -632,6 +632,11 @@ static void klist_children_put(struct klist_node *n) ...@@ -632,6 +632,11 @@ static void klist_children_put(struct klist_node *n)
* may be used for reference counting of @dev after calling this * may be used for reference counting of @dev after calling this
* function. * function.
* *
* All fields in @dev must be initialized by the caller to 0, except
* for those explicitly set to some other value. The simplest
* approach is to use kzalloc() to allocate the structure containing
* @dev.
*
* NOTE: Use put_device() to give up your reference instead of freeing * NOTE: Use put_device() to give up your reference instead of freeing
* @dev directly once you have called this function. * @dev directly once you have called this function.
*/ */
...@@ -930,6 +935,13 @@ int device_private_init(struct device *dev) ...@@ -930,6 +935,13 @@ int device_private_init(struct device *dev)
* to the global and sibling lists for the device, then * to the global and sibling lists for the device, then
* adds it to the other relevant subsystems of the driver model. * adds it to the other relevant subsystems of the driver model.
* *
* Do not call this routine or device_register() more than once for
* any device structure. The driver model core is not designed to work
* with devices that get unregistered and then spring back to life.
* (Among other things, it's very hard to guarantee that all references
* to the previous incarnation of @dev have been dropped.) Allocate
* and register a fresh new struct device instead.
*
* NOTE: _Never_ directly free @dev after calling this function, even * NOTE: _Never_ directly free @dev after calling this function, even
* if it returned an error! Always use put_device() to give up your * if it returned an error! Always use put_device() to give up your
* reference instead. * reference instead.
...@@ -1022,7 +1034,7 @@ int device_add(struct device *dev) ...@@ -1022,7 +1034,7 @@ int device_add(struct device *dev)
device_pm_add(dev); device_pm_add(dev);
/* Notify clients of device addition. This call must come /* Notify clients of device addition. This call must come
* after dpm_sysf_add() and before kobject_uevent(). * after dpm_sysfs_add() and before kobject_uevent().
*/ */
if (dev->bus) if (dev->bus)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier, blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
...@@ -1090,6 +1102,9 @@ int device_add(struct device *dev) ...@@ -1090,6 +1102,9 @@ int device_add(struct device *dev)
* have a clearly defined need to use and refcount the device * have a clearly defined need to use and refcount the device
* before it is added to the hierarchy. * before it is added to the hierarchy.
* *
* For more information, see the kerneldoc for device_initialize()
* and device_add().
*
* NOTE: _Never_ directly free @dev after calling this function, even * NOTE: _Never_ directly free @dev after calling this function, even
* if it returned an error! Always use put_device() to give up the * if it returned an error! Always use put_device() to give up the
* reference initialized in this function instead. * reference initialized in this function instead.
......
This diff is collapsed.
...@@ -493,6 +493,12 @@ int sysfs_attr_ns(struct kobject *kobj, const struct attribute *attr, ...@@ -493,6 +493,12 @@ int sysfs_attr_ns(struct kobject *kobj, const struct attribute *attr,
const void *ns = NULL; const void *ns = NULL;
int err; int err;
if (!dir_sd) {
WARN(1, KERN_ERR "sysfs: kobject %s without dirent\n",
kobject_name(kobj));
return -ENOENT;
}
err = 0; err = 0;
if (!sysfs_ns_type(dir_sd)) if (!sysfs_ns_type(dir_sd))
goto out; goto out;
......
...@@ -318,8 +318,11 @@ int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const cha ...@@ -318,8 +318,11 @@ int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const cha
struct sysfs_addrm_cxt acxt; struct sysfs_addrm_cxt acxt;
struct sysfs_dirent *sd; struct sysfs_dirent *sd;
if (!dir_sd) if (!dir_sd) {
WARN(1, KERN_WARNING "sysfs: can not remove '%s', no directory\n",
name);
return -ENOENT; return -ENOENT;
}
sysfs_addrm_start(&acxt, dir_sd); sysfs_addrm_start(&acxt, dir_sd);
......
/**
* System devices follow a slightly different driver model.
* They don't need to do dynammic driver binding, can't be probed,
* and don't reside on any type of peripheral bus.
* So, we represent and treat them a little differently.
*
* We still have a notion of a driver for a system device, because we still
* want to perform basic operations on these devices.
*
* We also support auxiliary drivers binding to devices of a certain class.
*
* This allows configurable drivers to register themselves for devices of
* a certain type. And, it allows class definitions to reside in generic
* code while arch-specific code can register specific drivers.
*
* Auxiliary drivers registered with a NULL cls are registered as drivers
* for all system devices, and get notification calls for each device.
*/
#ifndef _SYSDEV_H_
#define _SYSDEV_H_
#include <linux/kobject.h>
#include <linux/pm.h>
struct sys_device;
struct sysdev_class_attribute;
struct sysdev_class {
const char *name;
struct list_head drivers;
struct sysdev_class_attribute **attrs;
struct kset kset;
};
struct sysdev_class_attribute {
struct attribute attr;
ssize_t (*show)(struct sysdev_class *, struct sysdev_class_attribute *,
char *);
ssize_t (*store)(struct sysdev_class *, struct sysdev_class_attribute *,
const char *, size_t);
};
#define _SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \
{ \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.show = _show, \
.store = _store, \
}
#define SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \
struct sysdev_class_attribute attr_##_name = \
_SYSDEV_CLASS_ATTR(_name,_mode,_show,_store)
extern int sysdev_class_register(struct sysdev_class *);
extern void sysdev_class_unregister(struct sysdev_class *);
extern int sysdev_class_create_file(struct sysdev_class *,
struct sysdev_class_attribute *);
extern void sysdev_class_remove_file(struct sysdev_class *,
struct sysdev_class_attribute *);
/**
* Auxiliary system device drivers.
*/
struct sysdev_driver {
struct list_head entry;
int (*add)(struct sys_device *);
int (*remove)(struct sys_device *);
};
extern int sysdev_driver_register(struct sysdev_class *, struct sysdev_driver *);
extern void sysdev_driver_unregister(struct sysdev_class *, struct sysdev_driver *);
/**
* sys_devices can be simplified a lot from regular devices, because they're
* simply not as versatile.
*/
struct sys_device {
u32 id;
struct sysdev_class * cls;
struct kobject kobj;
};
extern int sysdev_register(struct sys_device *);
extern void sysdev_unregister(struct sys_device *);
struct sysdev_attribute {
struct attribute attr;
ssize_t (*show)(struct sys_device *, struct sysdev_attribute *, char *);
ssize_t (*store)(struct sys_device *, struct sysdev_attribute *,
const char *, size_t);
};
#define _SYSDEV_ATTR(_name, _mode, _show, _store) \
{ \
.attr = { .name = __stringify(_name), .mode = _mode }, \
.show = _show, \
.store = _store, \
}
#define SYSDEV_ATTR(_name, _mode, _show, _store) \
struct sysdev_attribute attr_##_name = \
_SYSDEV_ATTR(_name, _mode, _show, _store);
extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *);
extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *);
/* Create/remove NULL terminated attribute list */
static inline int
sysdev_create_files(struct sys_device *d, struct sysdev_attribute **a)
{
return sysfs_create_files(&d->kobj, (const struct attribute **)a);
}
static inline void
sysdev_remove_files(struct sys_device *d, struct sysdev_attribute **a)
{
return sysfs_remove_files(&d->kobj, (const struct attribute **)a);
}
struct sysdev_ext_attribute {
struct sysdev_attribute attr;
void *var;
};
/*
* Support for simple variable sysdev attributes.
* The pointer to the variable is stored in a sysdev_ext_attribute
*/
/* Add more types as needed */
extern ssize_t sysdev_show_ulong(struct sys_device *, struct sysdev_attribute *,
char *);
extern ssize_t sysdev_store_ulong(struct sys_device *,
struct sysdev_attribute *, const char *, size_t);
extern ssize_t sysdev_show_int(struct sys_device *, struct sysdev_attribute *,
char *);
extern ssize_t sysdev_store_int(struct sys_device *,
struct sysdev_attribute *, const char *, size_t);
#define _SYSDEV_ULONG_ATTR(_name, _mode, _var) \
{ _SYSDEV_ATTR(_name, _mode, sysdev_show_ulong, sysdev_store_ulong), \
&(_var) }
#define SYSDEV_ULONG_ATTR(_name, _mode, _var) \
struct sysdev_ext_attribute attr_##_name = \
_SYSDEV_ULONG_ATTR(_name, _mode, _var);
#define _SYSDEV_INT_ATTR(_name, _mode, _var) \
{ _SYSDEV_ATTR(_name, _mode, sysdev_show_int, sysdev_store_int), \
&(_var) }
#define SYSDEV_INT_ATTR(_name, _mode, _var) \
struct sysdev_ext_attribute attr_##_name = \
_SYSDEV_INT_ATTR(_name, _mode, _var);
#endif /* _SYSDEV_H_ */
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