LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: "Dave Young" <hidave.darkstar@gmail.com> To: "Stefan Richter" <stefanr@s5r6.in-berlin.de> Cc: "Greg KH" <gregkh@suse.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: Mon, 14 Jan 2008 09:32:47 +0800 [thread overview] Message-ID: <a8e1da0801131732t55238bf0u8e083b1754641c68@mail.gmail.com> (raw) In-Reply-To: <47889B68.8010601@s5r6.in-berlin.de> On Jan 12, 2008 6:50 PM, Stefan Richter <stefanr@s5r6.in-berlin.de> wrote: > Dave Young wrote: > > Add the following class iteration functions for driver use: > > Thanks Dave. I will check the ieee1394 part in detail later. > > ... > > +/** > > + * class_find_device - device iterator for locating a particular device > > + * @class: the class we're iterating > > + * @data: data for the match function > > + * @match: function to check device > > + * > > + * This is similar to the class_for_each_dev() function above, but it > > + * returns a reference to a device that is 'found' for later use, as > > + * determined by the @match callback. > > Maybe add "Drop the reference with put_device() after use." for the > really slow driver programmers like me? Sounds good, thanks. > > > + * > > + * The callback should return 0 if the device doesn't match and non-zero > > + * if it does. If the callback returns non-zero, this function will > > + * return to the caller and not iterate over any more devices. > > + */ > > +struct device *class_find_device(struct class *class, void *data, > > + int (*match)(struct device *, void *)) > > +{ > > A general comment on the linux/device.h API (not a direct comment on > your patch): > > The match argument in bus_find_device(), driver_find_device(), > device_find_child(), class_find_device(), class_find_child() could be > changed to > > bool (*match)(struct device *, void *)). > > Then the semantics are IMO a little bit clearer. Ditto for the > dr_match_t type and the struct bus_type.match member. Yes, from semantics side it's better. But IMHO int is good as well, although it need a little bit more understanding of the api. > > I don't know though whether the churn of doing such a change everywhere > would be justified by the result. > > > A comment on patch 2/7...6/7: > > You can bring most or all of the various __match implementations into a > slightly terser but IMO easy to read form, like this: > > static int __match_ne(struct device *dev, void *data) > { > struct unit_directory *ud; > struct node_entry *ne = (struct node_entry *)data; > > ud = container_of(dev, struct unit_directory, unit_dev); > - if (ud->ne == ne) > - return 1; > - return 0; > + return ud->ne == ne; > } > > Here it is also easy to see that readability would improve if the return > type was bool rather than int. Ok, thanks. > -- > Stefan Richter > -=====-==--- ---= -==-- > http://arcgraph.de/sr/ >
next prev parent reply other threads:[~2008-01-14 1:32 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 [this message] 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 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=a8e1da0801131732t55238bf0u8e083b1754641c68@mail.gmail.com \ --to=hidave.darkstar@gmail.com \ --cc=James.Bottomley@hansenpartnership.com \ --cc=a.zummo@towertech.it \ --cc=cbou@mail.ru \ --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).