From: "Henrik Rydberg" <rydberg@euromail.se>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH] Input: introduce managed input devices (add devres support)
Date: Mon, 29 Oct 2012 21:02:26 +0100 [thread overview]
Message-ID: <20121029200226.GA15156@polaris.bitmath.org> (raw)
In-Reply-To: <20121029185919.GA13256@core.coreip.homeip.net>
> > > @@ -1766,8 +1830,14 @@ EXPORT_SYMBOL(input_allocate_device);
> > > */
> > > void input_free_device(struct input_dev *dev)
> > > {
> > > - if (dev)
> > > + if (dev) {
> > > + if (dev->devres_managed)
> > > + WARN_ON(devres_destroy(dev->dev.parent,
> > > + devm_input_device_release,
> > > + devm_input_device_match,
> > > + dev));
> > > input_put_device(dev);
> >
> > Device is put twice?
>
> No, devres_destroy() does not actually run the release handler so we
> need to call it explicitly.
Ok, I see it now - it merely uses the handler to qualify the matching object.
> > Why not add the resource to the input device instead? For one, it
> > would make the order of unregister and release more apparent.
>
> And what would that achieve? What would trigger unregistration?
As you say, it is a matter of view. We do not want to replay the whole
"function with object argument or object with member function"
debate. :-)
> > Right
> > now, the code seems to rely on the reverse for-loop in the devres
> > implementation.
>
> That is the whole point of devres: it releases resources attached to
> the parent device (either when ->probe() fails or after ->remove() is
> called) in the opposed order of acquiring said resources. Think of it as
> calling destructors in C++ code.
That's what I did, but I mapped register() to a member of the input
resource, rather than to the parent device. If the parent device does
not need to know how to unregister the input device, it makes sense to
do so.
Either way, the code looks functional to me.
Thanks,
Henrik
next prev parent reply other threads:[~2012-10-29 19:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-23 5:35 [PATCH] Input: introduce managed input devices (add devres support) Dmitry Torokhov
2012-10-29 18:22 ` Henrik Rydberg
2012-10-29 18:59 ` Dmitry Torokhov
2012-10-29 20:02 ` Henrik Rydberg [this message]
2012-10-29 20:40 ` Dmitry Torokhov
2012-10-29 21:32 ` Henrik Rydberg
2012-10-29 22:12 ` Dmitry Torokhov
2012-10-31 21:05 ` Tejun Heo
2012-10-31 21:37 ` Dmitry Torokhov
2012-10-31 21:38 ` Tejun Heo
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=20121029200226.GA15156@polaris.bitmath.org \
--to=rydberg@euromail.se \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@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).