lkml.org 
[lkml]   [2010]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 23/24] drivers/block/floppy.c: Add function is_ready_state
On 20:26 Mon 25 Jan     , James Kosin wrote:
> On 1/23/2010 3:46 PM, Joe Perches wrote:
> > On Sat, 2010-01-23 at 12:32 -0500, James Kosin wrote:
> >
> >> On 1/22/2010 12:00 AM, Joe Perches wrote:
> >>
> >>> +static bool is_ready_state(int status)
> >>> +{
> >>> + int state = status& (STATUS_READY | STATUS_DIR | STATUS_DMA);
> >>> + return state == STATUS_READY;
> >>> +}
> >>> +
> >>>
> >> This should probably be simplified to:
> >>
> >> static bool is_ready_state(int status)
> >> {
> >> return ((state& STATUS_READY) == STATUS_READY);
> >> }
> >>
> > Certainly not.
> > That wouldn't be the same code.
> >
> > include/linux/fdreg.h:#define STATUS_DMA 0x20 /* 0- DMA mode */
> > include/linux/fdreg.h:#define STATUS_DIR 0x40 /* 0- cpu->fdc */
> > include/linux/fdreg.h:#define STATUS_READY 0x80 /* Data reg ready */
> >
> Read the code....
>
> It simplifies what is already there. The two other status flags make no
> difference in the test for equality with STATUS_READY.

Sure they do: the old code tests that the STATUS_READY is set and
both STATUS_DMA and STATUS_DIR bits are clear. So, for example, if
STATUS_READY and STATUS_DMA are both set, then the old test will return
false.

Your "simplification" has removed the check for those clear bits, and
will return true even if all three bits are set.

--
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)


\
 
 \ /
  Last update: 2010-01-26 16:09    [W:0.065 / U:3.652 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site