From: Andres Salomon <dilinger@queued.net>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] OLPC: touchpad driver (take 2)
Date: Wed, 10 Sep 2008 17:55:13 -0400 [thread overview]
Message-ID: <20080910175513.17d900bc@dev.queued.net> (raw)
In-Reply-To: <20080815031435.GD9438@anvil.corenet.prv>
On Thu, 14 Aug 2008 23:14:35 -0400
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> Hi Andres,
>
> On Wed, Aug 13, 2008 at 03:24:59PM -0400, Andres Salomon wrote:
[...]
>
> > +
> > + retval = serio_pin_driver(serio);
> > + if (retval)
> > + return retval;
> > +
> > + psmouse = serio_get_drvdata(serio);
> > + priv = psmouse->private;
> > +
> > + if (val == priv->powered)
> > + goto done;
> > +
> > + /* hgpk_toggle_power will deal w/ state so we're not
> > racing w/ irq */
> > + retval = hgpk_toggle_power(psmouse, val);
> > + if (!retval)
> > + priv->powered = val;
> > +
> > +done:
> > + serio_unpin_driver(serio);
> > + return retval ? retval : count;
> > +}
> > +
> > +static DEVICE_ATTR(powered, S_IWUSR | S_IRUGO, hgpk_show_powered,
> > + hgpk_set_powered);
> >
>
> Any particular reason you didn't use PSMOUSE_DEFINE_ATTR? Then you
> would not need to bother with pinning the driver and provode mutual
> exclusion with other things. Btw, what do we do if device is powered
> down an user tries to change some settings via generic attributes
> defined in psmouse-base?
>
Ok, the problem is this - hgpk_set_powered disables power by sending a
special command, and power is re-enabled with the following code:
/*
* Sending a byte will drive MS-DAT low; this will wake
up
* the controller. Once we get an ACK back from it, it
* means we can continue with the touchpad re-init. ALPS
* tells us that 1s should be long enough, so set that
as
* the upper bound.
*/
for (timeo = 20; timeo > 0; timeo--) {
if (!ps2_sendbyte(&psmouse->ps2dev,
PSMOUSE_CMD_DISABLE, 20))
break;
msleep(50);
}
This means that after telling the ALPS device to turn off power, we
shouldn't be sending any ps2 commands until we want to turn power
back on. However, psmouse_attr_set_helper code has the following:
psmouse_deactivate(psmouse);
retval = attr->set(psmouse, attr->data, buf, count);
if (retval != -ENODEV)
psmouse_activate(psmouse);
If we're disabling power, psmouse_activate will proceed to turn
power back on.
There's also the following check in psmouse_attr_set_helper:
if (psmouse->state == PSMOUSE_IGNORE) {
retval = -ENODEV;
goto out_unlock;
}
That's not at all what we want; when we disable power, we also
do a psmouse_set_state(psmouse, PSMOUSE_IGNORE). That check
means we'd never be able to turn power back on.
What do you think about either changing PSMOUSE_DEFINE_ATTR
to take an additional 'raw' argument (meaning psmouse->state is
not checked, and psmouse_deactivate/psmouse_activate are not
called), or alternatively adding new helper functions that just
handle the locking (__PSMOUSE_DEFINE_ATTR() and
__psmouse_attr_{set,show}_helper())? I'd prefer the raw
argument.
next prev parent reply other threads:[~2008-09-10 21:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-13 19:24 [PATCH 3/3] OLPC: touchpad driver (take 2) Andres Salomon
2008-08-15 3:14 ` Dmitry Torokhov
2008-08-29 6:49 ` Andres Salomon
2008-09-10 13:00 ` Dmitry Torokhov
2008-09-10 21:55 ` Andres Salomon [this message]
2008-09-11 5:01 ` Andres Salomon
2008-09-11 5:32 ` Andres Salomon
2008-09-11 13:05 ` Dmitry Torokhov
2008-09-11 14:32 ` Andres Salomon
2008-09-11 18:32 ` Andres Salomon
2008-09-11 18:34 ` Andres Salomon
2008-09-11 12:59 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080910175513.17d900bc@dev.queued.net \
--to=dilinger@queued.net \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).