spi_s3c24xx: use dev_pm_ops
[linux-2.6-block.git] / drivers / spi / spi_s3c24xx.c
index 3f3119d760db71fc653b75e77615ce8069b7c300..03695b67ebd5484f0256eb0dae9ffcce09fce956 100644 (file)
 #include <linux/clk.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
+#include <linux/io.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
 
-#include <asm/io.h>
-#include <asm/dma.h>
-#include <mach/hardware.h>
-
 #include <plat/regs-spi.h>
 #include <mach/spi.h>
 
@@ -302,7 +299,7 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
                goto err_no_iores;
        }
 
-       hw->ioarea = request_mem_region(res->start, (res->end - res->start)+1,
+       hw->ioarea = request_mem_region(res->start, resource_size(res),
                                        pdev->name);
 
        if (hw->ioarea == NULL) {
@@ -311,7 +308,7 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
                goto err_no_iores;
        }
 
-       hw->regs = ioremap(res->start, (res->end - res->start)+1);
+       hw->regs = ioremap(res->start, resource_size(res));
        if (hw->regs == NULL) {
                dev_err(&pdev->dev, "Cannot map IO\n");
                err = -ENXIO;
@@ -388,7 +385,7 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
 
  err_no_iores:
  err_no_pdata:
-       spi_master_put(hw->master);;
+       spi_master_put(hw->master);
 
  err_nomem:
        return err;
@@ -421,9 +418,9 @@ static int __exit s3c24xx_spi_remove(struct platform_device *dev)
 
 #ifdef CONFIG_PM
 
-static int s3c24xx_spi_suspend(struct platform_device *pdev, pm_message_t msg)
+static int s3c24xx_spi_suspend(struct device *dev)
 {
-       struct s3c24xx_spi *hw = platform_get_drvdata(pdev);
+       struct s3c24xx_spi *hw = platform_get_drvdata(to_platform_device(dev));
 
        if (hw->pdata && hw->pdata->gpio_setup)
                hw->pdata->gpio_setup(hw->pdata, 0);
@@ -432,27 +429,31 @@ static int s3c24xx_spi_suspend(struct platform_device *pdev, pm_message_t msg)
        return 0;
 }
 
-static int s3c24xx_spi_resume(struct platform_device *pdev)
+static int s3c24xx_spi_resume(struct device *dev)
 {
-       struct s3c24xx_spi *hw = platform_get_drvdata(pdev);
+       struct s3c24xx_spi *hw = platform_get_drvdata(to_platform_device(dev));
 
        s3c24xx_spi_initialsetup(hw);
        return 0;
 }
 
+static struct dev_pm_ops s3c24xx_spi_pmops = {
+       .suspend        = s3c24xx_spi_suspend,
+       .resume         = s3c24xx_spi_resume,
+};
+
+#define S3C24XX_SPI_PMOPS &s3c24xx_spi_pmops
 #else
-#define s3c24xx_spi_suspend NULL
-#define s3c24xx_spi_resume  NULL
-#endif
+#define S3C24XX_SPI_PMOPS NULL
+#endif /* CONFIG_PM */
 
 MODULE_ALIAS("platform:s3c2410-spi");
 static struct platform_driver s3c24xx_spi_driver = {
        .remove         = __exit_p(s3c24xx_spi_remove),
-       .suspend        = s3c24xx_spi_suspend,
-       .resume         = s3c24xx_spi_resume,
        .driver         = {
                .name   = "s3c2410-spi",
                .owner  = THIS_MODULE,
+               .pm     = S3C24XX_SPI_PMOPS,
        },
 };