Re: [PATCH] 2.5.10 IDE 42

Linus Torvalds
2002-04-26T17:37:59Z

On Fri, 26 Apr 2002, Pavel Machek wrote:
> > + if (stat & READY_STAT)
> > + printk("DriveReady ");
> > + if (stat & WRERR_STAT)
> > + printk("DeviceFault ");
> > + if (stat & SEEK_STAT)
> > + printk("SeekComplete ");
> > + if (stat & DRQ_STAT)
> > + printk("DataRequest ");
> > + if (stat & ECC_STAT)
> > + printk("CorrectedError ");
> > + if (stat & INDEX_STAT)
> > + printk("Index ");
> > + if (stat & ERR_STAT)
> > + printk("Error ");
>
> I believe this is actually making it *less* readable.

Somewhat agreed. Also, the above is just not the right way to do
printouts.

I'd suggest rewriting the whole big mess as something like

#define STAT_STR(x,s) \
((stat & x ##_STAT) ? s " " : "")

...

printf("IDE: %s%s%s%s%s%s..\n"
STAT_STR(READY, "DriveReady"),
STAT_STR(WERR, "DeviceFault"),
...

which is pretty certain to generate much smaller code (not to mention
smaller sources).

Linus