MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / base / interface.c
blobbd515843a0cbf4e87d5dd483f71e6890ffe67841
1 /*
2 * drivers/base/interface.c - common driverfs interface that's exported to
3 * the world for all devices.
5 * Copyright (c) 2002-3 Patrick Mochel
6 * Copyright (c) 2002-3 Open Source Development Labs
8 * This file is released under the GPLv2
12 #include <linux/device.h>
13 #include <linux/err.h>
14 #include <linux/stat.h>
15 #include <linux/string.h>
17 /**
18 * detach_state - control the default power state for the device.
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.
30 static ssize_t detach_show(struct device * dev, char * buf)
32 return sprintf(buf, "%u\n", dev->detach_state);
35 static ssize_t detach_store(struct device * dev, const char * buf, size_t n)
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;
45 static DEVICE_ATTR(detach_state, 0644, detach_show, detach_store);
48 struct attribute * dev_default_attrs[] = {
49 &dev_attr_detach_state.attr,
50 NULL,