LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: "Dave Young" <hidave.darkstar@gmail.com> To: "Cornelia Huck" <cornelia.huck@de.ibm.com> Cc: "Greg KH" <gregkh@suse.de>, stefanr@s5r6.in-berlin.de, James.Bottomley@hansenpartnership.com, a.zummo@towertech.it, peterz@infradead.org, cbou@mail.ru, linux-kernel@vger.kernel.org, "David Brownell" <david-b@pacbell.net>, krh@redhat.com, stern@rowland.harvard.edu, dwmw2@infradead.org, davem@davemloft.net, jarkao2@gmail.com Subject: Re: [PATCH 1/7] driver-core : add class iteration api Date: Tue, 15 Jan 2008 08:17:04 +0800 [thread overview] Message-ID: <a8e1da0801141617x6d49a144r441404dfe06d5b35@mail.gmail.com> (raw) In-Reply-To: <20080114131347.6ddd036a@gondolin.boeblingen.de.ibm.com> On Jan 14, 2008 8:13 PM, Cornelia Huck <cornelia.huck@de.ibm.com> wrote: > On Sat, 12 Jan 2008 17:47:54 +0800, > Dave Young <hidave.darkstar@gmail.com> wrote: > > Minor style suggestion (same for class_find_child): > > > +struct device *class_find_device(struct class *class, void *data, > > + int (*match)(struct device *, void *)) > > +{ > > + struct device *dev; > > + int error = 1; > > How about using inverse logic here (e.g., start with int found = 0)... Sounds good, will do. Thanks. > > > + > > + if (!class) > > + return NULL; > > + > > + down(&class->sem); > > + list_for_each_entry(dev, &class->devices, node) { > > + dev = get_device(dev); > > + if (dev) { > > + if (match(dev, data)) { > > + error = 0; > > ...and set found = 1 here... > > > + break; > > + } else > > + put_device(dev); > > + } else > > + break; > > + } > > + up(&class->sem); > > + > > + if (error) > > + return NULL; > > + return dev; > > ...and do > return found ? dev : NULL; > in the end? > > Especially since not finding the device is not really an error. > > > +} > > Otherwise this looks fine to me. >
next prev parent reply other threads:[~2008-01-15 0:17 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-01-12 9:47 [PATCH 1/7] driver-core : add class iteration api Dave Young 2008-01-12 10:50 ` Stefan Richter 2008-01-14 1:32 ` Dave Young 2008-01-12 20:11 ` Jarek Poplawski 2008-01-14 1:36 ` Dave Young 2008-01-14 6:58 ` Jarek Poplawski 2008-01-14 7:00 ` Dave Young 2008-01-14 12:13 ` Cornelia Huck 2008-01-15 0:17 ` Dave Young [this message] 2008-01-15 9:13 ` Dave Young 2008-01-15 9:45 ` Cornelia Huck 2008-01-22 5:54 ` [PATCH 1/6] " Dave Young 2008-01-22 6:06 ` Dave Young 2008-01-22 6:24 ` David Brownell 2008-01-22 6:30 ` Dave Young 2008-01-22 7:27 ` Dave Young 2008-01-22 8:44 ` Cornelia Huck 2008-01-22 22:25 ` Greg KH 2008-01-23 1:02 ` 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=a8e1da0801141617x6d49a144r441404dfe06d5b35@mail.gmail.com \ --to=hidave.darkstar@gmail.com \ --cc=James.Bottomley@hansenpartnership.com \ --cc=a.zummo@towertech.it \ --cc=cbou@mail.ru \ --cc=cornelia.huck@de.ibm.com \ --cc=davem@davemloft.net \ --cc=david-b@pacbell.net \ --cc=dwmw2@infradead.org \ --cc=gregkh@suse.de \ --cc=jarkao2@gmail.com \ --cc=krh@redhat.com \ --cc=linux-kernel@vger.kernel.org \ --cc=peterz@infradead.org \ --cc=stefanr@s5r6.in-berlin.de \ --cc=stern@rowland.harvard.edu \ /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: linkBe 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).