aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2007-02-09devres: device resource managementTejun Heo1-0/+2
Implement device resource management, in short, devres. A device driver can allocate arbirary size of devres data which is associated with a release function. On driver detach, release function is invoked on the devres data, then, devres data is freed. devreses are typed by associated release functions. Some devreses are better represented by single instance of the type while others need multiple instances sharing the same release function. Both usages are supported. devreses can be grouped using devres group such that a device driver can easily release acquired resources halfway through initialization or selectively release resources (e.g. resources for port 1 out of 4 ports). This patch adds devres core including documentation and the following managed interfaces. * alloc/free : devm_kzalloc(), devm_kzfree() * IO region : devm_request_region(), devm_release_region() * IRQ : devm_request_irq(), devm_free_irq() * DMA : dmam_alloc_coherent(), dmam_free_coherent(), dmam_declare_coherent_memory(), dmam_pool_create(), dmam_pool_destroy() * PCI : pcim_enable_device(), pcim_pin_device(), pci_is_managed() * iomap : devm_ioport_map(), devm_ioport_unmap(), devm_ioremap(), devm_ioremap_nocache(), devm_iounmap(), pcim_iomap_table(), pcim_iomap(), pcim_iounmap() Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-02-07Driver core: allow to delay the uevent at device creation timeKay Sievers1-1/+2
For the block subsystem, we want to delay all uevents until the disk has been scanned and allpartitons are already created before the first event is sent out. Signed-off-by: Kay Sievers <kay.sievers@novell.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-02-07Driver core: add device_type to struct deviceKay Sievers1-18/+39
This allows us to add type specific attributes, uevent vars and release funtions. A subsystem can carry different types of devices like the "block" subsys has disks and partitions. Both types create a different set of attributes, but belong to the same subsystem. This corresponds to the low level objects: kobject -> device (object/device data) kobj_type -> device_type (type of object/device we are embedded in) kset -> class/bus (list of objects/devices of a subsystem) Signed-off-by: Kay Sievers <kay.sievers@novell.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-02-07Driver core: add uevent vars for devices of a classKay Sievers1-12/+34
Devices converted from class_device to device should have the same uevent keys as the original class_device had. We search up the parents until we find the first bus device and add the (already deprecated) PHYDEV* values. Signed-off-by: Kay Sievers <kay.sievers@novell.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-02-07driver core fixes: make_class_name() retval checksCornelia Huck1-6/+11
Make make_class_name() return NULL on error and fixup callers in the driver core. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-02-07driver core: Allow device_move(dev, NULL).Cornelia Huck1-29/+47
If we allow NULL as the new parent in device_move(), we need to make sure that the device is placed into the same place as it would if it was newly registered: - Consider the device virtual tree. In order to be able to reuse code, setup_parent() has been tweaked a bit. - kobject_move() can fall back to the kset's kobject. - sysfs_move_dir() uses the sysfs root dir as fallback. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-02-07driver core: Remove device_is_registered() in device_move().Cornelia Huck1-4/+0
device_is_registered() will always be false for a device with no bus. Remove this check and trust the caller to know what they're doing. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-07[PATCH] add numa node information to struct deviceChristoph Hellwig1-0/+1
For node-aware skb allocations we need information about the node in struct net_device or struct device. Davem suggested to put it into struct device which this patch does. In particular: - struct device gets a new int numa_node member if CONFIG_NUMA is set - there are two new helpers, dev_to_node and set_dev_node to transparently deal with the non-numa case - for pci devices the node-info is set to the value we get from pcibus_to_node. Note that for some architectures pcibus_to_node doesn't work yet at the time we call it currently. This is harmless and will just mean skb allocations aren't node-local on this architectures until the implementation of pcibus_to_node on these architectures have been updated (There are patches for x86 and x86_64 floating around) [akpm@osdl.org: cleanup] Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Christoph Lameter <clameter@engr.sgi.com> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-01driver core: Use klist_remove() in device_move()Cornelia Huck1-2/+2
As pointed out by Alan Stern, device_move needs to use klist_remove which waits until removal is complete. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-01driver core: Introduce device_move(): move a device to a new parent.Cornelia Huck1-0/+92
Provide a function device_move() to move a device to a new parent device. Add auxilliary functions kobject_move() and sysfs_move_dir(). kobject_move() generates a new uevent of type KOBJ_MOVE, containing the previous path (DEVPATH_OLD) in addition to the usual values. For this, a new interface kobject_uevent_env() is created that allows to add further environmental data to the uevent at the kobject layer. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-01Driver core: make drivers/base/core.c:setup_parent() staticAdrian Bunk1-2/+2
This patch makes the needlessly global setup_parent() static. Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-01driver core: Introduce device_find_child().Cornelia Huck1-0/+33
Introduce device_find_child() to match device_for_each_child(). Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-01Driver core: Call platform_notify_remove laterBenjamin Herrenschmidt1-1/+1
Move the call to platform_notify_remove() to after the call to bus_remove_device(), where it belongs. It's bogus to notify the platform of removal while drivers are still attached to the device and possibly still operating since the platform might use this callback to tear down some resources used by the driver (ACPI bits, iommu table, ...) Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: "Brown, Len" <len.brown@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-01CONFIG_SYSFS_DEPRECATED - PHYSDEV* uevent variablesKay Sievers1-0/+4
Disable the PHYSDEV* uevent variables if CONFIG_SYSFS_DEPRECATED is enabled. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-01CONFIG_SYSFS_DEPRECATED - device symlinksKay Sievers1-4/+14
Turn off device symlinks CONFIG_SYSFS_DEPRECATED is enabled. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-01Driver core: make old versions of udev work properlyGreg Kroah-Hartman1-14/+45
If CONFIG_SYSFS_DEPRECATED is enabled, old versions of udev will work properly with devices that are associated with a class. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-01Driver Core: Move virtual_device_parent() to core.cGreg Kroah-Hartman1-0/+17
It doesn't need to be global or in device.h Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-12-01Driver core: add notification of bus eventsBenjamin Herrenschmidt1-0/+12
I finally did as you suggested and added the notifier to the struct bus_type itself. There are still problems to be expected is something attaches to a bus type where the code can hook in different struct device sub-classes (which is imho a big bogosity but I won't even try to argue that case now) but it will solve nicely a number of issues I've had so far. That also means that clients interested in registering for such notifications have to do it before devices are added and after bus types are registered. Fortunately, most bus types that matter for the various usage scenarios I have in mind are registerd at postcore_initcall time, which means I have a really nice spot at arch_initcall time to add my notifiers. There are 4 notifications provided. Device being added (before hooked to the bus) and removed (failure of previous case or after being unhooked from the bus), along with driver being bound to a device and about to be unbound. The usage I have for these are: - The 2 first ones are used to maintain a struct device_ext that is hooked to struct device.firmware_data. This structure contains for now a pointer to the Open Firmware node related to the device (if any), the NUMA node ID (for quick access to it) and the DMA operations pointers & iommu table instance for DMA to/from this device. For bus types I own (like IBM VIO or EBUS), I just maintain that structure directly from the bus code when creating the devices. But for bus types managed by generic code like PCI or platform (actually, of_platform which is a variation of platform linked to Open Firmware device-tree), I need this notifier. - The other two ones have a completely different usage scenario. I have cases where multiple devices and their drivers depend on each other. For example, the IBM EMAC network driver needs to attach to a MAL DMA engine which is a separate device, and a PHY interface which is also a separate device. They are all of_platform_device's (well, about to be with my upcoming patches) but there is no say in what precise order the core will "probe" them and instanciate the various modules. The solution I found for that is to have the drivers for emac to use multithread_probe, and wait for a driver to be bound to the target MAL and PHY control devices (the device-tree contains reference to the MAL and PHY interface nodes, which I can then match to of_platform_devices). Right now, I've been polling, but with that notifier, I can more cleanly wait (with a timeout of course). Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-11-25[PATCH] Fix device_attribute memory leak in device_delCatalin Marinas1-1/+3
dev->devt_attr is allocated in device_add() but it is never freed in device_del() in the drivers/base/core.c file (reported by kmemleak). Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com> Acked-by: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-10-18Driver core: Don't ignore error returns from probingAlan Stern1-1/+4
This patch (as797) fixes device_add() in the driver core. It needs to pay attention when the driver for a new device reports an error. At the same time, since bus_remove_device() undoes the effects of both bus_add_device() and bus_attach_device(), it needs to check whether the bus_attach_device step failed. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-10-18Driver core: Don't leak 'old_class_name' in drivers/base/core.c::device_rename()Jesper Juhl1-3/+6
If kmalloc() fails to allocate space for 'old_symlink_name' in drivers/base/core.c::device_rename(), then we'll leak 'old_class_name'. Spotted by the Coverity checker. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-10-18driver core fixes: device_add() cleanup on errorCornelia Huck1-3/+7
Check for return code of device_create_file() and correct cleanup in the error case in device_add(). Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-10-18Fix dev_printk() is now GPL-onlyMatthew Wilcox1-1/+1
Make dev_printk usable from non-GPL modules again dev_printk now calls dev_driver_string. We want even proprietary modules to be calling dev_printk, so the export of dev_driver_string needs to be non-GPL-only. Signed-off-by: Matthew Wilcox <matthew@wil.cx> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25drivers/base: Platform notify needs to occur before drivers attach to the deviceBrian Walsh1-4/+4
The platform_notify call for Arm and PPC architectures needs to be called before the driver attaches to the device. The problem only presents itself when hotplugging certain devices while the driver is already loaded. Signed-off-by: Brian Walsh <brian@walsh.ws> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25Driver core: add ability for devices to create and remove bin filesGreg Kroah-Hartman1-0/+26
Makes it easier for devices to create and remove binary attribute files so they don't have to call directly into sysfs. This is needed to help with the conversion from struct class_device to struct device. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25Class: add support for class interfaces for devicesGreg Kroah-Hartman1-1/+13
When moving class_device usage over to device, we need to handle class_interfaces properly with devices. This patch adds that support. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25Driver core: create devices/virtual/ treeGreg Kroah-Hartman1-0/+7
This change creates a devices/virtual/CLASS_NAME tree for struct devices that belong to a class, yet do not have a "real" struct device for a parent. It automatically creates the directories on the fly as needed. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25Driver core: add device_rename functionGreg Kroah-Hartman1-0/+55
The network layer needs this to convert to using struct device instead of a struct class_device. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25Driver core: add ability for classes to handle devices properlyGreg Kroah-Hartman1-0/+53
This adds two new callbacks to the class structure: int (*dev_uevent)(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); void (*dev_release)(struct device *dev); And one pointer: struct device_attribute * dev_attrs; which all corrispond with the same thing as the "normal" class devices do, yet this is for when a struct device is bound to a class. Someday soon, struct class_device will go away, and then the other fields in this structure can be removed too. But this is necessary in order to get the transition to work properly. Tested out on a network core patch that converted it to use struct device instead of struct class_device. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25Driver core: allow devices in classes to have no parentGreg Kroah-Hartman1-10/+11
This fixes an oops when a device is attached to a class, yet has no "parent" device. An example of this would be the "lo" device in the network core. We should create a "virtual" subdirectory under /sys/devices/ for these, but no one seems to agree on a proper name for it yet... Oh, and update my copyright on the driver core. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25Driver core: add groups support to struct deviceGreg Kroah-Hartman1-0/+34
This is needed for the network class devices in order to be able to convert over to use struct device. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25device_create(): make fmt argument 'const char *'Greg Kroah-Hartman1-1/+1
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25deprecate PHYSDEV* keysKay Sievers1-3/+7
deprecate PHYSDEV* values in the uevent environment These values are no longer needed and inconsistent with the stacking of class devices. The event environment should not carry properties of a parent device. The key PHYSDEVDRIVER is available as DRIVER, PHYDEVBUS is indentical SUBSYSTEM. Class devices should not carry any of these values. Signed-off-by: Kay Sievers <kay.sievers@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-07-12[PATCH] Driver core: kernel-doc in drivers/base/core.c correctionsHenrik Kretzschmar1-15/+15
Corrects the kerneldocs for device_create() and device_destroy() with an eye on coding style, grammar and readability. Signed-off-by: Henrik Kretzschmar <henne@nachtwindheim.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-07-12[PATCH] Driver core: fix driver-core kernel-docRandy Dunlap1-3/+3
Warning(/var/linsrc/linux-2617-g4//drivers/base/core.c:574): No description found for parameter 'class' Warning(/var/linsrc/linux-2617-g4//drivers/base/core.c:574): No description found for parameter 'devt' Warning(/var/linsrc/linux-2617-g4//drivers/base/core.c:626): No description found for parameter 'devt' Signed-off-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-06-30Remove obsolete #include <linux/config.h>Jörn Engel1-1/+0
Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de> Signed-off-by: Adrian Bunk <bunk@stusta.de>
2006-06-22[PATCH] Driver core: fix locking issues with the devices that are attached to classesGreg Kroah-Hartman1-8/+11
Doh, that was foolish... Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-06-21[PATCH] Driver Core: Make dev_info and friends print the bus name if there is no driverAlan Stern1-0/+16
This patch (as721) makes dev_info and related macros print the device's bus name if the device doesn't have a driver, instead of printing just a blank. If the device isn't on a bus either... well, then it does leave a blank space. But it will be easier for someone else to change if they want. Cc: Matthew Wilcox <matthew@wil.cx> Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-06-21[PATCH] Driver core: add proper symlinks for devicesGreg Kroah-Hartman1-0/+11
We need to create the "compatible" symlinks that class_devices used to create when they were in the class directories so that userspace does not know anything changed at all. Yeah, we have a lot of symlinks now, but we should be able to get rid of them in a year or two... (wishful thinking...) Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-06-21[PATCH] Driver core: add generic "subsystem" link to all devicesKay Sievers1-2/+7
Like the SUBSYTEM= key we find in the environment of the uevent, this creates a generic "subsystem" link in sysfs for every device. Userspace usually doesn't care at all if its a "class" or a "bus" device. This provides an unified way to determine the subsytem of a device, regardless of the way the driver core has created it. Signed-off-by: Kay Sievers <kay.sievers@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-06-21[PATCH] Driver core: allow struct device to have a dev_tGreg Kroah-Hartman1-1/+161
This is the first step in moving class_device to being replaced by struct device. It allows struct device to export a dev_t and makes it easy to dynamically create and destroy struct device as long as they are associated with a specific class. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-06-21[PATCH] Driver core: bus device event delayKay Sievers1-1/+2
split bus_add_device() and send device uevents after sysfs population Signed-off-by: Kay Sievers <kay.sievers@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-01-10[PATCH] DocBook: fix kernel-doc commentsMartin Waitz1-2/+2
Fix typos in comments to remove kernel-doc warnings. Signed-off-by: Martin Waitz <tali@admingilde.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-04[PATCH] driver core: replace "hotplug" by "uevent"Kay Sievers1-21/+21
Leave the overloaded "hotplug" word to susbsystems which are handling real devices. The driver core does not "plug" anything, it just exports the state to userspace and generates events. Signed-off-by: Kay Sievers <kay.sievers@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-10-28[PATCH] kernel-doc: drivers/base fixesRandy Dunlap1-2/+2
driver/base: add missing function parameters; eliminate all warnings. Signed-off-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-10-28[PATCH] add sysfs attr to re-emit device hotplug eventKay Sievers1-0/+16
A "coldplug + udevstart" can be simple like this: for i in /sys/block/*/*/uevent; do echo 1 > $i; done for i in /sys/class/*/*/uevent; do echo 1 > $i; done for i in /sys/bus/*/devices/*/uevent; do echo 1 > $i; done Signed-off-by: Kay Sievers <kay.sievers@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-10-28[PATCH] driver model wakeup flagsDavid Brownell1-0/+1
This is a refresh of an earlier patch to add "wakeup" support to the PM core model. This provides per-device bus-neutral control of the use of wakeup events. * "struct device_pm_info" has two bits that are initialized as part of setting up the enclosing struct device: - "can_wakeup", reflecting hardware capabilities - "may_wakeup", the policy setting (when CONFIG_PM) * There's a writeable sysfs "wakeup" file, with one of two values: - "enabled", when the policy is to allow wakeup - "disabled", when the policy is not to allow it - "" if the device can't currently issue wakeups By default, wakeup is enabled on all devices that support it. If its driver doesn't support it ... treat it as a bug. :) Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-09-07[PATCH] fix klist semantics for lists which have elements removed on traversalJames Bottomley1-1/+16
The problem is that klists claim to provide semantics for safe traversal of lists which are being modified. The failure case is when traversal of a list causes element removal (a fairly common case). The issue is that although the list node is refcounted, if it is embedded in an object (which is universally the case), then the object will be freed regardless of the klist refcount leading to slab corruption because the klist iterator refers to the prior element to get the next. The solution is to make the klist take and release references to the embedding object meaning that the embedding object won't be released until the list relinquishes the reference to it. (akpm: fast-track this because it's needed for the 2.6.13 scsi merge) Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-05[PATCH] klist: fix klist to have the same klist_add semantics as list_headJames Bottomley1-1/+1
at the moment, the list_head semantics are list_add(node, head) whereas current klist semantics are klist_add(head, node) This is bound to cause confusion, and since klist is the newcomer, it should follow the list_head semantics. I also added missing include guards to klist.h Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-06-29[PATCH] Driver core: Use klist_del() instead of klist_remove().Patrick Mochel1-1/+1
Use klist_del() instead of klist_remove() when unregistering devices. This will prevent a deadlock when executing a recursive unregister using device_for_each_child(). Signed-off-by Patrick Mochel <mochel@digitalimplant.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>