Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-cor…
Browse files Browse the repository at this point in the history
…e-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (46 commits)
  UIO: Fix mapping of logical and virtual memory
  UIO: add automata sercos3 pci card support
  UIO: Change driver name of uio_pdrv
  UIO: Add alignment warnings for uio-mem
  Driver core: add bus_sort_breadthfirst() function
  NET: convert the phy_device file to use bus_find_device_by_name
  kobject: Cleanup kobject_rename and !CONFIG_SYSFS
  kobject: Fix kobject_rename and !CONFIG_SYSFS
  sysfs: Make dir and name args to sysfs_notify() const
  platform: add new device registration helper
  sysfs: use ilookup5() instead of ilookup5_nowait()
  PNP: create device attributes via default device attributes
  Driver core: make bus_find_device_by_name() more robust
  usb: turn dev_warn+WARN_ON combos into dev_WARN
  debug: use dev_WARN() rather than WARN_ON() in device_pm_add()
  debug: Introduce a dev_WARN() function
  sysfs: fix deadlock
  device model: Do a quickcheck for driver binding before doing an expensive check
  Driver core: Fix cleanup in device_create_vargs().
  Driver core: Clarify device cleanup.
  ...
  • Loading branch information
torvalds committed Oct 16, 2008
2 parents c8d8a23 + 02683ff commit c813b4e
Show file tree
Hide file tree
Showing 131 changed files with 1,786 additions and 617 deletions.
5 changes: 5 additions & 0 deletions Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,11 @@ and is between 256 and 4096 characters. It is defined in the file
autoconfiguration.
Ranges are in pairs (memory base and size).

dynamic_printk
Enables pr_debug()/dev_dbg() calls if
CONFIG_DYNAMIC_PRINTK_DEBUG has been enabled. These can also
be switched on/off via <debugfs>/dynamic_printk/modules

print-fatal-signals=
[KNL] debug: print fatal signals
print-fatal-signals=1: print segfault info to
Expand Down
4 changes: 4 additions & 0 deletions Documentation/kobject.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ the name of the kobject, call kobject_rename():

int kobject_rename(struct kobject *kobj, const char *new_name);

Note kobject_rename does perform any locking or have a solid notion of
what names are valid so the provide must provide their own sanity checking
and serialization.

There is a function called kobject_set_name() but that is legacy cruft and
is being removed. If your code needs to call this function, it is
incorrect and needs to be fixed.
Expand Down
4 changes: 2 additions & 2 deletions arch/mips/kernel/rtlx.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ static int __init rtlx_module_init(void)
atomic_set(&channel_wqs[i].in_open, 0);
mutex_init(&channel_wqs[i].mutex);

dev = device_create_drvdata(mt_class, NULL, MKDEV(major, i),
NULL, "%s%d", module_name, i);
dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
"%s%d", module_name, i);
if (IS_ERR(dev)) {
err = PTR_ERR(dev);
goto out_chrdev;
Expand Down
3 changes: 1 addition & 2 deletions arch/mips/sibyte/common/sb_tbprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,7 @@ static int __init sbprof_tb_init(void)

tb_class = tbc;

dev = device_create_drvdata(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0),
NULL, "tb");
dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb");
if (IS_ERR(dev)) {
err = PTR_ERR(dev);
goto out_class;
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/kernel/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ static __cpuinit int cpuid_device_create(int cpu)
{
struct device *dev;

dev = device_create_drvdata(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu),
NULL, "cpu%d", cpu);
dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), NULL,
"cpu%d", cpu);
return IS_ERR(dev) ? PTR_ERR(dev) : 0;
}

Expand Down
2 changes: 2 additions & 0 deletions arch/x86/kernel/dumpstack_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/kexec.h>
#include <linux/bug.h>
#include <linux/nmi.h>
#include <linux/sysfs.h>

#include <asm/stacktrace.h>

