From: "Dave Young" <hidave.darkstar@gmail.com>
To: "Stefan Richter" <stefanr@s5r6.in-berlin.de>
Cc: gregkh@suse.de, linux1394-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/7] ieee1394 : use class iteration api
Date: Mon, 14 Jan 2008 09:57:33 +0800 [thread overview]
Message-ID: <a8e1da0801131757s7b4c46e3vc72b03e6a809917d@mail.gmail.com> (raw)
In-Reply-To: <4788A039.4090802@s5r6.in-berlin.de>
On Jan 12, 2008 7:10 PM, Stefan Richter <stefanr@s5r6.in-berlin.de> wrote:
> Dave Young wrote:
> > +++ linux.new/drivers/ieee1394/nodemgr.c 2008-01-12 15:20:27.000000000 +0800
> ...
>
> > static void nodemgr_remove_uds(struct node_entry *ne)
> > {
> > struct device *dev;
> > - struct unit_directory *tmp, *ud;
> > + struct unit_directory *ud;
> >
> > - /* Iteration over nodemgr_ud_class.devices has to be protected by
> > - * nodemgr_ud_class.sem, but device_unregister() will eventually
> > - * take nodemgr_ud_class.sem too. Therefore pick out one ud at a time,
> > - * release the semaphore, and then unregister the ud. Since this code
> > - * may be called from other contexts besides the knodemgrds, protect the
> > - * gap after release of the semaphore by nodemgr_serialize_remove_uds.
> > + /* Use class_find device to iterate the devices. Since this code
> > + * may be called from other contexts besides the knodemgrds,
> > + * protect it by nodemgr_serialize_remove_uds.
> > */
> > mutex_lock(&nodemgr_serialize_remove_uds);
> > - for (;;) {
> > - ud = NULL;
> > - down(&nodemgr_ud_class.sem);
> > - list_for_each_entry(dev, &nodemgr_ud_class.devices, node) {
> > - tmp = container_of(dev, struct unit_directory,
> > - unit_dev);
> > - if (tmp->ne == ne) {
> > - ud = tmp;
> > - break;
> > - }
> > - }
> > - up(&nodemgr_ud_class.sem);
> > - if (ud == NULL)
> > - break;
> > - device_unregister(&ud->unit_dev);
> > - device_unregister(&ud->device);
> > + dev = class_find_device(&nodemgr_ud_class, ne, __match_ne);
> > + if (!dev) {
> > + mutex_unlock(&nodemgr_serialize_remove_uds);
> > + return;
> > }
> > + ud = container_of(dev, struct unit_directory, unit_dev);
> > + device_unregister(&ud->unit_dev);
> > + device_unregister(&ud->device);
> > mutex_unlock(&nodemgr_serialize_remove_uds);
> > }
>
> A quick response on this change, without having checked the rest yet:
>
> This doesn't work. Each "ne" may have zero or more "ud". The purpose
> of nodemgr_remove_uds is to kill all of the uds of one ne. After your
> change, only the first ud of a ne would be gone.
>
> You need to keep the loop which takes care that all of the uds of the ne
> are removed
My wrong, will fix.
>
> Furthermore, I usually try to use "goto" or "break" constructs with
> single unlock + return path instead of multiple unlock + return paths.
> However, if these unlock + return paths are as visually close together
> as they are here, it doesn't really matter (to me) which of the styles
> is used.
I will update as your style in this patch, thanks for review.
>
> BTW, you don't need to CC <krh@redhat.com> on drivers/ieee1394/ patches
> (CONFIG_IEEE1394). He only looks after drivers/firewire/
> (CONFIG_FIREWIRE). I know, these are details, and everybody confuses
> them. :-) I should try to clarify this in MAINTAINERS.
Ok.
> --
> Stefan Richter
> -=====-==--- ---= -==--
> http://arcgraph.de/sr/
>
next prev parent reply other threads:[~2008-01-14 1:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-12 9:50 Dave Young
2008-01-12 11:10 ` Stefan Richter
2008-01-12 11:13 ` Stefan Richter
2008-01-14 1:57 ` Dave Young [this message]
2008-01-15 8:38 ` Dave Young
2008-01-15 18:10 ` Stefan Richter
2008-01-16 0:49 ` Dave Young
2008-01-17 0:19 ` Stefan Richter
2008-01-22 5:56 ` [PATCH 2/6] " Dave Young
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=a8e1da0801131757s7b4c46e3vc72b03e6a809917d@mail.gmail.com \
--to=hidave.darkstar@gmail.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=stefanr@s5r6.in-berlin.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
all inboxes | Powered by JetHome®