{
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
- if (p_dev->dev.power.power_state.event != PM_EVENT_ON)
+ if (p_dev->suspended)
return sprintf(buf, "off\n");
else
return sprintf(buf, "on\n");
if (!count)
return -EINVAL;
- if ((p_dev->dev.power.power_state.event == PM_EVENT_ON) &&
- (!strncmp(buf, "off", 3)))
+ if ((!p_dev->suspended) && !strncmp(buf, "off", 3))
ret = dpm_runtime_suspend(dev, PMSG_SUSPEND);
- else if ((p_dev->dev.power.power_state.event != PM_EVENT_ON) &&
- (!strncmp(buf, "on", 2)))
+ else if (p_dev->suspended && !strncmp(buf, "on", 2))
dpm_runtime_resume(dev);
return ret ? ret : count;
{
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
struct pcmcia_driver *p_drv = NULL;
- int ret;
+ int ret = 0;
if (dev->driver)
p_drv = to_pcmcia_drv(dev->driver);
if (p_drv && p_drv->suspend) {
ret = p_drv->suspend(p_dev);
if (ret)
- return ret;
- p_dev->state |= DEV_SUSPEND;
- if ((p_dev->state & DEV_CONFIG) &&
- !(p_dev->state & DEV_SUSPEND_NORELEASE))
- pcmcia_release_configuration(p_dev);
+ goto out;
+ if ((p_dev->state & DEV_CONFIG) &&
+ !(p_dev->state & DEV_SUSPEND_NORELEASE))
+ pcmcia_release_configuration(p_dev);
}
- return 0;
+ out:
+ if (!ret)
+ p_dev->suspended = 1;
+ return ret;
}
{
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
struct pcmcia_driver *p_drv = NULL;
- int ret;
+ int ret = 0;
if (dev->driver)
p_drv = to_pcmcia_drv(dev->driver);
if (p_drv && p_drv->resume) {
- p_dev->state &= ~DEV_SUSPEND;
- if ((p_dev->state & DEV_CONFIG) &&
- !(p_dev->state & DEV_SUSPEND_NORELEASE)){
- ret = pcmcia_request_configuration(p_dev,
- &p_dev->conf);
- if (ret)
- return ret;
- }
- return p_drv->resume(p_dev);
+ if ((p_dev->state & DEV_CONFIG) &&
+ !(p_dev->state & DEV_SUSPEND_NORELEASE)){
+ ret = pcmcia_request_configuration(p_dev,
+ &p_dev->conf);
+ if (ret)
+ goto out;
+ }
+ ret = p_drv->resume(p_dev);
}
- return 0;
+ out:
+ if (!ret)
+ p_dev->suspended = 0;
+ return ret;
}