diff options
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r-- | drivers/pcmcia/ds.c | 37 | ||||
-rw-r--r-- | drivers/pcmcia/socket_sysfs.c | 25 |
2 files changed, 60 insertions, 2 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 0252582b91cd..621ec459d27a 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -920,6 +920,37 @@ pcmcia_device_stringattr(prod_id2, prod_id[1]); | |||
920 | pcmcia_device_stringattr(prod_id3, prod_id[2]); | 920 | pcmcia_device_stringattr(prod_id3, prod_id[2]); |
921 | pcmcia_device_stringattr(prod_id4, prod_id[3]); | 921 | pcmcia_device_stringattr(prod_id4, prod_id[3]); |
922 | 922 | ||
923 | |||
924 | static ssize_t pcmcia_show_pm_state(struct device *dev, struct device_attribute *attr, char *buf) | ||
925 | { | ||
926 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); | ||
927 | |||
928 | if (p_dev->dev.power.power_state.event != PM_EVENT_ON) | ||
929 | return sprintf(buf, "off\n"); | ||
930 | else | ||
931 | return sprintf(buf, "on\n"); | ||
932 | } | ||
933 | |||
934 | static ssize_t pcmcia_store_pm_state(struct device *dev, struct device_attribute *attr, | ||
935 | const char *buf, size_t count) | ||
936 | { | ||
937 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); | ||
938 | int ret = 0; | ||
939 | |||
940 | if (!count) | ||
941 | return -EINVAL; | ||
942 | |||
943 | if ((p_dev->dev.power.power_state.event == PM_EVENT_ON) && | ||
944 | (!strncmp(buf, "off", 3))) | ||
945 | ret = dpm_runtime_suspend(dev, PMSG_SUSPEND); | ||
946 | else if ((p_dev->dev.power.power_state.event != PM_EVENT_ON) && | ||
947 | (!strncmp(buf, "on", 2))) | ||
948 | dpm_runtime_resume(dev); | ||
949 | |||
950 | return ret ? ret : count; | ||
951 | } | ||
952 | |||
953 | |||
923 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) | 954 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) |
924 | { | 955 | { |
925 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); | 956 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); |
@@ -945,8 +976,9 @@ static ssize_t pcmcia_store_allow_func_id_match(struct device *dev, | |||
945 | struct device_attribute *attr, const char *buf, size_t count) | 976 | struct device_attribute *attr, const char *buf, size_t count) |
946 | { | 977 | { |
947 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); | 978 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); |
948 | if (!count) | 979 | |
949 | return -EINVAL; | 980 | if (!count) |
981 | return -EINVAL; | ||
950 | 982 | ||
951 | down(&p_dev->socket->skt_sem); | 983 | down(&p_dev->socket->skt_sem); |
952 | p_dev->allow_func_id_match = 1; | 984 | p_dev->allow_func_id_match = 1; |
@@ -959,6 +991,7 @@ static ssize_t pcmcia_store_allow_func_id_match(struct device *dev, | |||
959 | 991 | ||
960 | static struct device_attribute pcmcia_dev_attrs[] = { | 992 | static struct device_attribute pcmcia_dev_attrs[] = { |
961 | __ATTR(function, 0444, func_show, NULL), | 993 | __ATTR(function, 0444, func_show, NULL), |
994 | __ATTR(pm_state, 0644, pcmcia_show_pm_state, pcmcia_store_pm_state), | ||
962 | __ATTR_RO(func_id), | 995 | __ATTR_RO(func_id), |
963 | __ATTR_RO(manf_id), | 996 | __ATTR_RO(manf_id), |
964 | __ATTR_RO(card_id), | 997 | __ATTR_RO(card_id), |
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index 7a7744662d54..5ab1cdef7c48 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c | |||
@@ -98,6 +98,30 @@ static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, si | |||
98 | } | 98 | } |
99 | static CLASS_DEVICE_ATTR(card_insert, 0200, NULL, pccard_store_insert); | 99 | static CLASS_DEVICE_ATTR(card_insert, 0200, NULL, pccard_store_insert); |
100 | 100 | ||
101 | |||
102 | static ssize_t pccard_show_card_pm_state(struct class_device *dev, char *buf) | ||
103 | { | ||
104 | struct pcmcia_socket *s = to_socket(dev); | ||
105 | return sprintf(buf, "%s\n", s->state & SOCKET_SUSPEND ? "off" : "on"); | ||
106 | } | ||
107 | |||
108 | static ssize_t pccard_store_card_pm_state(struct class_device *dev, const char *buf, size_t count) | ||
109 | { | ||
110 | ssize_t ret = -EINVAL; | ||
111 | struct pcmcia_socket *s = to_socket(dev); | ||
112 | |||
113 | if (!count) | ||
114 | return -EINVAL; | ||
115 | |||
116 | if (!(s->state & SOCKET_SUSPEND) && !strncmp(buf, "off", 3)) | ||
117 | ret = pcmcia_suspend_card(s); | ||
118 | else if ((s->state & SOCKET_SUSPEND) && !strncmp(buf, "on", 2)) | ||
119 | ret = pcmcia_resume_card(s); | ||
120 | |||
121 | return ret ? -ENODEV : count; | ||
122 | } | ||
123 | static CLASS_DEVICE_ATTR(card_pm_state, 0644, pccard_show_card_pm_state, pccard_store_card_pm_state); | ||
124 | |||
101 | static ssize_t pccard_store_eject(struct class_device *dev, const char *buf, size_t count) | 125 | static ssize_t pccard_store_eject(struct class_device *dev, const char *buf, size_t count) |
102 | { | 126 | { |
103 | ssize_t ret; | 127 | ssize_t ret; |
@@ -320,6 +344,7 @@ static struct class_device_attribute *pccard_socket_attributes[] = { | |||
320 | &class_device_attr_card_vpp, | 344 | &class_device_attr_card_vpp, |
321 | &class_device_attr_card_vcc, | 345 | &class_device_attr_card_vcc, |
322 | &class_device_attr_card_insert, | 346 | &class_device_attr_card_insert, |
347 | &class_device_attr_card_pm_state, | ||
323 | &class_device_attr_card_eject, | 348 | &class_device_attr_card_eject, |
324 | &class_device_attr_card_irq_mask, | 349 | &class_device_attr_card_irq_mask, |
325 | &class_device_attr_available_resources_setup_done, | 350 | &class_device_attr_available_resources_setup_done, |