include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / i2c / busses / i2c-pxa.c
index e4ee883..14d249f 100644 (file)
@@ -12,7 +12,7 @@
  *
  *  History:
  *    Apr 2002: Initial version [CS]
- *    Jun 2002: Properly seperated algo/adap [FB]
+ *    Jun 2002: Properly separated algo/adap [FB]
  *    Jan 2003: Fixed several bugs concerning interrupt handling [Kai-Uwe Bloem]
  *    Jan 2003: added limited signal handling [Kai-Uwe Bloem]
  *    Sep 2004: Major rework to ensure efficient bus handling [RMK]
 #include <linux/platform_device.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 #include <asm/io.h>
-#include <mach/i2c.h>
+#include <plat/i2c.h>
 
 /*
  * I2C register offsets will be shifted 0 or 1 bit left, depending on
@@ -993,7 +994,6 @@ static const struct i2c_algorithm i2c_pxa_pio_algorithm = {
        .functionality  = i2c_pxa_functionality,
 };
 
-#define res_len(r)             ((r)->end - (r)->start + 1)
 static int i2c_pxa_probe(struct platform_device *dev)
 {
        struct pxa_i2c *i2c;
@@ -1008,7 +1008,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
        if (res == NULL || irq < 0)
                return -ENODEV;
 
-       if (!request_mem_region(res->start, res_len(res), res->name))
+       if (!request_mem_region(res->start, resource_size(res), res->name))
                return -ENOMEM;
 
        i2c = kzalloc(sizeof(struct pxa_i2c), GFP_KERNEL);
@@ -1038,7 +1038,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
                goto eclk;
        }
 
-       i2c->reg_base = ioremap(res->start, res_len(res));
+       i2c->reg_base = ioremap(res->start, resource_size(res));
        if (!i2c->reg_base) {
                ret = -EIO;
                goto eremap;
@@ -1046,7 +1046,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
        i2c->reg_shift = REG_SHIFT(id->driver_data);
 
        i2c->iobase = res->start;
-       i2c->iosize = res_len(res);
+       i2c->iosize = resource_size(res);
 
        i2c->irq = irq;
 
@@ -1110,7 +1110,7 @@ eremap:
 eclk:
        kfree(i2c);
 emalloc:
-       release_mem_region(res->start, res_len(res));
+       release_mem_region(res->start, resource_size(res));
        return ret;
 }
 
@@ -1135,35 +1135,44 @@ static int __exit i2c_pxa_remove(struct platform_device *dev)
 }
 
 #ifdef CONFIG_PM
-static int i2c_pxa_suspend_late(struct platform_device *dev, pm_message_t state)
+static int i2c_pxa_suspend_noirq(struct device *dev)
 {
-       struct pxa_i2c *i2c = platform_get_drvdata(dev);
+       struct platform_device *pdev = to_platform_device(dev);
+       struct pxa_i2c *i2c = platform_get_drvdata(pdev);
+
        clk_disable(i2c->clk);
+
        return 0;
 }
 
-static int i2c_pxa_resume_early(struct platform_device *dev)
+static int i2c_pxa_resume_noirq(struct device *dev)
 {
-       struct pxa_i2c *i2c = platform_get_drvdata(dev);
+       struct platform_device *pdev = to_platform_device(dev);
+       struct pxa_i2c *i2c = platform_get_drvdata(pdev);
 
        clk_enable(i2c->clk);
        i2c_pxa_reset(i2c);
 
        return 0;
 }
+
+static const struct dev_pm_ops i2c_pxa_dev_pm_ops = {
+       .suspend_noirq = i2c_pxa_suspend_noirq,
+       .resume_noirq = i2c_pxa_resume_noirq,
+};
+
+#define I2C_PXA_DEV_PM_OPS (&i2c_pxa_dev_pm_ops)
 #else
-#define i2c_pxa_suspend_late NULL
-#define i2c_pxa_resume_early NULL
+#define I2C_PXA_DEV_PM_OPS NULL
 #endif
 
 static struct platform_driver i2c_pxa_driver = {
        .probe          = i2c_pxa_probe,
        .remove         = __exit_p(i2c_pxa_remove),
-       .suspend_late   = i2c_pxa_suspend_late,
-       .resume_early   = i2c_pxa_resume_early,
        .driver         = {
                .name   = "pxa2xx-i2c",
                .owner  = THIS_MODULE,
+               .pm     = I2C_PXA_DEV_PM_OPS,
        },
        .id_table       = i2c_pxa_id_table,
 };