| Age | Commit message (Collapse) | Author |
|
add the helper and use it instead of open coding the klist_node_attached() check
(which is a layering violation IMHO)
idea by Alan Stern.
Signed-off-by: Daniel Ritz <daniel.ritz@gmx.ch>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
Signed-off-by: Len Brown <len.brown@intel.com>
|
|
Implement the framework for binding physical devices
with ACPI devices. A physical bus like PCI bus
should create a 'acpi_bus_type', with:
.find_device:
For device which has parent such as normal PCI devices.
.find_bridge:
It's for special devices, such as PCI root bridge
or IDE controller. Such devices generally haven't a
parent or ->bus. We use the special method
to get an ACPI handle.
Uses new field in struct device: firmware_data
http://bugzilla.kernel.org/show_bug.cgi?id=4277
Signed-off-by: David Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
|
|
No one was looking at the return value of bus_rescan_devices, and it
really wasn't anything that anyone in the kernel would ever care about.
So change it which enabled some counting code to be removed also.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
Add bus_find_device() and driver_find_device() which allow searching for a
device in the bus's resp. the driver's klist and obtain a reference on it.
Signed-off-by: Cornelia Huck <cohuck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
This patch adds the device_attribute paramerter to the
device_attribute store and show sysfs callback functions, and passes a
reference to the attribute when the callbacks are called.
Signed-off-by: Yani Ioannou <yani.ioannou@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
There's no check to see if the device is already bound to a driver, which
could do bad things. The first thing to go wrong is that it will try to match
a driver with a device already bound to one. In some cases (it appears with
USB with drivers/usb/core/usb.c::usb_match_id()), some drivers will match a
device based on the class type, so it would be common (especially for HID
devices) to match a device that is already bound.
The fun comes when ->probe() is called, it fails, then
driver_probe_device() does this:
dev->driver = NULL;
Later on, that pointer could be be dereferenced without checking and cause
hell to break loose.
This problem could be nasty. It's very hardware dependent, since some
devices could have a different set of matching qualifiers than others.
Now, I don't quite see exactly where/how you were getting that crash.
You're dereferencing bad memory, but I'm not sure which pointer was bad
and where it came from, but it could have come from a couple of different
places.
The patch below will hopefully fix it all up for you. It's against
2.6.12-rc2-mm1, and does the following:
- Move logic to driver_probe_device() and comments uncommon returns:
1 - If device is bound
0 - If device not bound, and no error
error - If there was an error.
- Move locking to caller of that function, since we want to lock a
device for the entire time we're trying to bind it to a driver (to
prevent against a driver being loaded at the same time).
- Update __device_attach() and __driver_attach() to do that locking.
- Check if device is already bound in __driver_attach()
- Update the converse device_release_driver() so it locks the device
around all of the operations.
- Mark driver_probe_device() as static and remove export. It's an
internal function, it should stay that way, and there are no other
callers. If there is ever a need to export it, we can audit it as
necessary.
Signed-off-by: Andrew Morton <akpm@osdl.org>
|
|
- Use klist iterator in device_for_each_child(), making it safe to use for
removing devices.
- Remove unused list_to_dev() function.
- Kills all usage of devices_subsys.rwsem.
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
- Use it in driver_for_each_device() instead of the regular list_head and stop using
the bus's rwsem for protection.
- Use driver_for_each_device() in driver_detach() so we don't deadlock on the
bus's rwsem.
- Remove ->devices.
- Move klist access and sysfs link access out from under device's semaphore, since
they're synchronized through other means.
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
- Use it in bus_for_each_drv().
- Use the klist spinlock instead of the bus rwsem.
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
- Use it for bus_for_each_dev().
- Use the klist spinlock instead of the bus rwsem.
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
Now there's an iterator for accessing each device bound to a driver.
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Index: linux-2.6.12-rc2/drivers/base/driver.c
===================================================================
|
|
This adds a per-device semaphore that is taken before every call from the core to a
driver method. This prevents e.g. simultaneous calls to the ->suspend() or ->resume()
and ->probe() or ->release(), potentially saving a whole lot of headaches.
It also moves us a step closer to removing the bus rwsem, since it protects the fields
in struct device that are modified by the core.
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
anymore.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
One step on improving the class api so that it can not be used incorrectly.
This also fixes the module owner issue with the dev files that happened when
the devt logic moved to the class core.
Based on a patch originally written by Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
Driver core:
change driver's, bus's, class's and platform device's names
to be const char * so one can use
const char *drv_name = "asdfg";
when initializing structures.
Also kill couple of whitespaces.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
The driver model has a "detach_state" mechanism that:
- Has never been used by any in-kernel drive;
- Is superfluous, since driver remove() methods can do the same thing;
- Became buggy when the suspend() parameter changed semantics and type;
- Could self-deadlock when called from certain suspend contexts;
- Is effectively wasted documentation, object code, and headspace.
This removes that "detach_state" mechanism; net code shrink, as well
as a per-device saving in the driver model and sysfs.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
This fixes u32 vs. pm_message_t in generic code. No code changes.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
subsystem rwsem.
This moves us away from using the rwsem, although recursive adds and removes of class devices
is not yet possible (nor is it really known if it even is needed.) So this simple change is
done instead.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
Get rid of semaphore abuse by converting device_driver->unload_sem
semaphore to device_driver->unloaded completion.
This should get rid of any confusion as well as save a few bytes in the
process.
Signed-off-by: Mike Waychison <michael.waychison@sun.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
|
|
Move the creation of the sysfs "dev" file of a class device into the
driver core. The struct class_device contains a dev_t value now. If set,
the driver core will create the "dev" file containing the major/minor
numbers automatically.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
This introduces pm_message_t. For now, it is only good for type-safety and
sparse checking, but plan is to turn pm_message_t into structure soon.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
This small patch adds routines to create and remove bin_attribute files
for class devices. One intended use is for binary files corresponding to
PCI busses, like bus legacy I/O ports or ISA memory.
Signed-off-by: Jesse Barnes <jbarnes@sgi.com>
|
|
platform_get_resource_byirq
Adds the ability to find a resource or irq on a platform device by its
resource name. This patch also tweaks how resource names get set.
Before, resources names were set to pdev->dev.bus_id, now that only
happens if the resource name has not been previous set.
All of this allows us to find a resource without assuming what order the
resources are in.
Signed-off-by: Kumar Gala <kumar.gala@freescale.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
This patch removes two fields from "struct device" that are duplicated
in "struct dev_pm_info": power_state (which should probably vanish)
and "saved_state". There were only two "real" uses of saved_state;
both are now switched over to use dev_pm_info.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
Driver core: rename bus_match into driver_probe_device and export
it so subsystems can bind an individual device to a
specific driver without getting involved with driver
core internals.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
Driver core: make device_attach() global and export it and
driver_attach() so subsystems can have finer
control over binding process.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
This functionality is essential for us to work out which drivers are
supplied by which modules. We use this in turn to work out which
modules are necessary to find the root device (and hence what
initrd/initramfs needs to insert).
If you look at debian at the moment, it uses a huge mapping table on
/proc/scsi/* to do this. If we implement the sysfs feature, we can
simply go from /sys/block/<device> to the actual device to the driver
and then to the module with no need of any fixed tables.
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
into ppc970.osdl.org:/home/torvalds/v2.6/linux
|
|
I recently went looking for users of the add() method in struct
bus_type, only to discover that there are none. A query to Pat
confirmed that it is surplus and should come out. So here's a patch
that does it.
While I was at it, I updated Documentation/driver-model/bus.txt to at
least get rid of the blatantly untrue stuff; it is still rather far from
being up to date, however. I may be able to fix that later on.
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
|
|
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
Add platform_device_register_simple to register platform devices
requiring minimal resource and memory management. The device
will have standard release function that just frees memory
occupied by the platform device. By having release function in
the driver core modules using such devices can be unloaded
without waiting for the last reference to the device to be
dropped.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
This actually implements the API (all except for
DMA_MEMORY_INCLUDES_CHILDREN).
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
|
|
On Wed, Jun 16, 2004 at 05:51:03PM -0500, Dmitry Torokhov wrote:
> What about freeing the resources? Can it be put in platform_device_unregister
> or is it release handler task? I'd put it in unregister because when I call
> unregister I expect device be half-dead and release as much resources as it
> can.
Here's the updated patch - to be applied on top of the
platform_get_resource() patch sent previously.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
This patch adds management of platform device resources to the
device model, allowing drivers to lookup resources, IRQs and DMA
numbers in the platform device resource array. We also add a
couple of functions which allow platform devices and their resources
to be registered.
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
- Add struct bus_type::dev_attrs, which is an array of device
attributes that are added to each device as they are registered.
- Also make sure that we don't hang when removing bus attributes
if adding one failed..
|
|
- Similar to default attributes for struct class, this is an array
of attributes, terminated with an attribute with a NULL name, that
are added when the bus is registered, and removed when the bus is
unregistered.
|
|
- add struct class::class_attrs, which is designed to point to an
array of class_attributes that are added when the class is registered
and removed when the class is unregistered.
This allows for more consolidated and cleaner definition of and
management of attributes.
- Add struct class::class_dev_attrs to do something similarly for
class devices. Each class device that is registered with the class
gets that set of attributes added for them, and subsequently removed
when the device is unregistered.
Each array depends on a terminating attribute with a NULL name. Hint:
use the new __ATTR_NULL macro to terminate it.
|
|
- Create __ATTR(), __ATTR_RO(), and __ATTR_NULL macros to help define
attributes in a neat, short-hand form.
- Apply these macros to the attribute definition in include/linux/device.h
- Note: These can be used to more cleanly define attributes in your own
code. e.g:
static struct device_attribute attrs[] = {
__ATTR_RO(foo),
__ATTR_RO(bar),
__ATTR(baz,0666,baz_show,baz_store),
__ATTR_NULL,
};
...etc.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
|
|
This avoids warnings about unused variables.
|
|
|
|
From: Rusty Russell <rusty@rustcorp.com.au>
include/linux/device.h includes include/linux/ioport.h twice.
|
|
From: James Bottomley <James.Bottomley@SteelEye.com>
pci_dev.consistent_dma_mask was introduced to get around problems in the
IA64 Altix machine.
Now, we have a use for it in x86: the aacraid needs coherent memory in a
31 bit address range (2GB). Unfortunately, x86 is converted to the dma
model, so it can't see the pci_dev by the time coherent memory is
allocated.
The solution to all of this is to move pci_dev.consistent_dma_mask to
dev.coherent_dma_mask and make x86 use it in the dma_alloc_coherent()
calls.
This should allow me to make the aacraid set the coherent mask instead
of using it's current dma_mask juggling.
|
|
into home.osdl.org:/home/torvalds/v2.5/linux
|
|
|