Commit 620859d1 authored by Domen Puncer's avatar Domen Puncer Committed by Linus Torvalds

[PATCH] macintosh/mediabay: replace schedule_timeout() with msleep_interruptible()

Use msleep_interruptible() instead of schedule_timeout() to guarantee the
task delays as expected.  Also remove macro MS_TO_HZ() and replace with
msecs_to_jiffies().
Signed-off-by: default avatarNishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: default avatarDomen Puncer <domen@coderock.org>
Acked-by: default avatar: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5014788d
...@@ -98,11 +98,6 @@ int media_bay_count = 0; ...@@ -98,11 +98,6 @@ int media_bay_count = 0;
#define MB_IDE_READY(i) ((readb(media_bays[i].cd_base + 0x70) & 0x80) == 0) #define MB_IDE_READY(i) ((readb(media_bays[i].cd_base + 0x70) & 0x80) == 0)
#endif #endif
/* Note: All delays are not in milliseconds and converted to HZ relative
* values by the macro below
*/
#define MS_TO_HZ(ms) ((ms * HZ + 999) / 1000)
/* /*
* Wait that number of ms between each step in normal polling mode * Wait that number of ms between each step in normal polling mode
*/ */
...@@ -384,7 +379,7 @@ static inline void __pmac set_mb_power(struct media_bay_info* bay, int onoff) ...@@ -384,7 +379,7 @@ static inline void __pmac set_mb_power(struct media_bay_info* bay, int onoff)
bay->state = mb_powering_down; bay->state = mb_powering_down;
MBDBG("mediabay%d: powering down\n", bay->index); MBDBG("mediabay%d: powering down\n", bay->index);
} }
bay->timer = MS_TO_HZ(MB_POWER_DELAY); bay->timer = msecs_to_jiffies(MB_POWER_DELAY);
} }
static void __pmac poll_media_bay(struct media_bay_info* bay) static void __pmac poll_media_bay(struct media_bay_info* bay)
...@@ -393,8 +388,8 @@ static void __pmac poll_media_bay(struct media_bay_info* bay) ...@@ -393,8 +388,8 @@ static void __pmac poll_media_bay(struct media_bay_info* bay)
if (id == bay->last_value) { if (id == bay->last_value) {
if (id != bay->content_id) { if (id != bay->content_id) {
bay->value_count += MS_TO_HZ(MB_POLL_DELAY); bay->value_count += msecs_to_jiffies(MB_POLL_DELAY);
if (bay->value_count >= MS_TO_HZ(MB_STABLE_DELAY)) { if (bay->value_count >= msecs_to_jiffies(MB_STABLE_DELAY)) {
/* If the device type changes without going thru /* If the device type changes without going thru
* "MB_NO", we force a pass by "MB_NO" to make sure * "MB_NO", we force a pass by "MB_NO" to make sure
* things are properly reset * things are properly reset
...@@ -504,7 +499,7 @@ static void __pmac media_bay_step(int i) ...@@ -504,7 +499,7 @@ static void __pmac media_bay_step(int i)
/* If timer expired or polling IDE busy, run state machine */ /* If timer expired or polling IDE busy, run state machine */
if ((bay->state != mb_ide_waiting) && (bay->timer != 0)) { if ((bay->state != mb_ide_waiting) && (bay->timer != 0)) {
bay->timer -= MS_TO_HZ(MB_POLL_DELAY); bay->timer -= msecs_to_jiffies(MB_POLL_DELAY);
if (bay->timer > 0) if (bay->timer > 0)
return; return;
bay->timer = 0; bay->timer = 0;
...@@ -517,13 +512,13 @@ static void __pmac media_bay_step(int i) ...@@ -517,13 +512,13 @@ static void __pmac media_bay_step(int i)
set_mb_power(bay, 0); set_mb_power(bay, 0);
break; break;
} }
bay->timer = MS_TO_HZ(MB_RESET_DELAY); bay->timer = msecs_to_jiffies(MB_RESET_DELAY);
bay->state = mb_enabling_bay; bay->state = mb_enabling_bay;
MBDBG("mediabay%d: enabling (kind:%d)\n", i, bay->content_id); MBDBG("mediabay%d: enabling (kind:%d)\n", i, bay->content_id);
break; break;
case mb_enabling_bay: case mb_enabling_bay:
bay->ops->un_reset(bay); bay->ops->un_reset(bay);
bay->timer = MS_TO_HZ(MB_SETUP_DELAY); bay->timer = msecs_to_jiffies(MB_SETUP_DELAY);
bay->state = mb_resetting; bay->state = mb_resetting;
MBDBG("mediabay%d: waiting reset (kind:%d)\n", i, bay->content_id); MBDBG("mediabay%d: waiting reset (kind:%d)\n", i, bay->content_id);
break; break;
...@@ -537,7 +532,7 @@ static void __pmac media_bay_step(int i) ...@@ -537,7 +532,7 @@ static void __pmac media_bay_step(int i)
#ifdef CONFIG_BLK_DEV_IDE #ifdef CONFIG_BLK_DEV_IDE
MBDBG("mediabay%d: waiting IDE reset (kind:%d)\n", i, bay->content_id); MBDBG("mediabay%d: waiting IDE reset (kind:%d)\n", i, bay->content_id);
bay->ops->un_reset_ide(bay); bay->ops->un_reset_ide(bay);
bay->timer = MS_TO_HZ(MB_IDE_WAIT); bay->timer = msecs_to_jiffies(MB_IDE_WAIT);
bay->state = mb_ide_resetting; bay->state = mb_ide_resetting;
#else #else
printk(KERN_DEBUG "media-bay %d is ide (not compiled in kernel)\n", i); printk(KERN_DEBUG "media-bay %d is ide (not compiled in kernel)\n", i);
...@@ -547,7 +542,7 @@ static void __pmac media_bay_step(int i) ...@@ -547,7 +542,7 @@ static void __pmac media_bay_step(int i)
#ifdef CONFIG_BLK_DEV_IDE #ifdef CONFIG_BLK_DEV_IDE
case mb_ide_resetting: case mb_ide_resetting:
bay->timer = MS_TO_HZ(MB_IDE_TIMEOUT); bay->timer = msecs_to_jiffies(MB_IDE_TIMEOUT);
bay->state = mb_ide_waiting; bay->state = mb_ide_waiting;
MBDBG("mediabay%d: waiting IDE ready (kind:%d)\n", i, bay->content_id); MBDBG("mediabay%d: waiting IDE ready (kind:%d)\n", i, bay->content_id);
break; break;
...@@ -583,7 +578,7 @@ static void __pmac media_bay_step(int i) ...@@ -583,7 +578,7 @@ static void __pmac media_bay_step(int i)
} }
break; break;
} else if (bay->timer > 0) } else if (bay->timer > 0)
bay->timer -= MS_TO_HZ(MB_POLL_DELAY); bay->timer -= msecs_to_jiffies(MB_POLL_DELAY);
if (bay->timer <= 0) { if (bay->timer <= 0) {
printk("\nIDE Timeout in bay %d !, IDE state is: 0x%02x\n", printk("\nIDE Timeout in bay %d !, IDE state is: 0x%02x\n",
i, readb(bay->cd_base + 0x70)); i, readb(bay->cd_base + 0x70));
...@@ -641,8 +636,7 @@ static int __pmac media_bay_task(void *x) ...@@ -641,8 +636,7 @@ static int __pmac media_bay_task(void *x)
up(&media_bays[i].lock); up(&media_bays[i].lock);
} }
current->state = TASK_INTERRUPTIBLE; msleep_interruptible(MB_POLL_DELAY);
schedule_timeout(MS_TO_HZ(MB_POLL_DELAY));
if (signal_pending(current)) if (signal_pending(current))
return 0; return 0;
} }
...@@ -691,7 +685,7 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_ma ...@@ -691,7 +685,7 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_ma
msleep(MB_POWER_DELAY); msleep(MB_POWER_DELAY);
bay->content_id = MB_NO; bay->content_id = MB_NO;
bay->last_value = bay->ops->content(bay); bay->last_value = bay->ops->content(bay);
bay->value_count = MS_TO_HZ(MB_STABLE_DELAY); bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY);
bay->state = mb_empty; bay->state = mb_empty;
do { do {
msleep(MB_POLL_DELAY); msleep(MB_POLL_DELAY);
...@@ -747,8 +741,8 @@ static int __pmac media_bay_resume(struct macio_dev *mdev) ...@@ -747,8 +741,8 @@ static int __pmac media_bay_resume(struct macio_dev *mdev)
} }
set_mb_power(bay, 1); set_mb_power(bay, 1);
bay->last_value = bay->content_id; bay->last_value = bay->content_id;
bay->value_count = MS_TO_HZ(MB_STABLE_DELAY); bay->value_count = msecs_to_jiffies(MB_STABLE_DELAY);
bay->timer = MS_TO_HZ(MB_POWER_DELAY); bay->timer = msecs_to_jiffies(MB_POWER_DELAY);
#ifdef CONFIG_BLK_DEV_IDE #ifdef CONFIG_BLK_DEV_IDE
bay->cd_retry = 0; bay->cd_retry = 0;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment