All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Stephen Chandler Paul <cpaul@redhat.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Arnd Bergmann <arnd@arndb.de>, Joe Perches <joe@perches.com>,
	Jiri Slaby <jslaby@suse.com>,
	Vishnu Patekar <vishnupatekar0510@gmail.com>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-input@vger.kernel.org, linux-api@vger.kernel.org,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	Hans de Goede <hdegoede@redhat.com>
Subject: Re: [RFC] Input: Add ps2emu module
Date: Tue, 21 Jul 2015 12:15:12 -0700	[thread overview]
Message-ID: <20150721191512.GB21710@kroah.com> (raw)
In-Reply-To: <1437505634-8633-2-git-send-email-cpaul@redhat.com>

On Tue, Jul 21, 2015 at 03:07:14PM -0400, Stephen Chandler Paul wrote:
> +#define ps2emu_warn(format, args...) \
> +	dev_warn(ps2emu_misc.this_device, format, ## args)

Don't make a wrapper function for another wrapper function, just spell
the thing out in the code, makes it much easier to debug and maintain
over time.

It will also cause you to rename "this_device" to "dev" to make it
easier to type :)

> +static int ps2emu_char_open(struct inode *inode, struct file *file)
> +{
> +	struct ps2emu_device *ps2emu = NULL;
> +
> +	ps2emu = kzalloc(sizeof(struct ps2emu_device), GFP_KERNEL);
> +	if (!ps2emu)
> +		return -ENOMEM;
> +
> +	init_waitqueue_head(&ps2emu->waitq);
> +
> +	ps2emu->serio.write = ps2emu_device_write;
> +	ps2emu->serio.port_data = ps2emu;
> +
> +	file->private_data = ps2emu;
> +
> +	nonseekable_open(inode, file);

Why call this at all?

> +	ret = copy_to_user(buffer, &ps2emu->buf[ps2emu->tail], copylen);
> +	if (ret)
> +		return ret;

Wrong error value, please return -EFAULT.

> +	rc = copy_from_user(&cmd, buffer, sizeof(cmd));
> +	if (rc)
> +		return rc;

Same thing here, -EFAULT.

> +	case PS2EMU_CMD_SEND_INTERRUPT:
> +		if (unlikely(!ps2emu->running)) {

Unless you can verify likely/unlikely actually makes a difference in
your code, don't ever use it.  Hint, it's not needed here.

thanks,

greg k-h

  reply	other threads:[~2015-07-21 19:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21 19:07 [RFC] ps2emu - PS/2 emulation module Stephen Chandler Paul
2015-07-21 19:07 ` Stephen Chandler Paul
2015-07-21 19:07 ` [RFC] Input: Add ps2emu module Stephen Chandler Paul
2015-07-21 19:15   ` Greg KH [this message]
2015-07-21 19:47     ` [RFC 1/1 v2] " Stephen Chandler Paul
2015-07-21 19:57       ` Greg KH
2015-07-21 20:46       ` Dmitry Torokhov
2015-07-21 21:42         ` Stephen Chandler Paul
2015-07-21 22:13           ` Dmitry Torokhov
2015-07-21 19:16   ` [RFC] " Greg KH
2015-07-21 20:48 ` [RFC] ps2emu - PS/2 emulation module Dmitry Torokhov

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=20150721191512.GB21710@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=cpaul@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=joe@perches.com \
    --cc=jslaby@suse.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    --cc=sebott@linux.vnet.ibm.com \
    --cc=vishnupatekar0510@gmail.com \
    /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.