diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:28 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:28 -0400 |
commit | af5dfe8cf07b6f4fbd6b7d8ff1aeda718fdd0166 (patch) | |
tree | e60609e67d0c91cedcfdc8517f2f7ebbacbbee3d /drivers/ide/pci/cmd640.c | |
parent | 151a670186a0f8441798f90c8701647adb7a1589 (diff) |
cmd640: add __set_prefetch_mode()
Factor out the common code from check_prefetch()
and set_prefetch_mode() to __set_prefetch_mode().
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci/cmd640.c')
-rw-r--r-- | drivers/ide/pci/cmd640.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index 5b756757e049..7f39cdb41410 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
@@ -374,6 +374,21 @@ static void cmd640_dump_regs(void) | |||
374 | } | 374 | } |
375 | #endif | 375 | #endif |
376 | 376 | ||
377 | static void __set_prefetch_mode(ide_drive_t *drive, int mode) | ||
378 | { | ||
379 | if (mode) { /* want prefetch on? */ | ||
380 | #if CMD640_PREFETCH_MASKS | ||
381 | drive->no_unmask = 1; | ||
382 | drive->unmask = 0; | ||
383 | #endif | ||
384 | drive->no_io_32bit = 0; | ||
385 | } else { | ||
386 | drive->no_unmask = 0; | ||
387 | drive->no_io_32bit = 1; | ||
388 | drive->io_32bit = 0; | ||
389 | } | ||
390 | } | ||
391 | |||
377 | #ifndef CONFIG_BLK_DEV_CMD640_ENHANCED | 392 | #ifndef CONFIG_BLK_DEV_CMD640_ENHANCED |
378 | /* | 393 | /* |
379 | * Check whether prefetch is on for a drive, | 394 | * Check whether prefetch is on for a drive, |
@@ -383,19 +398,10 @@ static void __init check_prefetch(ide_drive_t *drive, unsigned int index) | |||
383 | { | 398 | { |
384 | u8 b = get_cmd640_reg(prefetch_regs[index]); | 399 | u8 b = get_cmd640_reg(prefetch_regs[index]); |
385 | 400 | ||
386 | if (b & prefetch_masks[index]) { /* is prefetch off? */ | 401 | __set_prefetch_mode(drive, (b & prefetch_masks[index]) ? 0 : 1); |
387 | drive->no_unmask = 0; | ||
388 | drive->no_io_32bit = 1; | ||
389 | drive->io_32bit = 0; | ||
390 | } else { | ||
391 | #if CMD640_PREFETCH_MASKS | ||
392 | drive->no_unmask = 1; | ||
393 | drive->unmask = 0; | ||
394 | #endif | ||
395 | drive->no_io_32bit = 0; | ||
396 | } | ||
397 | } | 402 | } |
398 | #else | 403 | #else |
404 | |||
399 | /* | 405 | /* |
400 | * Sets prefetch mode for a drive. | 406 | * Sets prefetch mode for a drive. |
401 | */ | 407 | */ |
@@ -407,19 +413,11 @@ static void set_prefetch_mode(ide_drive_t *drive, unsigned int index, int mode) | |||
407 | 413 | ||
408 | spin_lock_irqsave(&cmd640_lock, flags); | 414 | spin_lock_irqsave(&cmd640_lock, flags); |
409 | b = __get_cmd640_reg(reg); | 415 | b = __get_cmd640_reg(reg); |
410 | if (mode) { /* want prefetch on? */ | 416 | __set_prefetch_mode(drive, mode); |
411 | #if CMD640_PREFETCH_MASKS | 417 | if (mode) |
412 | drive->no_unmask = 1; | ||
413 | drive->unmask = 0; | ||
414 | #endif | ||
415 | drive->no_io_32bit = 0; | ||
416 | b &= ~prefetch_masks[index]; /* enable prefetch */ | 418 | b &= ~prefetch_masks[index]; /* enable prefetch */ |
417 | } else { | 419 | else |
418 | drive->no_unmask = 0; | ||
419 | drive->no_io_32bit = 1; | ||
420 | drive->io_32bit = 0; | ||
421 | b |= prefetch_masks[index]; /* disable prefetch */ | 420 | b |= prefetch_masks[index]; /* disable prefetch */ |
422 | } | ||
423 | __put_cmd640_reg(reg, b); | 421 | __put_cmd640_reg(reg, b); |
424 | spin_unlock_irqrestore(&cmd640_lock, flags); | 422 | spin_unlock_irqrestore(&cmd640_lock, flags); |
425 | } | 423 | } |