mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Rodolfo Giometti <giometti@linux.it>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.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>
Subject: Re: [PATCH 1/1] LinuxPPS core support.
Date: Tue, 3 Feb 2009 04:14:34 -0500	[thread overview]
Message-ID: <20090203091434.GB1091@infradead.org> (raw)
In-Reply-To: <1233510933-17512-2-git-send-email-giometti@linux.it>

> +static long pps_cdev_ioctl(struct file *file,
> +		unsigned int cmd, unsigned long arg)
> +{
> +	struct pps_device *pps = file->private_data;
> +	struct pps_kparams params;
> +	struct pps_fdata fdata;
> +	unsigned long ticks;
> +	void __user *uarg = (void __user *) arg;
> +	int __user *iuarg = (int __user *) arg;
> +	int err;
> +
> +	switch (cmd) {
> +	case PPS_CHECK:
> +
> +		/* This does nothing but signal we are a PPS source... */
> +
> +		return 0;

I think this one is superflous.  Just doing a PPS_GETPARAMS: should get
your the same information..

> +	case PPS_GETPARAMS:
> +		pr_debug("PPS_GETPARAMS: source %d\n", pps->id);
> +
> +		/* Return current parameters */
> +		err = copy_to_user(uarg, &pps->params,
> +						sizeof(struct pps_kparams));
> +		if (err)
> +			return -EFAULT;
> +
> +		break;
> +
> +	case PPS_SETPARAMS:
> +		pr_debug("PPS_SETPARAMS: source %d\n", pps->id);
> +
> +		/* Check the capabilities */
> +		if (!capable(CAP_SYS_TIME))
> +			return -EPERM;
> +
> +		err = copy_from_user(&params, uarg, sizeof(struct pps_kparams));
> +		if (err)
> +			return -EFAULT;
> +		if (!(params.mode & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR))) {
> +			pr_debug("capture mode unspecified (%x)\n",
> +								params.mode);
> +			return -EINVAL;
> +		}

Note that splitting out any non-trivial ioctl into it's own small helper
function gives generally much cleaner code.

> +	if (pps_devt)
> +		unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES);

Given that you have proper error handling in pps_init this can't
ever be zero.

> +
> +	pr_info("LinuxPPS API ver. %d removed\n", PPS_API_VERS);

Printing stuff on exit is rather noisy and should be avoided


  reply	other threads:[~2009-02-03  9:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-01 17:55 LinuxPPS core (Version 1): the PPS Linux implementation Rodolfo Giometti
2009-02-01 17:55 ` [PATCH 1/1] LinuxPPS core support Rodolfo Giometti
2009-02-03  9:14   ` Christoph Hellwig [this message]
2009-02-03  9:11 ` LinuxPPS core (Version 1): the PPS Linux implementation Christoph Hellwig
2009-02-10 14:05 LinuxPPS core (Version 2): " Rodolfo Giometti
2009-02-10 14:05 ` [PATCH 1/1] LinuxPPS core support Rodolfo Giometti
2009-02-22 20:39   ` Ingo Molnar
2009-02-22 20:57     ` H. Peter Anvin
2009-02-23  6:58       ` Ingo Molnar
2009-02-24 10:13         ` Rodolfo Giometti
2009-05-22  6:12 LinuxPPS core (Version 3): the PPS Linux implementation Rodolfo Giometti
2009-05-22  6:12 ` [PATCH 1/1] LinuxPPS core support Rodolfo Giometti
2009-05-26 23:33   ` Andrew Morton
2009-05-27  9:08     ` Alan Cox
2009-05-27 12:35       ` Folkert van Heusden
2009-05-27  9:38     ` 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=20090203091434.GB1091@infradead.org \
    --to=hch@infradead.org \
    --cc=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=hpa@zytor.com \
    --cc=kay.sievers@vrfy.org \
    --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

all inboxes | Powered by JetHome®