public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: postmaster@van-ginkel.eu
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ptmx: adding handshake support
Date: Sun, 30 Mar 2008 13:16:52 +0100	[thread overview]
Message-ID: <20080330131652.7073589c@core> (raw)
In-Reply-To: <20080330140948.0cqmtqb9us880cw8@62.129.139.44>

On Sun, 30 Mar 2008 14:09:48 +0200
postmaster@van-ginkel.eu wrote:

> This weekend I upgraded my kernel to 2.6.22.5 and tried my patch.
> Unfortunately pty.c seems to be a slightly different, so generated a new
> patch:

Really you want to be working against 2.6.25-rc5-mm1 or later as there
are big changes in the tty layer pending, some of which affect the
locking on stuff like this.

> +struct pty_mcrmsr {
> +
> +	struct semaphore        sem;            /* locks this structure */

You create a lock but don't use it. Also btw the -mm tty layer has a
ctrl_lock you could use instead.

> +	/* for tiocmget and tiocmset functions */
> +
> +	int                     msr;            /* MSR shadow */
> +	int                     mcr;            /* MCR shadow */

Could be one value using the existing bit masks.

> +	mcrmsr = kmalloc(sizeof(*mcrmsr), GFP_KERNEL);
> +
> +	init_MUTEX(&mcrmsr->sem);

Crashes on allocation failure

> +	if (tty->driver_data != NULL) {
> +		msr = mcrmsr->msr;
> +		mcr = mcrmsr->mcr;
> +	}

Always true

> +
> +	result = ((mcr & 0x01)  ? TIOCM_DTR  : 0) |  /* DTR is set */
> +		((mcr & 0x02)  ? TIOCM_RTS  : 0) |  /* RTS is set */
> +		((mcr & 0x04)  ? TIOCM_LOOP : 0) |  /* LOOP is set */
> +		((msr & 0x08)  ? TIOCM_CTS  : 0) |  /* CTS is set */
> +		((msr & 0x10)  ? TIOCM_CAR  : 0) |  /* Carrier detect is set*/
> +		((msr & 0x20)  ? TIOCM_RI   : 0) |  /* Ring Indicator is set */
> +		((msr & 0x40)  ? TIOCM_DSR  : 0);   /* DSR is set */

Use the mcr/msr bits as is and you don't need this mess

> +	if (set & TIOCM_DTR)
> +		mcr |= 0x01;
> +	if (set & TIOCM_RTS)
> +		mcr |= 0x02;
> +	if (set & TIOCM_LOOP)

Ditto

> +	/* set the new MCR value in the device */
> +
> +	if (tty->driver_data != NULL)
> +		mcrmsr->mcr=mcr;

That may cause wakeups, open, hangup etc to occur - does that need to be
considered here.

> +	case 0x5426: /* Set all of the handshake line, even the normally  
> read only */

Use a proper value as I said before.




  reply	other threads:[~2008-03-30 12:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-11 20:28 [PATCH] ptmx: adding handshake support sander van ginkel
2008-03-30 12:09 ` postmaster
2008-03-30 12:16   ` Alan Cox [this message]
2008-03-30 12:48     ` sander van ginkel
2008-04-13 15:42     ` sander van ginkel
2008-04-13 22:35       ` Alan Cox
2008-04-14 20:39         ` sander van ginkel
2008-04-14 20:02           ` Randy Dunlap
2008-04-29 18:01           ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2008-03-11 21:19 sander van ginkel

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=20080330131652.7073589c@core \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=postmaster@van-ginkel.eu \
    /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