Expand Down Expand Up @@ -343,6 +344,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
printk("DEBUG_PAGEALLOC");
#endif
printk("\n");
sysfs_printk_last_file();
if (notify_die(DIE_OOPS, str, regs, err,
current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
return 1;
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/kernel/dumpstack_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/kexec.h>
#include <linux/bug.h>
#include <linux/nmi.h>
#include <linux/sysfs.h>

#include <asm/stacktrace.h>

Expand Down Expand Up @@ -489,6 +490,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
printk("DEBUG_PAGEALLOC");
#endif
printk("\n");
sysfs_printk_last_file();
if (notify_die(DIE_OOPS, str, regs, err,
current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
return 1;
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/kernel/msr.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ static int __cpuinit msr_device_create(int cpu)
{
struct device *dev;

dev = device_create_drvdata(msr_class, NULL, MKDEV(MSR_MAJOR, cpu),
NULL, "msr%d", cpu);
dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), NULL,
"msr%d", cpu);
return IS_ERR(dev) ? PTR_ERR(dev) : 0;
}

Expand Down
3 changes: 1 addition & 2 deletions block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,7 @@ int bsg_register_queue(struct request_queue *q, struct device *parent,
bcd->release = release;
kref_init(&bcd->ref);
dev = MKDEV(bsg_major, bcd->minor);
class_dev = device_create_drvdata(bsg_class, parent, dev, NULL,
"%s", devname);
class_dev = device_create(bsg_class, parent, dev, NULL, "%s", devname);
if (IS_ERR(class_dev)) {
ret = PTR_ERR(class_dev);
goto put_dev;
Expand Down
54 changes: 51 additions & 3 deletions drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,7 @@ static int match_name(struct device *dev, void *data)
{
const char *name = data;

if (strcmp(name, dev->bus_id) == 0)
return 1;
return 0;
return sysfs_streq(name, dev->bus_id);
}

/**
Expand Down Expand Up @@ -982,6 +980,56 @@ struct klist *bus_get_device_klist(struct bus_type *bus)
}
EXPORT_SYMBOL_GPL(bus_get_device_klist);

/*
* Yes, this forcably breaks the klist abstraction temporarily. It
* just wants to sort the klist, not change reference counts and
* take/drop locks rapidly in the process. It does all this while
* holding the lock for the list, so objects can't otherwise be
* added/removed while we're swizzling.
*/
static void device_insertion_sort_klist(struct device *a, struct list_head *list,
int (*compare)(const struct device *a,
const struct device *b))
{
struct list_head *pos;
struct klist_node *n;
struct device *b;

list_for_each(pos, list) {
n = container_of(pos, struct klist_node, n_node);
b = container_of(n, struct device, knode_bus);
if (compare(a, b) <= 0) {
list_move_tail(&a->knode_bus.n_node,
&b->knode_bus.n_node);
return;
}
}
list_move_tail(&a->knode_bus.n_node, list);
}

void bus_sort_breadthfirst(struct bus_type *bus,
int (*compare)(const struct device *a,
const struct device *b))
{
LIST_HEAD(sorted_devices);
struct list_head *pos, *tmp;
struct klist_node *n;
struct device *dev;
struct klist *device_klist;

device_klist = bus_get_device_klist(bus);

spin_lock(&device_klist->k_lock);
list_for_each_safe(pos, tmp, &device_klist->k_list) {
n = container_of(pos, struct klist_node, n_node);
dev = container_of(n, struct device, knode_bus);
device_insertion_sort_klist(dev, &sorted_devices, compare);
}
list_splice(&sorted_devices, &device_klist->k_list);
spin_unlock(&device_klist->k_lock);
}
EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);

int __init buses_init(void)
{
bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL);
Expand Down
30 changes: 24 additions & 6 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,16 @@ static void klist_children_put(struct klist_node *n)
* device_initialize - init device structure.
* @dev: device.
*
* This prepares the device for use by other layers,
* including adding it to the device hierarchy.
* This prepares the device for use by other layers by initializing
* its fields.
* It is the first half of device_register(), if called by
* that, though it can also be called separately, so one
* may use @dev's fields (e.g. the refcount).
* that function, though it can also be called separately, so one
* may use @dev's fields. In particular, get_device()/put_device()
* may be used for reference counting of @dev after calling this
* function.
*
* NOTE: Use put_device() to give up your reference instead of freeing
* @dev directly once you have called this function.
*/
void device_initialize(struct device *dev)
{
Expand Down Expand Up @@ -835,9 +840,13 @@ static void device_remove_sys_dev_entry(struct device *dev)
* This is part 2 of device_register(), though may be called
* separately _iff_ device_initialize() has been called separately.
*
* This adds it to the kobject hierarchy via kobject_add(), adds it
* This adds @dev to the kobject hierarchy via kobject_add(), adds it
* to the global and sibling lists for the device, then
* adds it to the other relevant subsystems of the driver model.
*
* NOTE: _Never_ directly free @dev after calling this function, even
* if it returned an error! Always use put_device() to give up your
* reference instead.
*/
int device_add(struct device *dev)
{
Expand Down Expand Up @@ -965,6 +974,10 @@ int device_add(struct device *dev)
* I.e. you should only call the two helpers separately if
* have a clearly defined need to use and refcount the device
* before it is added to the hierarchy.
*
* NOTE: _Never_ directly free @dev after calling this function, even
* if it returned an error! Always use put_device() to give up the
* reference initialized in this function instead.
*/
int device_register(struct device *dev)
{
Expand Down Expand Up @@ -1243,7 +1256,7 @@ struct device *device_create_vargs(struct class *class, struct device *parent,
return dev;

error:
kfree(dev);
put_device(dev);
return ERR_PTR(retval);
}
EXPORT_SYMBOL_GPL(device_create_vargs);
Expand Down Expand Up @@ -1314,6 +1327,11 @@ EXPORT_SYMBOL_GPL(device_destroy);
* device_rename - renames a device
* @dev: the pointer to the struct device to be renamed
* @new_name: the new name of the device
*
* It is the responsibility of the caller to provide mutual
* exclusion between two different calls of device_rename
* on the same device to ensure that new_name is valid and
* won't conflict with other devices.
*/
int device_rename(struct device *dev, char *new_name)
{
Expand Down
3 changes: 3 additions & 0 deletions drivers/base/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ static int __driver_attach(struct device *dev, void *data)
* is an error.
*/

if (drv->bus->match && !drv->bus->match(dev, drv))
return 0;

if (dev->parent) /* Needed for USB */
down(&dev->parent->sem);
down(&dev->sem);
Expand Down
49 changes: 48 additions & 1 deletion drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,53 @@ struct platform_device *platform_device_register_simple(const char *name,
}
EXPORT_SYMBOL_GPL(platform_device_register_simple);

/**
* platform_device_register_data
* @parent: parent device for the device we're adding
* @name: base name of the device we're adding
* @id: instance id
* @data: platform specific data for this platform device
* @size: size of platform specific data
*
* This function creates a simple platform device that requires minimal
* resource and memory management. Canned release function freeing memory
* allocated for the device allows drivers using such devices to be
* unloaded without waiting for the last reference to the device to be
* dropped.
*/
struct platform_device *platform_device_register_data(
struct device *parent,
const char *name, int id,
const void *data, size_t size)
{
struct platform_device *pdev;
int retval;

pdev = platform_device_alloc(name, id);
if (!pdev) {
retval = -ENOMEM;
goto error;
}

pdev->dev.parent = parent;

if (size) {
retval = platform_device_add_data(pdev, data, size);
if (retval)
goto error;
}

retval = platform_device_add(pdev);
if (retval)
goto error;

return pdev;

error:
platform_device_put(pdev);
return ERR_PTR(retval);
}

static int platform_drv_probe(struct device *_dev)
{
struct platform_driver *drv = to_platform_driver(_dev->driver);
Expand Down Expand Up @@ -865,7 +912,7 @@ static int platform_pm_restore_noirq(struct device *dev)

#endif /* !CONFIG_HIBERNATION */

struct pm_ext_ops platform_pm_ops = {
static struct pm_ext_ops platform_pm_ops = {
.base = {
.prepare = platform_pm_prepare,
.complete = platform_pm_complete,
Expand Down
2 changes: 1 addition & 1 deletion drivers/base/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void device_pm_add(struct device *dev)
* transition is in progress in order to avoid leaving them
* unhandled down the road
*/
WARN_ON(true);
dev_WARN(dev, "Parentless device registered during a PM transaction\n");
}

list_add_tail(&dev->power.entry, &dpm_list);
Expand Down
6 changes: 3 additions & 3 deletions drivers/block/aoe/aoechr.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ aoechr_init(void)
return PTR_ERR(aoe_class);
}
for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
device_create_drvdata(aoe_class, NULL,
MKDEV(AOE_MAJOR, chardevs[i].minor),
NULL, chardevs[i].name);
device_create(aoe_class, NULL,
MKDEV(AOE_MAJOR, chardevs[i].minor), NULL,
chardevs[i].name);

return 0;
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/block/paride/pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,8 @@ static int __init pg_init(void)
for (unit = 0; unit < PG_UNITS; unit++) {
struct pg *dev = &devices[unit];
if (dev->present)
device_create_drvdata(pg_class, NULL,
MKDEV(major, unit), NULL,
"pg%u", unit);
device_create(pg_class, NULL, MKDEV(major, unit), NULL,
"pg%u", unit);
}
err = 0;
goto out;
Expand Down
10 changes: 4 additions & 6 deletions drivers/block/paride/pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,12 +979,10 @@ static int __init pt_init(void)

for (unit = 0; unit < PT_UNITS; unit++)
if (pt[unit].present) {
device_create_drvdata(pt_class, NULL,
MKDEV(major, unit), NULL,
"pt%d", unit);
device_create_drvdata(pt_class, NULL,
MKDEV(major, unit + 128), NULL,
"pt%dn", unit);
device_create(pt_class, NULL, MKDEV(major, unit), NULL,
"pt%d", unit);
device_create(pt_class, NULL, MKDEV(major, unit + 128),
NULL, "pt%dn", unit);
}
goto out;

Expand Down
5 changes: 2 additions & 3 deletions drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,8 @@ static struct kobj_type kobj_pkt_type_wqueue = {
static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
{
if (class_pktcdvd) {
pd->dev = device_create_drvdata(class_pktcdvd, NULL,
pd->pkt_dev, NULL,
"%s", pd->name);
pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, NULL,
"%s", pd->name);
if (IS_ERR(pd->dev))
pd->dev = NULL;
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/char/bsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,8 @@ static int bsr_create_devs(struct device_node *bn)
if (result)
goto out_err;

cur->bsr_device = device_create_drvdata(bsr_class, NULL,
cur->bsr_dev,
cur, cur->bsr_name);
cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev,
cur, cur->bsr_name);
if (!cur->bsr_device) {
printk(KERN_ERR "device_create failed for %s\n",
cur->bsr_name);
Expand Down
Loading

0 comments on commit c813b4e

Please sign in to comment.