From: Richard Weinberger <richard@nod.at>
To: Jiri Slaby <jslaby@suse.cz>
Cc: linux-kernel@vger.kernel.org,
user-mode-linux-devel@lists.sourceforge.net,
viro@zeniv.linux.org.uk, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, gregkh@linuxfoundation.org,
Jiri Slaby <jirislaby@gmail.com>
Subject: Re: [PATCH] um: Use tty_port
Date: Sun, 12 Feb 2012 14:12:10 +0100 [thread overview]
Message-ID: <4F37BAAA.8080207@nod.at> (raw)
In-Reply-To: <4F37B815.8060701@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 3330 bytes --]
Am 12.02.2012 14:01, schrieb Jiri Slaby:
> This and the ioctl change above fullfils the subject of the patch in no
> way. Do this fix and the cleanup above separately, please.
Fair point.
>
>>> @@ -404,27 +334,27 @@ int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
>>> * first open or last close. Otherwise, open and close just return.
>>> */
>>>
>>> -int line_open(struct line *lines, struct tty_struct *tty)
>>> +int line_open(struct tty_struct *tty, struct file *filp)
>>> {
>>> - struct line *line = &lines[tty->index];
>>> - int err = -ENODEV;
>>> + struct line *line = tty->driver_data;
>>> + return tty_port_open(&line->port, tty, filp);
>>> +}
>>>
>>> - spin_lock(&line->count_lock);
>>> - if (!line->valid)
>>> - goto out_unlock;
>>> +int line_install(struct tty_driver *driver, struct tty_struct *tty, struct line *line)
>
> As it stands, it should be tty_port->ops->activate, not
> tty->ops->install. Yes, you can still set driver_data and check for
> multiple opens in install. Then use also tty_standard_install.
Okay.
>>> +{
>>> + int ret = tty_init_termios(tty);
>>>
>>> - err = 0;
>>> - if (line->count++)
>>> - goto out_unlock;
>>> + if (ret)
>>> + return ret;
>>>
>>> - BUG_ON(tty->driver_data);
>>> + tty_driver_kref_get(driver);
>>> + tty->count++;
>>> tty->driver_data = line;
>>> - line->tty = tty;
>>> + driver->ttys[tty->index] = tty;
>>>
>>> - spin_unlock(&line->count_lock);
>>> - err = enable_chan(line);
>>> - if (err) /* line_close() will be called by our caller */
>>> - return err;
>>> + ret = enable_chan(line);
>>> + if (ret)
>>> + return ret;
>>>
>>> INIT_DELAYED_WORK(&line->task, line_timer_cb);
>>>
>>> @@ -437,48 +367,36 @@ int line_open(struct line *lines, struct tty_struct *tty)
>>> &tty->winsize.ws_col);
>>>
>>> return 0;
>>> -
>>> -out_unlock:
>>> - spin_unlock(&line->count_lock);
>>> - return err;
>>> }
> ...
>>> +void line_close(struct tty_struct *tty, struct file * filp)
>>> +{
>>> + struct line *line = tty->driver_data;
>>> +
>>> + if (!line)
>>> + return;
>
> Unless you set tty->driver_data to NULL somewhere, this can never
> happen. If you do, why -- this tends to be racy?
The old driver set tty->driver_data to NULL.
I guess we can remove it.
>>> + tty_port_close(&line->port, tty, filp);
>>> +}
> ...
>>> --- a/arch/um/drivers/ssl.c
>>> +++ b/arch/um/drivers/ssl.c
>>> @@ -92,6 +92,7 @@ static int ssl_remove(int n, char **error_out)
>>> error_out);
>>> }
>>>
>>> +#if 0
>
> Hmm, remove unused code instead.
Will do.
>>> static int ssl_open(struct tty_struct *tty, struct file *filp)
>>> {
>>> int err = line_open(serial_lines, tty);
> ...
>>> @@ -124,8 +124,16 @@ void ssl_hangup(struct tty_struct *tty)
>>> }
>>> #endif
>>>
>>> +static int ssl_install(struct tty_driver *driver, struct tty_struct *tty)
>>> +{
>>> + if (tty->index < NR_PORTS)
>
> Do you register more than NR_PORTS when allocating tty_driver? If not,
> this test is always true. But presumably you won't need this hook anyway.
Okay.
>>> + return line_install(driver, tty, &serial_lines[tty->index]);
>>> + else
>>> + return -ENODEV;
>>> +}
>
> thanks,
Thanks,
//richard
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
next prev parent reply other threads:[~2012-02-12 13:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-12 0:21 [uml-devel] (no subject) Richard Weinberger
2012-02-12 0:24 ` [uml-devel] [PATCH] um: Use tty_port Richard Weinberger
2012-02-12 13:01 ` Jiri Slaby
2012-02-12 13:12 ` Richard Weinberger [this message]
2012-02-12 0:25 ` your mail Jesper Juhl
2012-02-12 1:02 ` [uml-devel] " Al Viro
2012-02-12 12:40 ` Jiri Slaby
2012-02-12 19:06 ` Al Viro
2012-02-13 9:40 ` Jiri Slaby
2012-02-12 19:11 ` Al Viro
2012-02-13 9:15 ` Jiri Slaby
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=4F37BAAA.8080207@nod.at \
--to=richard@nod.at \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@gmail.com \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.