Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
455 giacomo 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 <linuxcomp.h>
13
 
14
#include <linux/device.h>
15
#include <linux/err.h>
16
#include <linux/stat.h>
17
#include <linux/string.h>
18
 
19
/**
20
 *      detach_state - control the default power state for the device.
21
 *     
22
 *      This is the state the device enters when it's driver module is
23
 *      unloaded. The value is an unsigned integer, in the range of 0-4.
24
 *      '0' indicates 'On', so no action will be taken when the driver is
25
 *      unloaded. This is the default behavior.
26
 *      '4' indicates 'Off', meaning the driver core will call the driver's
27
 *      shutdown method to quiesce the device.
28
 *      1-3 indicate a low-power state for the device to enter via the
29
 *      driver's suspend method.
30
 */
31
 
32
static ssize_t detach_show(struct device * dev, char * buf)
33
{
34
        return sprintf26(buf,"%u\n",dev->detach_state);
35
}
36
 
37
static ssize_t detach_store(struct device * dev, const char * buf, size_t n)
38
{
39
        u32 state;
40
        state = simple_strtoul(buf,NULL,10);
41
        if (state > 4)
42
                return -EINVAL;
43
        dev->detach_state = state;
44
        return n;
45
}
46
 
47
static DEVICE_ATTR(detach_state,0644,detach_show,detach_store);
48
 
49
 
50
struct attribute * dev_default_attrs[] = {
51
        &dev_attr_detach_state.attr,
52
        NULL,
53
};