From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: petkovbb@gmail.com
Cc: Sam Ravnborg <sam@ravnborg.org>,
linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/10] ide: flags query macros
Date: Thu, 26 Feb 2009 22:35:58 +0100 [thread overview]
Message-ID: <200902262235.58796.bzolnier@gmail.com> (raw)
In-Reply-To: <20090223082539.GA24465@gollum.tnic>
On Monday 23 February 2009, Borislav Petkov wrote:
> On Mon, Feb 23, 2009 at 08:34:52AM +0100, Sam Ravnborg wrote:
> > On Mon, Feb 23, 2009 at 08:04:13AM +0100, Borislav Petkov wrote:
> > > > Since it is not a lot of modified lines and the change is rather
> > > > straightforward it could as well be done in a single patch...
> > >
> > > here's version 2:
> > > --
> > > From: Borislav Petkov <petkovbb@gmail.com>
> > > Date: Mon, 23 Feb 2009 07:58:23 +0100
> > > Subject: [PATCH] ide: flags query macros
> > >
> > > Add drive->atapi_flags and drive->dev_flags macro wrappers
> > >
> > > v2:
> > > - use static inlines for better typechecking
> > > - use macro indirection for convenience
> > >
> > > Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
> >
> > Version 2 looks much better - thanks.
Yep, definitely an improvement.
Unfortunately my main concern is still not addressed -- namely the lack of
consistency between names of flags and names of inline functions, ie.:
- i, (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT) ? "off" : "on");
+ i, ide_dev_no_32bit_io(drive) ? "off" : "on");
This is really the major issue because introduction of this abstraction
was supposed to make code more readable and maintainable...
With the current version I get exactly the opposite feeling:
- we have now different naming used for flags and inline functions
- we use inline functions only for checking if flags are set
My other complaint is about changing my beloved CodingStyle, i.e.:
- if (drive->media != ide_disk ||
- (drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
+ if (drive->media != ide_disk || !ide_dev_present(drive))
select |= HT_PREFETCH_MODE;
I see '== 0' immediately while it takes a while to notice '!' (funny that
long time ago I preferred '!' because it's shorter but in the practice it
turns out to be less readable and more prone to cause subtle bugs during
code changes, though YMMV).
Also after checking the code I think ide_{d,a}flag_ naming is better
as it doesn't overlap with normal ide code...
> > diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
> > index df3df00..3553759 100644
> > --- a/drivers/ide/ide-cd_ioctl.c
> > +++ b/drivers/ide/ide-cd_ioctl.c
> > @@ -86,7 +86,7 @@ int ide_cdrom_check_media_change_real(struct cdrom_device_info *cdi,
> >
> > if (slot_nr == CDSL_CURRENT) {
> > (void) cdrom_check_status(drive, NULL);
> > - retval = (drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED) ? 1 : 0;
> > + retval = ide_dev_media_changed(drive) ? 1 : 0;
> > drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
> > return retval;
> > } else {
> >
> > The use of ? 1 : 0; here is redundant.
> >
> > if (drive->media == ide_disk) {
> > - printk(KERN_INFO "%s: non-IDE drive, CHS=%d/%d/%d\n",
> > + pr_info("%s: non-IDE drive, CHS=%d/%d/%d\n",
> > drive->name, drive->cyl,
> > drive->head, drive->sect);
> > } else if (drive->media == ide_cdrom) {
> > - printk(KERN_INFO "%s: ATAPI cdrom (?)\n", drive->name);
> > + pr_info("%s: ATAPI cdrom (?)\n", drive->name);
> > } else {
> > /* nuke it */
> > - printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n",
> > +drive->name);
> > + pr_warning("%s: Unknown device on bus refused "
> > + "identification, ignoring.\n",
> > + drive->name);
> > I did not see this addressed in the changelog?
>
> Actually, that was in the v1 changelog but got forgotten. Bart, can you
> please add to the changelog
>
> - shorten >80 lines
What about printk() -> pr_info()/pr_warning()?
[ Which brings us to consistency issues again -- do you plan to convert
whole IDE code to use pr_*()? If yes, great but please do it in separate
patches -- I think that converting only some printk()s is not worth it. ]
Please spend more time on documenting your changes properly.
You don't have to write a poem ;) but for reviewer it is important
to know if changes are intentional or accidental (since it could be
as well unintentional left-over from your private tree)...
> > drive->dev_flags &= ~IDE_DFLAG_PRESENT;
> >
> > You have a nice set of inlines to facilitate testing bits,
> > but not for the above use?
> > I guess this was not worth the abstraction for now.
>
> Yeah, those are next but I'd like to wait a bit until ide rewrite
> settles...
This should happen in this patch to keep the consistency, moreover since
you introduced nice macros to define "test" helpers you can now easily extend
them for "clear" ones, i.e.:
+#define IDE_AFLAG_(name, flag) \
+static inline int ide_test_aflag_##name(ide_drive_t *drive) \
+{ \
+ return !!(drive->atapi_flags & flag); \
+} \
+static inline void ide_clear_aflag_##name(ide_drive_t *drive) \
+{ \
+ drive->atapi_flags &= ~flag; \
+}
BTW you may want to delay this patch after 2.6.30 as things should
become much more peaceful then.
Thanks,
Bart
next prev parent reply other threads:[~2009-02-26 21:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-15 12:08 [PATCH 0/10] ide: flags query macros Borislav Petkov
2009-02-15 12:08 ` [PATCH 01/10] ide: add " Borislav Petkov
2009-02-15 13:35 ` Sam Ravnborg
2009-02-15 18:01 ` Borislav Petkov
2009-02-15 20:51 ` Sam Ravnborg
2009-02-16 21:07 ` Bartlomiej Zolnierkiewicz
2009-02-15 12:08 ` [PATCH 02/10] ide-cd: use " Borislav Petkov
2009-02-15 12:08 ` [PATCH 03/10] ide-floppy: " Borislav Petkov
2009-02-15 12:08 ` [PATCH 04/10] ide-tape: " Borislav Petkov
2009-02-15 12:08 ` [PATCH 05/10] ide-atapi: " Borislav Petkov
2009-02-15 12:08 ` [PATCH 06/10] ide-disk: " Borislav Petkov
2009-02-15 12:08 ` [PATCH 07/10] ide-devsets: " Borislav Petkov
2009-02-15 12:08 ` [PATCH 08/10] ide-eh: " Borislav Petkov
2009-02-15 12:08 ` [PATCH 09/10] ide-probe: " Borislav Petkov
2009-02-15 12:08 ` [PATCH 10/10] ide: use flags query macros in the remaining ide code Borislav Petkov
2009-02-16 22:17 ` [PATCH 0/10] ide: flags query macros Bartlomiej Zolnierkiewicz
2009-02-17 14:33 ` Bartlomiej Zolnierkiewicz
2009-02-23 7:04 ` Borislav Petkov
2009-02-23 7:34 ` Sam Ravnborg
2009-02-23 8:25 ` Borislav Petkov
2009-02-26 21:35 ` Bartlomiej Zolnierkiewicz [this message]
2009-02-27 6:38 ` Borislav Petkov
2009-02-27 8:21 ` Bartlomiej Zolnierkiewicz
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=200902262235.58796.bzolnier@gmail.com \
--to=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=petkovbb@gmail.com \
--cc=sam@ravnborg.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).