Commit f5435bda authored by Patrick Mochel's avatar Patrick Mochel

Merge osdl.org:/home/mochel/src/kernel/devel/linux-2.5-sync

into osdl.org:/home/mochel/src/kernel/devel/linux-2.5-linus
parents 58dc0833 ff70063c
......@@ -98,7 +98,7 @@ static void device_unbind(struct device * dev)
{
/* unbind from driver */
if (dev->driver && dev->driver->remove)
dev->driver->remove(dev,REMOVE_NOTIFY);
dev->driver->remove(dev);
}
static int do_driver_bind(struct device * dev, void * data)
......@@ -126,7 +126,7 @@ static int do_driver_unbind(struct device * dev, void * data)
dev->driver = NULL;
unlock_device(dev);
if (drv->remove)
drv->remove(dev,REMOVE_NOTIFY);
drv->remove(dev);
} else
unlock_device(dev);
return 0;
......@@ -134,7 +134,7 @@ static int do_driver_unbind(struct device * dev, void * data)
void driver_unbind(struct device_driver * drv)
{
// driver_for_each_dev(drv,drv,do_driver_unbind);
driver_for_each_dev(drv,drv,do_driver_unbind);
}
/**
......
......@@ -8,6 +8,39 @@
#include <linux/errno.h>
#include "base.h"
int driver_for_each_dev(struct device_driver * drv, void * data, int (*callback)(struct device *, void * ))
{
struct device * next;
struct device * dev = NULL;
struct list_head * node;
int error = 0;
get_driver(drv);
read_lock(&drv->lock);
node = drv->devices.next;
while (node != &drv->devices) {
next = list_entry(node,struct device,driver_list);
get_device(next);
read_unlock(&drv->lock);
if (dev)
put_device(dev);
dev = next;
if ((error = callback(dev,data))) {
put_device(dev);
break;
}
read_lock(&drv->lock);
node = dev->driver_list.next;
}
read_unlock(&drv->lock);
if (dev)
put_device(dev);
put_driver(drv);
return error;
}
/**
* driver_make_dir - create a driverfs directory for a driver
* @drv: driver in question
......@@ -68,5 +101,6 @@ void put_driver(struct device_driver * drv)
drv->release(drv);
}
EXPORT_SYMBOL(driver_for_each_dev);
EXPORT_SYMBOL(driver_register);
EXPORT_SYMBOL(put_driver);
......@@ -9,75 +9,6 @@
#include <linux/err.h>
#include <linux/stat.h>
/**
* device_read_status - report some device information
* @page: page-sized buffer to write into
* @count: number of bytes requested
* @off: offset into buffer
* @data: device-specific data
*
* Report some human-readable information about the device.
* This includes the name, the bus id, and the current power state.
*/
static ssize_t device_read_status(struct device * dev, char * page, size_t count, loff_t off)
{
return off ? 0 : sprintf(page,"%s\n",dev->bus_id);
}
/**
* device_write_status - forward a command to a driver
* @buf: encoded command
* @count: number of bytes in buffer
* @off: offset into buffer to start with
* @data: device-specific data
*
* Send a comamnd to a device driver.
* The following actions are supported:
* probe - scan slot for device
* remove - detach driver from slot
* suspend <state> <stage> - perform <stage> for entering <state>
* resume <stage> - perform <stage> for waking device up.
* (See Documentation/driver-model.txt for the theory of an n-stage
* suspend sequence).
*/
static ssize_t device_write_status(struct device * dev, const char* buf, size_t count, loff_t off)
{
char command[20];
int num;
int arg = 0;
int error = 0;
if (off)
return 0;
/* everything involves dealing with the driver. */
if (!dev->driver)
return 0;
num = sscanf(buf,"%10s %d",command,&arg);
if (!num)
return 0;
if (!strcmp(command,"probe")) {
if (dev->driver->probe)
error = dev->driver->probe(dev);
} else if (!strcmp(command,"remove")) {
if (dev->driver->remove)
error = dev->driver->remove(dev,REMOVE_NOTIFY);
} else
error = -EFAULT;
return error < 0 ? error : count;
}
static struct driver_file_entry device_status_entry = {
name: "status",
mode: S_IWUSR | S_IRUGO,
show: device_read_status,
store: device_write_status,
};
static ssize_t device_read_name(struct device * dev, char * buf, size_t count, loff_t off)
{
return off ? 0 : sprintf(buf,"%s\n",dev->name);
......@@ -166,7 +97,6 @@ static struct driver_file_entry device_power_entry = {
};
struct driver_file_entry * device_default_files[] = {
&device_status_entry,
&device_name_entry,
&device_power_entry,
NULL,
......
......@@ -113,7 +113,7 @@ void device_shutdown(void)
put_device(prev);
if (dev->driver && dev->driver->remove)
dev->driver->remove(dev,REMOVE_FREE_RESOURCES);
dev->driver->remove(dev);
spin_lock(&device_lock);
prev = dev;
......
......@@ -47,7 +47,7 @@ static int pci_device_probe(struct device * dev)
return error > 0 ? 0 : -ENODEV;
}
static int pci_device_remove(struct device * dev, u32 flags)
static int pci_device_remove(struct device * dev)
{
struct pci_dev * pci_dev = list_entry(dev,struct pci_dev,dev);
......
......@@ -48,11 +48,6 @@ enum {
RESUME_ENABLE,
};
enum {
REMOVE_NOTIFY,
REMOVE_FREE_RESOURCES,
};
struct device;
struct device_driver;
......@@ -103,7 +98,7 @@ struct device_driver {
struct driver_dir_entry dir;
int (*probe) (struct device * dev);
int (*remove) (struct device * dev, u32 flags);
int (*remove) (struct device * dev);
int (*suspend) (struct device * dev, u32 state, u32 level);
int (*resume) (struct device * dev, u32 level);
......
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