aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2005-05-12 15:06:27 -0400
committerGreg KH <gregkh@suse.de>2005-05-17 17:54:55 -0400
commit0b405a0f7e4d4d18fd1fe46ddf5ff465443036ab (patch)
tree49d74df6eddfdd095c650e0af34cde7f4548a2d5 /drivers/base
parent82428b62aa6294ea640c7e920a9224ecaf46db65 (diff)
[PATCH] Driver Core: remove driver model detach_state
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>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/Makefile2
-rw-r--r--drivers/base/bus.c1
-rw-r--r--drivers/base/core.c3
-rw-r--r--drivers/base/interface.c51
-rw-r--r--drivers/base/power/power.h11
-rw-r--r--drivers/base/power/shutdown.c16
6 files changed, 1 insertions, 83 deletions
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 6662b545e0a9..a47928a2e575 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -1,6 +1,6 @@
1# Makefile for the Linux device tree 1# Makefile for the Linux device tree
2 2
3obj-y := core.o sys.o interface.o bus.o \ 3obj-y := core.o sys.o bus.o \
4 driver.o class.o class_simple.o platform.o \ 4 driver.o class.o class_simple.o platform.o \
5 cpu.o firmware.o init.o map.o dmapool.o \ 5 cpu.o firmware.o init.o map.o dmapool.o \
6 attribute_container.o transport_class.o 6 attribute_container.o transport_class.o
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 2b3902c867da..3cb04bb04c2b 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -390,7 +390,6 @@ void device_release_driver(struct device * dev)
390 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj)); 390 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
391 sysfs_remove_link(&dev->kobj, "driver"); 391 sysfs_remove_link(&dev->kobj, "driver");
392 list_del_init(&dev->driver_list); 392 list_del_init(&dev->driver_list);
393 device_detach_shutdown(dev);
394 if (drv->remove) 393 if (drv->remove)
395 drv->remove(dev); 394 drv->remove(dev);
396 dev->driver = NULL; 395 dev->driver = NULL;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 268a9c8d168b..d21eb7744496 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -31,8 +31,6 @@ int (*platform_notify_remove)(struct device * dev) = NULL;
31#define to_dev(obj) container_of(obj, struct device, kobj) 31#define to_dev(obj) container_of(obj, struct device, kobj)
32#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) 32#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
33 33
34extern struct attribute * dev_default_attrs[];
35
36static ssize_t 34static ssize_t
37dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) 35dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
38{ 36{
@@ -89,7 +87,6 @@ static void device_release(struct kobject * kobj)
89static struct kobj_type ktype_device = { 87static struct kobj_type ktype_device = {
90 .release = device_release, 88 .release = device_release,
91 .sysfs_ops = &dev_sysfs_ops, 89 .sysfs_ops = &dev_sysfs_ops,
92 .default_attrs = dev_default_attrs,
93}; 90};
94 91
95 92
diff --git a/drivers/base/interface.c b/drivers/base/interface.c
deleted file mode 100644
index bd515843a0cb..000000000000
--- a/drivers/base/interface.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * drivers/base/interface.c - common driverfs interface that's exported to
3 * the world for all devices.
4 *
5 * Copyright (c) 2002-3 Patrick Mochel
6 * Copyright (c) 2002-3 Open Source Development Labs
7 *
8 * This file is released under the GPLv2
9 *
10 */
11
12#include <linux/device.h>
13#include <linux/err.h>
14#include <linux/stat.h>
15#include <linux/string.h>
16
17/**
18 * detach_state - control the default power state for the device.
19 *
20 * This is the state the device enters when it's driver module is
21 * unloaded. The value is an unsigned integer, in the range of 0-4.
22 * '0' indicates 'On', so no action will be taken when the driver is
23 * unloaded. This is the default behavior.
24 * '4' indicates 'Off', meaning the driver core will call the driver's
25 * shutdown method to quiesce the device.
26 * 1-3 indicate a low-power state for the device to enter via the
27 * driver's suspend method.
28 */
29
30static ssize_t detach_show(struct device * dev, char * buf)
31{
32 return sprintf(buf, "%u\n", dev->detach_state);
33}
34
35static ssize_t detach_store(struct device * dev, const char * buf, size_t n)
36{
37 u32 state;
38 state = simple_strtoul(buf, NULL, 10);
39 if (state > 4)
40 return -EINVAL;
41 dev->detach_state = state;
42 return n;
43}
44
45static DEVICE_ATTR(detach_state, 0644, detach_show, detach_store);
46
47
48struct attribute * dev_default_attrs[] = {
49 &dev_attr_detach_state.attr,
50 NULL,
51};
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index e5eda746f2a6..2e700d795cf1 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -1,18 +1,7 @@
1
2
3enum {
4 DEVICE_PM_ON,
5 DEVICE_PM1,
6 DEVICE_PM2,
7 DEVICE_PM3,
8 DEVICE_PM_OFF,
9};
10
11/* 1/*
12 * shutdown.c 2 * shutdown.c
13 */ 3 */
14 4
15extern int device_detach_shutdown(struct device *);
16extern void device_shutdown(void); 5extern void device_shutdown(void);
17 6
18 7
diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c
index 97979901c149..f50a08be424b 100644
--- a/drivers/base/power/shutdown.c
+++ b/drivers/base/power/shutdown.c
@@ -19,22 +19,6 @@
19extern struct subsystem devices_subsys; 19extern struct subsystem devices_subsys;
20 20
21 21
22int device_detach_shutdown(struct device * dev)
23{
24 if (!dev->detach_state)
25 return 0;
26
27 if (dev->detach_state == DEVICE_PM_OFF) {
28 if (dev->driver && dev->driver->shutdown) {
29 dev_dbg(dev, "shutdown\n");
30 dev->driver->shutdown(dev);
31 }
32 return 0;
33 }
34 return dpm_runtime_suspend(dev, dev->detach_state);
35}
36
37
38/** 22/**
39 * We handle system devices differently - we suspend and shut them 23 * We handle system devices differently - we suspend and shut them
40 * down last and resume them first. That way, we don't do anything stupid like 24 * down last and resume them first. That way, we don't do anything stupid like