From: Andrew Morton <akpm@linux-foundation.org>
To: Rodolfo Giometti <giometti@linux.it>
Cc: linux-kernel@vger.kernel.org,
David Woodhouse <dwmw2@infradead.org>,
Dave Jones <davej@redhat.com>, Sam Ravnborg <sam@ravnborg.org>,
Greg KH <greg@kroah.com>, Randy Dunlap <randy.dunlap@oracle.com>,
Kay Sievers <kay.sievers@vrfy.org>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@elte.hu>,
Michael Kerrisk <mtk.manpages@gmail.com>,
Christoph Hellwig <hch@infradead.org>,
Alexander Gordeev <lasaine@lvk.cs.msu.su>
Subject: Re: [PATCH 6/8] pps: serial clients support.
Date: Fri, 19 Feb 2010 13:53:59 -0800 [thread overview]
Message-ID: <20100219135359.a5c195ea.akpm@linux-foundation.org> (raw)
In-Reply-To: <1266313885-1195-7-git-send-email-giometti@linux.it>
On Tue, 16 Feb 2010 10:51:23 +0100
Rodolfo Giometti <giometti@linux.it> wrote:
> Adds support, by using the PPS line discipline, for the PPS sources
> connected with the CD (Carrier Detect) pin of a serial port.
>
> ...
>
> +static int (*n_tty_open)(struct tty_struct *tty);
> +
> +static int pps_tty_open(struct tty_struct *tty)
> +{
> + struct pps_source_info info;
> + struct tty_driver *drv = tty->driver;
> + int index = tty->index + drv->name_base;
> + int ret;
> +
> + info.owner = THIS_MODULE;
> + info.dev = NULL;
> + snprintf(info.name, PPS_MAX_NAME_LEN, "%s%d", drv->driver_name, index);
> + snprintf(info.path, PPS_MAX_NAME_LEN, "/dev/%s%d", drv->name, index);
> + info.mode = PPS_CAPTUREBOTH | \
> + PPS_OFFSETASSERT | PPS_OFFSETCLEAR | \
> + PPS_CANWAIT | PPS_TSFMT_TSPEC;
> +
> + ret = pps_register_source(&info, PPS_CAPTUREBOTH | \
> + PPS_OFFSETASSERT | PPS_OFFSETCLEAR);
> + if (ret < 0) {
> + pr_err("cannot register PPS source \"%s\"\n", info.path);
> + return ret;
> + }
> + tty->disc_data = (void *) ret;
> +
> + /* Should open N_TTY ldisc too */
> + ret = n_tty_open(tty);
> + if (ret < 0)
> + pps_unregister_source((int) tty->disc_data);
> +
> + pr_info("PPS source #%d \"%s\" added\n", ret, info.path);
> +
> + return 0;
> +}
hm. The n_tty_open/close layering is a bit grubby but I guess we don't
have a need to create anything more comprehensive at this stage.
A small stylistic thing: the code's a bit confusing at present because
the names n_tty_open/n_tty_close are identical to the global functions
over in n_tty.c. A user of ctags will be tricked. Also, the _way_ in
which these function pointers are called:
ret = n_tty_open(tty);
make it look like the code is calling
drivers/char/n_tty.c:n_tty_open(). Except it isn't.
So I think it's better to do it with
ret = (*n_tty_open)(tty);
to avoid misleading the reader.
And perhaps to rename these variables to avoid the duplication with the
global functions.
next prev parent reply other threads:[~2010-02-19 21:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-16 9:51 LinuxPPS new functionalities Rodolfo Giometti
2010-02-16 9:51 ` [PATCH 1/8] pps: userland header file for PPS API Rodolfo Giometti
2010-02-16 9:51 ` [PATCH 2/8] pps: documentation programs and examples Rodolfo Giometti
2010-02-16 9:51 ` [PATCH 3/8] pps: LinuxPPS clients support Rodolfo Giometti
2010-02-16 9:51 ` [PATCH 4/8] ldisc: new dcd_change() method for line disciplines Rodolfo Giometti
2010-02-16 9:51 ` [PATCH 5/8] ldisc n_tty: add new method n_tty_inherit_ops() Rodolfo Giometti
2010-02-16 9:51 ` [PATCH 6/8] pps: serial clients support Rodolfo Giometti
2010-02-16 9:51 ` [PATCH 7/8] serial 8250: enable PPS support Rodolfo Giometti
2010-02-16 9:51 ` [PATCH 8/8] serial amba-pl010: " Rodolfo Giometti
2010-02-19 21:53 ` Andrew Morton [this message]
2010-02-21 19:21 ` [PATCH 6/8] pps: serial clients support Rodolfo Giometti
2010-02-19 21:45 ` [PATCH 5/8] ldisc n_tty: add new method n_tty_inherit_ops() Andrew Morton
2010-02-16 12:44 ` [PATCH 2/8] pps: documentation programs and examples Alexander Gordeev
2010-02-16 13:56 ` Rodolfo Giometti
2010-02-16 12:33 ` [PATCH 1/8] pps: userland header file for PPS API Alexander Gordeev
2010-02-16 13:53 ` Rodolfo Giometti
2010-02-16 12:28 ` LinuxPPS new functionalities Alan Cox
-- strict thread matches above, loose matches on Subject: below --
2008-02-08 18:00 LinuxPPS: the PPS Linux implementation Rodolfo Giometti
2008-02-08 18:00 ` [PATCH 1/8] LinuxPPS core support Rodolfo Giometti
2008-02-08 18:00 ` [PATCH 2/8] PPS: basic documentation file Rodolfo Giometti
2008-02-08 18:00 ` [PATCH 3/8] PPS: userland header file for PPS API Rodolfo Giometti
2008-02-08 18:00 ` [PATCH 4/8] PPS: documentation programs and examples Rodolfo Giometti
2008-02-08 18:00 ` [PATCH 5/8] PPS: LinuxPPS clients support Rodolfo Giometti
2008-02-08 18:00 ` [PATCH 6/8] PPS: serial " Rodolfo Giometti
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=20100219135359.a5c195ea.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=davej@redhat.com \
--cc=dwmw2@infradead.org \
--cc=giometti@linux.it \
--cc=greg@kroah.com \
--cc=hch@infradead.org \
--cc=hpa@zytor.com \
--cc=kay.sievers@vrfy.org \
--cc=lasaine@lvk.cs.msu.su \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mtk.manpages@gmail.com \
--cc=randy.dunlap@oracle.com \
--cc=sam@ravnborg.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