Re: [PATCH 21/21] ide-floppy: remove atomic test_*bit macros

2008-01-12 Thread Bartlomiej Zolnierkiewicz
On Friday 11 January 2008, Borislav Petkov wrote:
 This change is temporary and after unification of the IDE subsystem proper
 bit setting and testing macros will be introduced.
 
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
 ---
  drivers/ide/ide-floppy.c |   82 
 +-
  1 files changed, 45 insertions(+), 37 deletions(-)
 
 diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
 index 4106eb4..29c1983 100644
 --- a/drivers/ide/ide-floppy.c
 +++ b/drivers/ide/ide-floppy.c
 @@ -479,12 +479,12 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t 
 *drive)
  
   debug_log(Reached %s interrupt handler\n, __FUNCTION__);
  
 - if (test_bit(PC_DMA_IN_PROGRESS, pc-flags)) {
 + if ((1UL  PC_DMA_IN_PROGRESS)  pc-flags) {

How's about introducing new defines i.e.

enum {
IDE_FLOPPY_FLAG_PC_ABORT= (1  0),
IDE_FLOPPY_FLAG_PC_DMA_RECOMMENDED  = (1  1),
IDE_FLOPPY_FLAG_PC_DMA_IN_PROGRESS  = (1  2),
...
}

instead of open-coding the bit-shifts?

   dma_error = HWIF(drive)-ide_dma_end(drive);
   if (dma_error) {
   printk(KERN_ERR %s: DMA %s error\n, drive-name,
   write ? write : read);
 - set_bit(PC_DMA_ERROR, pc-flags);
 + pc-flags |= (1UL  PC_DMA_ERROR);
   } else {
   pc-actually_transferred = pc-request_transfer;
   idefloppy_update_buffers(drive, pc);
 @@ -499,11 +499,11 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t 
 *drive)
   /* No more interrupts */
   debug_log(Packet command completed, %d bytes transferred\n,
   pc-actually_transferred);
 - clear_bit(PC_DMA_IN_PROGRESS, pc-flags);
 + pc-flags = ((1UL  PC_DMA_IN_PROGRESS) ^ ~0UL);

Same can be achieved with:

pc-flags = ~(1  PC_DMA_IN_PROGRESS);
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/21] ide-floppy: remove atomic test_*bit macros

2008-01-11 Thread Borislav Petkov
This change is temporary and after unification of the IDE subsystem proper
bit setting and testing macros will be introduced.

Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
---
 drivers/ide/ide-floppy.c |   82 +-
 1 files changed, 45 insertions(+), 37 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 4106eb4..29c1983 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -479,12 +479,12 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t 
*drive)
 
debug_log(Reached %s interrupt handler\n, __FUNCTION__);
 
-   if (test_bit(PC_DMA_IN_PROGRESS, pc-flags)) {
+   if ((1UL  PC_DMA_IN_PROGRESS)  pc-flags) {
dma_error = HWIF(drive)-ide_dma_end(drive);
if (dma_error) {
printk(KERN_ERR %s: DMA %s error\n, drive-name,
write ? write : read);
-   set_bit(PC_DMA_ERROR, pc-flags);
+   pc-flags |= (1UL  PC_DMA_ERROR);
} else {
pc-actually_transferred = pc-request_transfer;
idefloppy_update_buffers(drive, pc);
@@ -499,11 +499,11 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t 
*drive)
/* No more interrupts */
debug_log(Packet command completed, %d bytes transferred\n,
pc-actually_transferred);
-   clear_bit(PC_DMA_IN_PROGRESS, pc-flags);
+   pc-flags = ((1UL  PC_DMA_IN_PROGRESS) ^ ~0UL);
 
local_irq_enable_in_hardirq();
 
-   if ((stat  ERR_STAT) || test_bit(PC_DMA_ERROR, pc-flags)) {
+   if ((stat  ERR_STAT) || ((1UL  PC_DMA_ERROR)  pc-flags)) {
/* Error detected */
debug_log(I/O error\n, drive-name);
rq-errors++;
@@ -525,7 +525,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
return ide_stopped;
}
 
-   if (test_and_clear_bit(PC_DMA_IN_PROGRESS, pc-flags)) {
+   if ((1UL  PC_DMA_IN_PROGRESS)  pc-flags) {
+   pc-flags = ((1UL  PC_DMA_IN_PROGRESS) ^ ~0UL);
printk(KERN_ERR ide-floppy: The floppy wants to issue 
more interrupts in DMA mode\n);
ide_dma_off(drive);
@@ -704,13 +705,13 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t 
*drive,
floppy-pc = pc;
 
if (pc-retries  IDEFLOPPY_MAX_PC_RETRIES ||
-   test_bit(PC_ABORT, pc-flags)) {
+   ((1UL  PC_ABORT)  pc-flags)) {
/*
 *  We will abort retrying a packet command in case
 *  a legitimate error code was received.
 */
-   if (!test_bit(PC_ABORT, pc-flags)) {
-   if (!test_bit(PC_SUPPRESS_ERROR, pc-flags))
+   if (!((1UL  PC_ABORT)  pc-flags)) {
+   if (!((1UL  PC_SUPPRESS_ERROR)  pc-flags))
idefloppy_report_error(floppy, pc);
/* Giving up */
pc-error = IDEFLOPPY_ERROR_GENERAL;
@@ -728,12 +729,14 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t 
*drive,
pc-current_position = pc-buffer;
bcount = min(pc-request_transfer, 63 * 1024);
 
-   if (test_and_clear_bit(PC_DMA_ERROR, pc-flags))
+   if ((1UL  PC_DMA_ERROR)  pc-flags) {
+   pc-flags = ((1UL  PC_DMA_ERROR) ^ ~0UL);
ide_dma_off(drive);
+   }
 
dma = 0;
 
-   if (test_bit(PC_DMA_RECOMMENDED, pc-flags)  drive-using_dma)
+   if (((1UL  PC_DMA_RECOMMENDED)  pc-flags)  drive-using_dma)
dma = !hwif-dma_setup(drive);
 
ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK |
@@ -741,12 +744,12 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t 
*drive,
 
if (dma) {
/* Begin DMA, if necessary */
-   set_bit(PC_DMA_IN_PROGRESS, pc-flags);
+   pc-flags |= 1UL  PC_DMA_IN_PROGRESS;
hwif-dma_start(drive);
}
 
/* Can we transfer the packet when we get the interrupt or wait? */
-   if (test_bit(IDEFLOPPY_ZIP_DRIVE, floppy-flags)) {
+   if ((1UL  IDEFLOPPY_ZIP_DRIVE)  floppy-flags) {
/* wait */
pkt_xfer_routine = idefloppy_transfer_pc1;
} else {
@@ -754,7 +757,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t 
*drive,
pkt_xfer_routine = idefloppy_transfer_pc;
}
 
-   if (test_bit(IDEFLOPPY_DRQ_INTERRUPT, floppy-flags)) {
+   if ((1UL  IDEFLOPPY_DRQ_INTERRUPT)  floppy-flags) {
/* Issue the packet command */
ide_execute_command(drive, WIN_PACKETCMD,
pkt_xfer_routine,
@@ -812,7 +815,7 @@ static void