@@ -920,6 +920,37 @@ pcmcia_device_stringattr(prod_id2, prod_id[1]);
920920pcmcia_device_stringattr (prod_id3 , prod_id [2 ]);
921921pcmcia_device_stringattr (prod_id4 , prod_id [3 ]);
922922
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+
923954static ssize_t modalias_show (struct device * dev , struct device_attribute * attr , char * buf )
924955{
925956 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,
945976 struct device_attribute * attr , const char * buf , size_t count )
946977{
947978 struct pcmcia_device * p_dev = to_pcmcia_dev (dev );
948- if (!count )
949- return - EINVAL ;
979+
980+ if (!count )
981+ return - EINVAL ;
950982
951983 down (& p_dev -> socket -> skt_sem );
952984 p_dev -> allow_func_id_match = 1 ;
@@ -959,6 +991,7 @@ static ssize_t pcmcia_store_allow_func_id_match(struct device *dev,
959991
960992static struct device_attribute pcmcia_dev_attrs [] = {
961993 __ATTR (function , 0444 , func_show , NULL ),
994+ __ATTR (pm_state , 0644 , pcmcia_show_pm_state , pcmcia_store_pm_state ),
962995 __ATTR_RO (func_id ),
963996 __ATTR_RO (manf_id ),
964997 __ATTR_RO (card_id ),
0 commit comments