Re: [patch] pm: fix runtime powermanagement's /sys interface

Pavel Machek
2006-01-06T08:53:18Z

On Pá 06-01-06 02:10:41, Dominik Brodowski wrote:
> On Thu, Jan 05, 2006 at 04:04:07PM -0800, Patrick Mochel wrote:
> > A better point, and one that would actually be useful, would be to remove
> > the file altogether. Let Dominik export a power file, with complete
> > control over the values, for each pcmcia device. Then you never have to
> > worry about breaking PCMCIA again.
>
> Then I'll try to push this into 2.6.16 later on; also I still need to fix
> up userspace accordingly...
>
> BTW, ACK on the removal of power/state from me... PCMCIA shouldn't hold this
> removal up.

Thanks.

> Dominik
>
>
> diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
> index 0252582..a4f3258 100644
> --- a/drivers/pcmcia/ds.c
> +++ b/drivers/pcmcia/ds.c
> @@ -920,6 +920,37 @@ pcmcia_device_stringattr(prod_id2, prod_
> pcmcia_device_stringattr(prod_id3, prod_id[2]);
> pcmcia_device_stringattr(prod_id4, prod_id[3]);
>
> +
> +static ssize_t pcmcia_show_suspend(struct device *dev, struct device_attribute *attr, char *buf)
> +{
> + struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
> +
> + if (p_dev->dev.power.power_state.event != PM_EVENT_ON)
> + return sprintf(buf, "1\n");
> + else
> + return sprintf(buf, "0\n");
> +}

Could we get something like 'on' / 'off', or something else less
ambiquous than 0/1?

> +static ssize_t pcmcia_store_suspend(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
> + int ret = 0;
> +
> + if (!count)
> + return -EINVAL;
> +
> + if (p_dev->dev.power.power_state.event == PM_EVENT_ON)
> + ret = dpm_runtime_suspend(dev, PMSG_SUSPEND);
> + else
> + dpm_runtime_resume(dev);

So *any* write into this file just toggles suspend status? That seems
remarkably ugly. The other hunk has same issue.

> + return ret ? ret : count;
> +
> + return count;

Not reachable.
Pavel
--
Thanks, Sharp!