From: Tejun Heo <tj@kernel.org>
To: Elias Oltmanns <eo@nebensachen.de>
Cc: Jeff Garzik <jeff@garzik.org>,
IDE/ATA development list <linux-ide@vger.kernel.org>
Subject: Re: [PATCH #upstream-fixes 2/4] libata: beef up iterators
Date: Mon, 27 Oct 2008 18:06:46 +0900 [thread overview]
Message-ID: <490584A6.3020005@kernel.org> (raw)
In-Reply-To: <87tzaz77ix.fsf@denkblock.local>
Hello,
Elias Oltmanns wrote:
>> - ata_port_for_each_link(link, ap) {
>> - ata_link_for_each_dev(dev, link)
>> + ata_for_each_link(link, ap, EDGE) {
>> + ata_for_each_dev(dev, link, ALL)
>
> Where did these short forms (EDGE, ALL) spring from? Does this code even
> compile?
+#define ata_for_each_link(link, ap, mode) \
+ for ((link) = ata_link_next(NULL, (ap), ATA_LITER_##mode); (link); \
+ (link) = ata_link_next((link), (ap), ATA_LITER_##mode))
+
+#define ata_for_each_dev(dev, link, mode) \
+ for ((dev) = ata_dev_next(NULL, (link), ATA_DITER_##mode); (dev); \
+ (dev) = ata_dev_next((dev), (link), ATA_DITER_##mode))
>> @@ -2891,7 +2881,7 @@ static int ata_link_nr_vacant(struct ata
>> struct ata_device *dev;
>> int cnt = 0;
>>
>> - ata_link_for_each_dev(dev, link)
>> + ata_for_each_dev(dev, link, ALL)
>> if (dev->class == ATA_DEV_UNKNOWN)
>> cnt++;
>> return cnt;
>
> What about making the two above (ata_link_nr_*()) static inline while
> you are at it? Or is this another one of those cases where the compiler
> knows best anyway?
Yeah, it's a static function used only in single place. Should be
pretty straight forward for the compiler and even if it fails to
notice it, it doesn't hurt at all.
> [...]
>> Index: work/drivers/ata/libata-scsi.c
>> ===================================================================
>> --- work.orig/drivers/ata/libata-scsi.c
>> +++ work/drivers/ata/libata-scsi.c
> [...]
>> @@ -3254,9 +3254,9 @@ void ata_scsi_scan_host(struct ata_port
>> * failure occurred, scan would have failed silently. Check
>> * whether all devices are attached.
>> */
>> - ata_port_for_each_link(link, ap) {
>> - ata_link_for_each_dev(dev, link) {
>> - if (ata_dev_enabled(dev) && !dev->sdev)
>> + ata_for_each_link(link, ap, EDGE) {
>> + ata_for_each_dev(dev, link, ENABLED) {
>> + if (!dev->sdev)
>> goto exit_loop;
>> }
>> }
>
> Getting rid of those braces would make things even cleaner in my
> opinion. (That's my nit picking since Sergei picked on that comment
> formatting issue shortly before I was going to ;-) ).
Yeah, maybe. I don't know. The reason why I added braces there in
the first place was because emacs has some problem dealing with nested
non-standard looping constructs.
Thanks.
--
tejun
next prev parent reply other threads:[~2008-10-27 9:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-26 6:50 [PATCH #upstream-fixes 1/4] libata: fix device iteration bugs Tejun Heo
2008-10-26 6:51 ` [PATCH #upstream-fixes 2/4] libata: beef up iterators Tejun Heo
2008-10-26 6:51 ` [PATCH #upstream-fixes 3/4] libata: when restoring SControl during detach do the PMP links first Tejun Heo
2008-10-26 6:52 ` [PATCH #upstream-fixes 4/4] libata: perform port detach in EH Tejun Heo
2008-10-28 4:02 ` Jeff Garzik
2008-10-26 14:31 ` [PATCH #upstream-fixes 2/4] libata: beef up iterators Elias Oltmanns
2008-10-27 9:06 ` Tejun Heo [this message]
2008-10-27 9:39 ` Elias Oltmanns
2008-10-27 10:17 ` Tejun Heo
2008-10-27 11:58 ` Elias Oltmanns
2008-10-28 4:01 ` Jeff Garzik
2008-10-30 1:25 ` Mark Lord
2008-10-30 1:58 ` Jeff Garzik
2008-10-26 10:47 ` [PATCH #upstream-fixes 1/4] libata: fix device iteration bugs Sergei Shtylyov
2008-10-27 9:07 ` Tejun Heo
2008-10-27 10:59 ` [PATCH #upstream-fixes 1/4 UPDATED] " Tejun Heo
2008-10-28 3:57 ` Jeff Garzik
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=490584A6.3020005@kernel.org \
--to=tj@kernel.org \
--cc=eo@nebensachen.de \
--cc=jeff@garzik.org \
--cc=linux-ide@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).