diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/macintosh/mediabay.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c index 818aba368541..b1e5b4705250 100644 --- a/drivers/macintosh/mediabay.c +++ b/drivers/macintosh/mediabay.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/ide.h> | 22 | #include <linux/ide.h> |
23 | #include <linux/kthread.h> | 23 | #include <linux/kthread.h> |
24 | #include <linux/mutex.h> | ||
24 | #include <asm/prom.h> | 25 | #include <asm/prom.h> |
25 | #include <asm/pgtable.h> | 26 | #include <asm/pgtable.h> |
26 | #include <asm/io.h> | 27 | #include <asm/io.h> |
@@ -77,7 +78,7 @@ struct media_bay_info { | |||
77 | int index; | 78 | int index; |
78 | int cached_gpio; | 79 | int cached_gpio; |
79 | int sleeping; | 80 | int sleeping; |
80 | struct semaphore lock; | 81 | struct mutex lock; |
81 | #ifdef CONFIG_BLK_DEV_IDE_PMAC | 82 | #ifdef CONFIG_BLK_DEV_IDE_PMAC |
82 | ide_hwif_t *cd_port; | 83 | ide_hwif_t *cd_port; |
83 | void __iomem *cd_base; | 84 | void __iomem *cd_base; |
@@ -459,27 +460,27 @@ int media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base, | |||
459 | if (bay->mdev && which_bay == bay->mdev->ofdev.node) { | 460 | if (bay->mdev && which_bay == bay->mdev->ofdev.node) { |
460 | int timeout = 5000, index = hwif->index; | 461 | int timeout = 5000, index = hwif->index; |
461 | 462 | ||
462 | down(&bay->lock); | 463 | mutex_lock(&bay->lock); |
463 | 464 | ||
464 | bay->cd_port = hwif; | 465 | bay->cd_port = hwif; |
465 | bay->cd_base = (void __iomem *) base; | 466 | bay->cd_base = (void __iomem *) base; |
466 | bay->cd_irq = irq; | 467 | bay->cd_irq = irq; |
467 | 468 | ||
468 | if ((MB_CD != bay->content_id) || bay->state != mb_up) { | 469 | if ((MB_CD != bay->content_id) || bay->state != mb_up) { |
469 | up(&bay->lock); | 470 | mutex_unlock(&bay->lock); |
470 | return 0; | 471 | return 0; |
471 | } | 472 | } |
472 | printk(KERN_DEBUG "Registered ide%d for media bay %d\n", index, i); | 473 | printk(KERN_DEBUG "Registered ide%d for media bay %d\n", index, i); |
473 | do { | 474 | do { |
474 | if (MB_IDE_READY(i)) { | 475 | if (MB_IDE_READY(i)) { |
475 | bay->cd_index = index; | 476 | bay->cd_index = index; |
476 | up(&bay->lock); | 477 | mutex_unlock(&bay->lock); |
477 | return 0; | 478 | return 0; |
478 | } | 479 | } |
479 | mdelay(1); | 480 | mdelay(1); |
480 | } while(--timeout); | 481 | } while(--timeout); |
481 | printk(KERN_DEBUG "Timeount waiting IDE in bay %d\n", i); | 482 | printk(KERN_DEBUG "Timeount waiting IDE in bay %d\n", i); |
482 | up(&bay->lock); | 483 | mutex_unlock(&bay->lock); |
483 | return -ENODEV; | 484 | return -ENODEV; |
484 | } | 485 | } |
485 | } | 486 | } |
@@ -617,10 +618,10 @@ static int media_bay_task(void *x) | |||
617 | 618 | ||
618 | while (!kthread_should_stop()) { | 619 | while (!kthread_should_stop()) { |
619 | for (i = 0; i < media_bay_count; ++i) { | 620 | for (i = 0; i < media_bay_count; ++i) { |
620 | down(&media_bays[i].lock); | 621 | mutex_lock(&media_bays[i].lock); |
621 | if (!media_bays[i].sleeping) | 622 | if (!media_bays[i].sleeping) |
622 | media_bay_step(i); | 623 | media_bay_step(i); |
623 | up(&media_bays[i].lock); | 624 | mutex_unlock(&media_bays[i].lock); |
624 | } | 625 | } |
625 | 626 | ||
626 | msleep_interruptible(MB_POLL_DELAY); | 627 | msleep_interruptible(MB_POLL_DELAY); |
@@ -660,7 +661,7 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de | |||
660 | bay->index = i; | 661 | bay->index = i; |
661 | bay->ops = match->data; | 662 | bay->ops = match->data; |
662 | bay->sleeping = 0; | 663 | bay->sleeping = 0; |
663 | init_MUTEX(&bay->lock); | 664 | mutex_init(&bay->lock); |
664 | 665 | ||
665 | /* Init HW probing */ | 666 | /* Init HW probing */ |
666 | if (bay->ops->init) | 667 | if (bay->ops->init) |
@@ -698,10 +699,10 @@ static int media_bay_suspend(struct macio_dev *mdev, pm_message_t state) | |||
698 | 699 | ||
699 | if (state.event != mdev->ofdev.dev.power.power_state.event | 700 | if (state.event != mdev->ofdev.dev.power.power_state.event |
700 | && (state.event & PM_EVENT_SLEEP)) { | 701 | && (state.event & PM_EVENT_SLEEP)) { |
701 | down(&bay->lock); | 702 | mutex_lock(&bay->lock); |
702 | bay->sleeping = 1; | 703 | bay->sleeping = 1; |
703 | set_mb_power(bay, 0); | 704 | set_mb_power(bay, 0); |
704 | up(&bay->lock); | 705 | mutex_unlock(&bay->lock); |
705 | msleep(MB_POLL_DELAY); | 706 | msleep(MB_POLL_DELAY); |
706 | mdev->ofdev.dev.power.power_state = state; | 707 | mdev->ofdev.dev.power.power_state = state; |
707 | } | 708 | } |
@@ -720,12 +721,12 @@ static int media_bay_resume(struct macio_dev *mdev) | |||
720 | they seem to help the 3400 get it right. | 721 | they seem to help the 3400 get it right. |
721 | */ | 722 | */ |
722 | /* Force MB power to 0 */ | 723 | /* Force MB power to 0 */ |
723 | down(&bay->lock); | 724 | mutex_lock(&bay->lock); |
724 | set_mb_power(bay, 0); | 725 | set_mb_power(bay, 0); |
725 | msleep(MB_POWER_DELAY); | 726 | msleep(MB_POWER_DELAY); |
726 | if (bay->ops->content(bay) != bay->content_id) { | 727 | if (bay->ops->content(bay) != bay->content_id) { |
727 | printk("mediabay%d: content changed during sleep...\n", bay->index); | 728 | printk("mediabay%d: content changed during sleep...\n", bay->index); |
728 | up(&bay->lock); | 729 | mutex_unlock(&bay->lock); |
729 | return 0; | 730 | return 0; |
730 | } | 731 | } |
731 | set_mb_power(bay, 1); | 732 | set_mb_power(bay, 1); |
@@ -741,7 +742,7 @@ static int media_bay_resume(struct macio_dev *mdev) | |||
741 | } while((bay->state != mb_empty) && | 742 | } while((bay->state != mb_empty) && |
742 | (bay->state != mb_up)); | 743 | (bay->state != mb_up)); |
743 | bay->sleeping = 0; | 744 | bay->sleeping = 0; |
744 | up(&bay->lock); | 745 | mutex_unlock(&bay->lock); |
745 | } | 746 | } |
746 | return 0; | 747 | return 0; |
747 | } | 748 | } |