From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: David Herrmann <dh.herrmann@googlemail.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH 4/4] Input: extend the number of event (and other) devices
Date: Wed, 10 Oct 2012 09:58:16 -0700 [thread overview]
Message-ID: <20121010165816.GF19335@core.coreip.homeip.net> (raw)
In-Reply-To: <CANq1E4SK9poZO7etxYNmKHpK3SX1OM+0JC71HTC0f8h1uYDfBg@mail.gmail.com>
Hi David,
On Sun, Oct 07, 2012 at 04:52:28PM +0200, David Herrmann wrote:
> Hi Dmitry
>
> On Wed, Oct 3, 2012 at 11:03 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
>
> [snip]
>
> > @@ -991,43 +950,47 @@ static void evdev_cleanup(struct evdev *evdev)
> >
> > /*
> > * Create new evdev device. Note that input core serializes calls
> > - * to connect and disconnect so we don't need to lock evdev_table here.
> > + * to connect and disconnect.
> > */
> > static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
> > const struct input_device_id *id)
> > {
> > struct evdev *evdev;
> > int minor;
> > + int dev_no;
> > int error;
> >
> > - for (minor = 0; minor < EVDEV_MINORS; minor++)
> > - if (!evdev_table[minor])
> > - break;
> > -
> > - if (minor == EVDEV_MINORS) {
> > - pr_err("no more free evdev devices\n");
> > - return -ENFILE;
> > + minor = input_get_new_minor(EVDEV_MINOR_BASE, EVDEV_MINORS, true);
> > + if (minor < 0) {
> > + error = minor;
> > + pr_err("failed to reserve new minor: %d\n", error);
> > + return error;
>
> You could also do:
> return minor;
> So you can drop that "error = minor;" line.
Right, but I prefer doing this to signify that the value in 'minor' is
actually an error code.
>
> [snip]
>
> > @@ -1062,6 +1028,7 @@ static void evdev_disconnect(struct input_handle *handle)
> >
> > device_del(&evdev->dev);
> > evdev_cleanup(evdev);
> > + input_free_minor(MINOR(evdev->dev.devt));
>
> I was wondering whether we should free the minors in evdev_free()
> instead. Because if we free them here, we might end up with two
> user-space applications listening to the same cdev (based on
> major/minor) but to different input devices that drive the cdev.
>
> The older of both cdevs would be already dead and I don't think this
> is a big issue, but I just wanted to mention it if others can think of
> corner cases where this would be bad.
I believe this is OK and how the rest of Unix objects work - they do not
get freed until all users release them, but new users will get the new
instance.
>
> [snip]
>
> > @@ -2016,22 +2017,14 @@ EXPORT_SYMBOL(input_unregister_device);
> > int input_register_handler(struct input_handler *handler)
> > {
> > struct input_dev *dev;
> > - int retval;
> > + int error;
> >
> > - retval = mutex_lock_interruptible(&input_mutex);
> > - if (retval)
> > - return retval;
> > + error = mutex_lock_interruptible(&input_mutex);
> > + if (error)
> > + return error;
>
> Still wondering why you change that variable name here?
My style preference: when the same variable is used to return error
codes and success/real values I call it retval. If I have separate error
handling path and explicit success path I use "return error;"/"return 0;".
Here we transitioned to explicitly returning success, so I changed the
name.
>
> [snip]
>
> > @@ -576,13 +556,14 @@ static int mousedev_open(struct inode *inode, struct file *file)
> > goto err_free_client;
> >
> > file->private_data = client;
> > + nonseekable_open(inode, file);
>
> Ouh, seems like we never called this for mousedevs, isn't that a bug
> that should also go to stable? It just sets some flags but I am not
> sure what happends if we don't set them.
> It isn't related to this patch (I think?).
I split it out, but we do not need it for stable. We still were
installing noop_llseek() fops handler so it should still work even
without nonseekable_open().
>
> [snip]
>
> Sorry for the bikeshedding. The patch looks really good and all I
> found are just minor optional suggestions (or personal taste).
Thank you very mich for going over the code!
> Thanks a lot for fixing this! It looks much better than my first approach.
>
> Reviewed-by: David Herrmann <dh.herrmann@googlemail.com>
>
> Regards
> David
--
Dmitry
next prev parent reply other threads:[~2012-10-10 16:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-03 21:02 [PATCH 1/4] Input: mousedev - factor out psaux code to reduce #ifdefery Dmitry Torokhov
2012-10-03 21:03 ` [PATCH 2/4] Input: mousedev - reformat structure initializers Dmitry Torokhov
2012-10-03 21:03 ` [PATCH 3/4] Input: mousedev - rename mixdev_open to opened_by_mixdev Dmitry Torokhov
2012-10-03 21:03 ` [PATCH 4/4] Input: extend the number of event (and other) devices Dmitry Torokhov
2012-10-07 14:52 ` David Herrmann
2012-10-10 16:58 ` Dmitry Torokhov [this message]
2012-10-07 14:56 ` David Herrmann
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=20121010165816.GF19335@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=dh.herrmann@googlemail.com \
--cc=linux-input@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).