public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Richard Cochran <richardcochran@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
	netdev@vger.kernel.org, Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Christoph Lameter <cl@linux.com>,
	David Miller <davem@davemloft.net>,
	John Stultz <johnstul@us.ibm.com>,
	Krzysztof Halasa <khc@pm.waw.pl>,
	Peter Zijlstra <peterz@infradead.org>,
	Rodolfo Giometti <giometti@linux.it>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH V7 3/8] posix clocks: introduce dynamic clocks
Date: Thu, 16 Dec 2010 17:16:42 +0100	[thread overview]
Message-ID: <201012161716.42520.arnd@arndb.de> (raw)
In-Reply-To: <8debe4d48d9a6484b7fbd35d8888524155fed977.1292512461.git.richard.cochran@omicron.at>

On Thursday 16 December 2010, Richard Cochran wrote:
> This patch adds support for adding and removing posix clocks. The
> clock lifetime cycle is patterned after usb devices. Each clock is
> represented by a standard character device. In addition, the driver
> may optionally implemented custom character device operations.
> 
> The dynamic posix clocks do not yet do anything useful. This patch
> merely provides some needed infrastructure.
> 
> Signed-off-by: Richard Cochran <richard.cochran@omicron.at>

> +struct posix_clock_fops {
> +	int (*fasync)  (void *priv, int fd, struct file *file, int on);
> +	int (*mmap)    (void *priv, struct vm_area_struct *vma);
> +	int (*open)    (void *priv, fmode_t f_mode);
> +	int (*release) (void *priv);
> +	long (*ioctl)  (void *priv, unsigned int cmd, unsigned long arg);
> +	long (*compat_ioctl) (void *priv, unsigned int cmd, unsigned long arg);
> +	ssize_t (*read) (void *priv, uint flags, char __user *buf, size_t cnt);
> +	unsigned int (*poll) (void *priv, struct file *file, poll_table *wait);
> +};

Thanks for the change to a private ops structure. Three more
suggestions for this:

* I would recommend starting without a compat_ioctl operation if you can.
Just mandate that all ioctls for posix clocks are compatible and call
fops->ioctl from the posix_clock_compat_ioctl() function.
If you ever need compat_ioctl handling, it can still be added later.

* Instead of passing a void pointer, why not pass a struct posix_clock
pointer to the lower device and use container_of? That follows what
we do in other subsystems and allows you save one allocation, by
including the posix_clock into the specific clock struct like
ptp_clock.

> +struct posix_clock_operations {
> +	struct module *owner;
> +	struct posix_clock_fops fops;
> +	int  (*clock_adjtime)(void *priv, struct timex *tx);

You can easily combine the two structures and get rid of the extra
struct posix_clock_fops by moving its operations into
posix_clock_operations.

Looks really good otherwise.

	Arnd

  reply	other threads:[~2010-12-16 16:17 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-16 15:41 [PATCH V7 0/8] ptp: IEEE 1588 hardware clock support Richard Cochran
2010-12-16 15:41 ` [PATCH V7 1/8] ntp: add ADJ_SETOFFSET mode bit Richard Cochran
2010-12-16 17:48   ` Thomas Gleixner
2010-12-17 20:16   ` Kuwahara,T.
2010-12-21  7:56     ` Richard Cochran
2010-12-21 20:57       ` Kuwahara,T.
2010-12-21 22:25         ` john stultz
2010-12-22  7:13           ` Richard Cochran
2010-12-22 20:27           ` Kuwahara,T.
2010-12-23  0:00             ` john stultz
2010-12-23  6:13             ` Richard Cochran
2010-12-25 20:38               ` Kuwahara,T.
2010-12-26 14:14                 ` Richard Cochran
2010-12-21 19:37     ` john stultz
2010-12-21 21:13       ` Kuwahara,T.
2010-12-21 21:59         ` john stultz
2010-12-22  7:11           ` Richard Cochran
2010-12-22  9:58           ` Alexander Gordeev
2010-12-16 15:42 ` [PATCH V7 2/8] posix clocks: introduce a syscall for clock tuning Richard Cochran
2010-12-16 15:51   ` Arnd Bergmann
2010-12-16 17:55   ` Thomas Gleixner
2010-12-16 15:43 ` [PATCH V7 3/8] posix clocks: introduce dynamic clocks Richard Cochran
2010-12-16 16:16   ` Arnd Bergmann [this message]
2010-12-16 20:56   ` Thomas Gleixner
2010-12-17  6:29     ` Richard Cochran
2010-12-16 15:43 ` [PATCH V7 4/8] posix clocks: hook dynamic clocks into system calls Richard Cochran
2010-12-16 23:20   ` Thomas Gleixner
2010-12-17  7:04     ` Richard Cochran
2010-12-17 10:03       ` Thomas Gleixner
2010-12-21  8:00         ` Richard Cochran
2010-12-22  8:21         ` Richard Cochran
2010-12-16 15:44 ` [PATCH V7 5/8] ptp: Added a brand new class driver for ptp clocks Richard Cochran
2010-12-16 15:57   ` Arnd Bergmann
2010-12-16 16:08   ` Rodolfo Giometti
2010-12-16 15:44 ` [PATCH V7 6/8] ptp: Added a clock that uses the eTSEC found on the MPC85xx Richard Cochran
2010-12-16 15:44 ` [PATCH V7 7/8] ptp: Added a clock driver for the IXP46x Richard Cochran
2011-01-02  8:45   ` Pavel Machek
2011-01-02  9:12     ` Richard Cochran
2011-01-02  9:20       ` Pavel Machek
2011-01-03 17:07         ` Richard Cochran
2011-01-06 20:04           ` Pavel Machek
2011-01-02  9:19     ` Richard Cochran
2010-12-16 15:45 ` [PATCH V7 8/8] ptp: Added a clock driver for the National Semiconductor PHYTER Richard Cochran

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=201012161716.42520.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=cl@linux.com \
    --cc=davem@davemloft.net \
    --cc=giometti@linux.it \
    --cc=johnstul@us.ibm.com \
    --cc=khc@pm.waw.pl \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=richardcochran@gmail.com \
    --cc=tglx@linutronix.de \
    /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