drivers/block/floppy.c: Add function is_ready_state
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 12 lines · Joe Perches
Used a couple of times, might simplify the code a bit.
Signed-off-by Joe Perches<[email protected]>--- drivers/block/floppy.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-)drivers/block/floppy.c +0
-0
drivers/block/floppy.c static inline int is_selected(int dor, int unit) · line 790
Quoted 9 lines
drivers/block/floppy.c +6
-0@@ -782,6 +782,12 @@ static inline int is_selected(int dor, int unit)return ((dor& (0x10 << unit))&& (dor&3 ) == unit); } +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);
}James
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 33 lines · Joe Perches
Quoted 26 lines · James Kosin
Quoted 12 lines · Joe Perches
Used a couple of times, might simplify the code a bit.
Signed-off-by Joe Perches<[email protected]>--- drivers/block/floppy.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-)drivers/block/floppy.c +0
-0drivers/block/floppy.c static inline int is_selected(int dor, int unit) · line 791
Quoted 10 lines
drivers/block/floppy.c +6
-0@@ -782,6 +782,12 @@ static inline int is_selected(int dor, int unit)return ((dor& (0x10 << unit))&& (dor&3 ) == unit); } +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:
Quoted 5 lines
static bool
is_ready_state(int status){ return ((state& STATUS_READY) == STATUS_READY); }
Quoted 9 lines
Certainly not.
That wouldn't be the same code.include/linux/fdreg.h:#define
STATUS_DMA0x20/* 0- DMA mode */
include/linux/fdreg.h:#defineSTATUS_DIR0x40/* 0-cpu->fdc*/
include/linux/fdreg.h:#defineSTATUS_READY0x80/* 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.
James
Quoted 22 lines · James Kosin
Quoted 21 lines · Joe Perches
Quoted 11 lines · James Kosin
Review
Quoted 7 lines · Joe Perches
(quoted diff) +6
-0+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:
Quoted 5 lines
static bool
is_ready_state(int status){ return ((state& STATUS_READY) == STATUS_READY); }Certainly not.
That wouldn't be the same code.
Quoted 8 lines
Quoted 4 lines
include/linux/fdreg.h:#define
STATUS_DMA0x20/* 0- DMA mode */
include/linux/fdreg.h:#defineSTATUS_DIR0x40/* 0-cpu->fdc*/
include/linux/fdreg.h:#defineSTATUS_READY0x80/* 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.
Signature · 1 line
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)
Quoted 33 lines · Joe Perches
Quoted 26 lines · James Kosin
Quoted 12 lines · Joe Perches
Used a couple of times, might simplify the code a bit.
Signed-off-by Joe Perches<[email protected]>--- drivers/block/floppy.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-)drivers/block/floppy.c +0
-0drivers/block/floppy.c static inline int is_selected(int dor, int unit) · line 791
Quoted 10 lines
drivers/block/floppy.c +6
-0@@ -782,6 +782,12 @@ static inline int is_selected(int dor, int unit)return ((dor& (0x10 << unit))&& (dor&3 ) == unit); } +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:
Quoted 5 lines
static bool
is_ready_state(int status){ return ((state& STATUS_READY) == STATUS_READY); }
Quoted 9 lines
Certainly not.
That wouldn't be the same code.include/linux/fdreg.h:#define
STATUS_DMA0x20/* 0- DMA mode */
include/linux/fdreg.h:#defineSTATUS_DIR0x40/* 0-cpu->fdc*/
include/linux/fdreg.h:#defineSTATUS_READY0x80/* Data reg ready */
Sorry,
That probably should have been:
return ((status & STATUS_READY) == STATUS_READY);
James