linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH 2/4] serio: add support for PS2Mult multiplexer protocol
Date: Thu, 12 Aug 2010 20:33:42 -0700	[thread overview]
Message-ID: <20100813033342.GC2661@core.coreip.homeip.net> (raw)
In-Reply-To: <1281605513-11586-3-git-send-email-dbaryshkov@gmail.com>

On Thu, Aug 12, 2010 at 01:31:51PM +0400, Dmitry Eremin-Solenikov wrote:
> +
> +static int ps2mult_serio_write(struct serio *serio, unsigned char data)
> +{
> +	struct ps2mult *psm = serio_get_drvdata(serio->parent);
> +	struct ps2mult_port *psmp = serio->port_data;
> +	int need_escape = 0;
> +
> +	mutex_lock(&psm->lock);

serio->write() is allowed to be called from interrupt contexts so you
should not be using mutex but a spinlock.

BTW, if anyone has time to annotate serio code with kerneldoc markups
that would be great.


> +	if (psm->cur_out_port != psmp->port) {
> +		psm->serio->write(psm->serio, psmp->sel);
> +		psm->cur_out_port = psmp->port;
> +		dev_dbg(&serio->dev, "switched to sel %02x\n", psmp->sel);
> +	}
> +	if (data == PS2MULT_ESCAPE
> +	 || data == PS2MULT_BSYNC
> +	 || data == PS2MULT_SESSION_START
> +	 || data == PS2MULT_SESSION_END
> +	 || memchr(ps2mult_selectors, data, PS2MULT_NUM_PORTS))
> +		need_escape = 1;

Use bool/true/false please. I'd also probably write

	need_escape = data == PS2MULT_ESCAPE ||
		      data == ...

> +
> +static int ps2mult_connect(struct serio *serio, struct serio_driver *drv)
> +{
> +	struct ps2mult *psm;
> +	int i;
> +	int rc;
> +
> +	if (!serio->write)
> +		return -EINVAL;
> +
> +	psm = kzalloc(sizeof(*psm), GFP_KERNEL);
> +	if (!psm)
> +		return -ENOMEM;
> +
> +	mutex_init(&psm->lock);
> +	psm->serio = serio;
> +
> +	serio_set_drvdata(serio, psm);
> +	serio_open(serio, drv);
> +

Here serio port is allowed to start sending the data. I do not believe
you are ready to receive it though. I think you need to create ports
first and then use start() to mark ports that have been regstered by
serio core as 'ready'. Probably i8042 could give you some ideas.

> index d2ae60d..1cf47e5 100644
> --- a/include/linux/serio.h
> +++ b/include/linux/serio.h
> @@ -155,6 +155,7 @@ static inline void serio_continue_rx(struct serio *serio)
>  #define SERIO_HIL_MLC	0x03
>  #define SERIO_PS_PSTHRU	0x05
>  #define SERIO_8042_XL	0x06
> +#define SERIO_PS2MULT_T	0x07

Why do you need new serio type? I'd stick with SERIO_I8042 so that you
do not need to patch atkbd/psmouse.

Thanks.

-- 
Dmitry

  reply	other threads:[~2010-08-13  3:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-12  9:31 [PATCH 0/4] Add drivers necessary to support PS/2 port on TQM85xx boards Dmitry Eremin-Solenikov
2010-08-12  9:31 ` [PATCH 1/4] serio: support multiple child devices per single parent Dmitry Eremin-Solenikov
2010-08-13  3:26   ` Dmitry Torokhov
2010-08-14 12:01     ` Dmitry Eremin-Solenikov
2010-08-12  9:31 ` [PATCH 2/4] serio: add support for PS2Mult multiplexer protocol Dmitry Eremin-Solenikov
2010-08-13  3:33   ` Dmitry Torokhov [this message]
2010-08-12  9:31 ` [PATCH 3/4] atkbd: support binding to ps2mult devices Dmitry Eremin-Solenikov
2010-08-12  9:31 ` [PATCH 4/4] psmouse: " Dmitry Eremin-Solenikov

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=20100813033342.GC2661@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=dbaryshkov@gmail.com \
    --cc=linux-input@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).