]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/spi/spi_mpc8xxx.c
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[mv-sheeva.git] / drivers / spi / spi_mpc8xxx.c
index 1fb2a6ea328cfcff9ce8ec3a03700f3bec729947..14d052316502cfcf7334cbb57cf5181e02c2c3be 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/gpio.h>
 #include <linux/of_gpio.h>
 #include <linux/of_spi.h>
+#include <linux/slab.h>
 
 #include <sysdev/fsl_soc.h>
 #include <asm/cpm.h>
@@ -365,7 +366,7 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 
        if ((mpc8xxx_spi->spibrg / hz) > 64) {
                cs->hw_mode |= SPMODE_DIV16;
-               pm = mpc8xxx_spi->spibrg / (hz * 64);
+               pm = (mpc8xxx_spi->spibrg - 1) / (hz * 64) + 1;
 
                WARN_ONCE(pm > 16, "%s: Requested speed is too low: %d Hz. "
                          "Will use %d Hz instead.\n", dev_name(&spi->dev),
@@ -373,7 +374,7 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
                if (pm > 16)
                        pm = 16;
        } else
-               pm = mpc8xxx_spi->spibrg / (hz * 4);
+               pm = (mpc8xxx_spi->spibrg - 1) / (hz * 4) + 1;
        if (pm)
                pm--;
 
@@ -1328,7 +1329,7 @@ static struct of_platform_driver of_mpc8xxx_spi_driver = {
 static int __devinit plat_mpc8xxx_spi_probe(struct platform_device *pdev)
 {
        struct resource *mem;
-       unsigned int irq;
+       int irq;
        struct spi_master *master;
 
        if (!pdev->dev.platform_data)
@@ -1339,7 +1340,7 @@ static int __devinit plat_mpc8xxx_spi_probe(struct platform_device *pdev)
                return -EINVAL;
 
        irq = platform_get_irq(pdev, 0);
-       if (!irq)
+       if (irq <= 0)
                return -EINVAL;
 
        master = mpc8xxx_spi_probe(&pdev->dev, mem, irq);