ps3: update ps3vram patches
[openwrt/svn-archive/archive.git] / target / linux / ps3 / patches-2.6.28 / 0012-mtd-ps3vram-Use-msleep-in-waits.patch
1 From 60c0c5987b0996a7c7c4c6d90f63ed413c368a71 Mon Sep 17 00:00:00 2001
2 From: Geoff Levand <geoffrey.levand@am.sony.com>
3 Date: Wed, 7 Jan 2009 17:22:02 -0800
4 Subject: [PATCH] mtd/ps3vram: Use msleep in waits
5
6 Replace the use of udelay() with msleep() in the looping wait routines
7 ps3vram_notifier_wait() and ps3vram_wait_ring().
8
9 Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
10 Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
11 ---
12 drivers/mtd/devices/ps3vram.c | 42 +++++++++++++++++-----------------------
13 1 files changed, 18 insertions(+), 24 deletions(-)
14
15 diff --git a/drivers/mtd/devices/ps3vram.c b/drivers/mtd/devices/ps3vram.c
16 index 91cc2af..d592414 100644
17 --- a/drivers/mtd/devices/ps3vram.c
18 +++ b/drivers/mtd/devices/ps3vram.c
19 @@ -109,22 +109,19 @@ static void ps3vram_notifier_reset(struct mtd_info *mtd)
20 notify[i] = 0xffffffff;
21 }
22
23 -static int ps3vram_notifier_wait(struct mtd_info *mtd, int timeout_ms)
24 +static int ps3vram_notifier_wait(struct mtd_info *mtd, unsigned int timeout_ms)
25 {
26 struct ps3vram_priv *priv = mtd->priv;
27 u32 *notify = ps3vram_get_notifier(priv->reports, NOTIFIER);
28 -
29 - timeout_ms *= 1000;
30 + unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
31
32 do {
33 - if (notify[3] == 0)
34 + if (!notify[3])
35 return 0;
36 + msleep(1);
37 + } while (time_before(jiffies, timeout));
38
39 - if (timeout_ms)
40 - udelay(1);
41 - } while (timeout_ms--);
42 -
43 - return -1;
44 + return -ETIMEDOUT;
45 }
46
47 static void ps3vram_init_ring(struct mtd_info *mtd)
48 @@ -135,25 +132,22 @@ static void ps3vram_init_ring(struct mtd_info *mtd)
49 priv->ctrl[CTRL_GET] = FIFO_BASE + FIFO_OFFSET;
50 }
51
52 -static int ps3vram_wait_ring(struct mtd_info *mtd, int timeout)
53 +static int ps3vram_wait_ring(struct mtd_info *mtd, unsigned int timeout_ms)
54 {
55 struct ps3vram_priv *priv = mtd->priv;
56 + unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
57
58 - /* wait until setup commands are processed */
59 - timeout *= 1000;
60 - while (--timeout) {
61 + do {
62 if (priv->ctrl[CTRL_PUT] == priv->ctrl[CTRL_GET])
63 - break;
64 - udelay(1);
65 - }
66 - if (timeout == 0) {
67 - dev_dbg(priv->dev, "%s:%d: FIFO timeout (%08x/%08x/%08x)\n",
68 - __func__, __LINE__, priv->ctrl[CTRL_PUT],
69 - priv->ctrl[CTRL_GET], priv->ctrl[CTRL_TOP]);
70 - return -ETIMEDOUT;
71 - }
72 + return 0;
73 + msleep(1);
74 + } while (time_before(jiffies, timeout));
75
76 - return 0;
77 + dev_dbg(priv->dev, "%s:%d: FIFO timeout (%08x/%08x/%08x)\n", __func__,
78 + __LINE__, priv->ctrl[CTRL_PUT], priv->ctrl[CTRL_GET],
79 + priv->ctrl[CTRL_TOP]);
80 +
81 + return -ETIMEDOUT;
82 }
83
84 static void ps3vram_out_ring(struct ps3vram_priv *priv, u32 data)
85 --
86 1.6.0.4
87