spi: spi_txx9.c: use resource_size()
[linux-2.6-block.git] / drivers / spi / spi_txx9.c
index 29cbb065618a048cdffdffd6cedd4ccee1232106..c166eb5ad3c501ddbe718fe68c1b9fb13e7ce89e 100644 (file)
@@ -110,23 +110,17 @@ static void txx9spi_cs_func(struct spi_device *spi, struct txx9spi *c,
        ndelay(cs_delay);       /* CS Setup Time / CS Recovery Time */
 }
 
-/* the spi->mode bits understood by this driver: */
-#define MODEBITS       (SPI_CS_HIGH|SPI_CPOL|SPI_CPHA)
-
 static int txx9spi_setup(struct spi_device *spi)
 {
        struct txx9spi *c = spi_master_get_devdata(spi->master);
        u8 bits_per_word;
 
-       if (spi->mode & ~MODEBITS)
-               return -EINVAL;
-
        if (!spi->max_speed_hz
                        || spi->max_speed_hz > c->max_speed_hz
                        || spi->max_speed_hz < c->min_speed_hz)
                return -EINVAL;
 
-       bits_per_word = spi->bits_per_word ? : 8;
+       bits_per_word = spi->bits_per_word;
        if (bits_per_word != 8 && bits_per_word != 16)
                return -EINVAL;
 
@@ -382,12 +376,10 @@ static int __init txx9spi_probe(struct platform_device *dev)
        res = platform_get_resource(dev, IORESOURCE_MEM, 0);
        if (!res)
                goto exit_busy;
-       if (!devm_request_mem_region(&dev->dev,
-                                    res->start, res->end - res->start + 1,
+       if (!devm_request_mem_region(&dev->dev, res->start, resource_size(res),
                                     "spi_txx9"))
                goto exit_busy;
-       c->membase = devm_ioremap(&dev->dev,
-                                 res->start, res->end - res->start + 1);
+       c->membase = devm_ioremap(&dev->dev, res->start, resource_size(res));
        if (!c->membase)
                goto exit_busy;
 
@@ -414,6 +406,9 @@ static int __init txx9spi_probe(struct platform_device *dev)
                 (unsigned long long)res->start, irq,
                 (c->baseclk + 500000) / 1000000);
 
+       /* the spi->mode bits understood by this driver: */
+       master->mode_bits = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA;
+
        master->bus_num = dev->id;
        master->setup = txx9spi_setup;
        master->transfer = txx9spi_transfer;