[ARM] MXC: remove _clk suffix from clock names
[safe/jmp/linux-2.6] / drivers / w1 / masters / ds1wm.c
index 763bc73..29e144f 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/pm.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/ds1wm.h>
 
@@ -85,7 +86,7 @@ static struct {
 };
 
 struct ds1wm_data {
-       void            *map;
+       void            __iomem *map;
        int             bus_shift; /* # of shifts to calc register offsets */
        struct platform_device *pdev;
        struct ds1wm_platform_data *pdata;
@@ -102,12 +103,12 @@ struct ds1wm_data {
 static inline void ds1wm_write_register(struct ds1wm_data *ds1wm_data, u32 reg,
                                        u8 val)
 {
-        __raw_writeb(val, ds1wm_data->map + (reg << ds1wm_data->bus_shift));
+       __raw_writeb(val, ds1wm_data->map + (reg << ds1wm_data->bus_shift));
 }
 
 static inline u8 ds1wm_read_register(struct ds1wm_data *ds1wm_data, u32 reg)
 {
-        return __raw_readb(ds1wm_data->map + (reg << ds1wm_data->bus_shift));
+       return __raw_readb(ds1wm_data->map + (reg << ds1wm_data->bus_shift));
 }
 
 
@@ -149,8 +150,8 @@ static int ds1wm_reset(struct ds1wm_data *ds1wm_data)
        timeleft = wait_for_completion_timeout(&reset_done, DS1WM_TIMEOUT);
        ds1wm_data->reset_complete = NULL;
        if (!timeleft) {
-                dev_dbg(&ds1wm_data->pdev->dev, "reset failed\n");
-                return 1;
+               dev_err(&ds1wm_data->pdev->dev, "reset failed\n");
+               return 1;
        }
 
        /* Wait for the end of the reset. According to the specs, the time
@@ -159,19 +160,21 @@ static int ds1wm_reset(struct ds1wm_data *ds1wm_data)
         *     625 us - 60 us - 240 us - 100 ns = 324.9 us
         *
         * We'll wait a bit longer just to be sure.
+        * Was udelay(500), but if it is going to busywait the cpu that long,
+        * might as well come back later.
         */
-       udelay(500);
+       msleep(1);
 
        ds1wm_write_register(ds1wm_data, DS1WM_INT_EN,
                DS1WM_INTEN_ERBF | DS1WM_INTEN_ETMT | DS1WM_INTEN_EPD |
                (ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0));
 
        if (!ds1wm_data->slave_present) {
-                dev_dbg(&ds1wm_data->pdev->dev, "reset: no devices found\n");
-                return 1;
-        }
+               dev_dbg(&ds1wm_data->pdev->dev, "reset: no devices found\n");
+               return 1;
+       }
 
-        return 0;
+       return 0;
 }
 
 static int ds1wm_write(struct ds1wm_data *ds1wm_data, u8 data)
@@ -273,8 +276,8 @@ static u8 ds1wm_reset_bus(void *data)
        return 0;
 }
 
-static void ds1wm_search(void *data, u8 search_type,
-                        w1_slave_found_callback slave_found)
+static void ds1wm_search(void *data, struct w1_master *master_dev,
+                       u8 search_type, w1_slave_found_callback slave_found)
 {
        struct ds1wm_data *ds1wm_data = data;
        int i;
@@ -307,12 +310,12 @@ static void ds1wm_search(void *data, u8 search_type,
                rom_id |= (unsigned long long) r << (i * 4);
 
        }
-       dev_dbg(&ds1wm_data->pdev->dev, "found 0x%08llX", rom_id);
+       dev_dbg(&ds1wm_data->pdev->dev, "found 0x%08llX\n", rom_id);
 
        ds1wm_write_register(ds1wm_data, DS1WM_CMD, ~DS1WM_CMD_SRA);
        ds1wm_reset(ds1wm_data);
 
-       slave_found(ds1wm_data, rom_id);
+       slave_found(master_dev, rom_id);
 }
 
 /* --------------------------------------------------------------------- */
@@ -334,7 +337,7 @@ static int ds1wm_probe(struct platform_device *pdev)
        if (!pdev)
                return -ENODEV;
 
-       ds1wm_data = kzalloc(sizeof (*ds1wm_data), GFP_KERNEL);
+       ds1wm_data = kzalloc(sizeof(*ds1wm_data), GFP_KERNEL);
        if (!ds1wm_data)
                return -ENOMEM;
 
@@ -361,11 +364,12 @@ static int ds1wm_probe(struct platform_device *pdev)
                goto err1;
        }
        ds1wm_data->irq = res->start;
-       ds1wm_data->active_high = (res->flags & IORESOURCE_IRQ_HIGHEDGE) ?
-               1 : 0;
+       ds1wm_data->active_high = plat->active_high;
 
-       set_irq_type(ds1wm_data->irq, ds1wm_data->active_high ?
-                       IRQ_TYPE_EDGE_RISING : IRQ_TYPE_EDGE_FALLING);
+       if (res->flags & IORESOURCE_IRQ_HIGHEDGE)
+               set_irq_type(ds1wm_data->irq, IRQ_TYPE_EDGE_RISING);
+       if (res->flags & IORESOURCE_IRQ_LOWEDGE)
+               set_irq_type(ds1wm_data->irq, IRQ_TYPE_EDGE_FALLING);
 
        ret = request_irq(ds1wm_data->irq, ds1wm_isr, IRQF_DISABLED,
                          "ds1wm", ds1wm_data);
@@ -373,8 +377,8 @@ static int ds1wm_probe(struct platform_device *pdev)
                goto err1;
 
        ds1wm_data->clk = clk_get(&pdev->dev, "ds1wm");
-       if (!ds1wm_data->clk) {
-               ret = -ENOENT;
+       if (IS_ERR(ds1wm_data->clk)) {
+               ret = PTR_ERR(ds1wm_data->clk);
                goto err2;
        }