diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-10-14 10:54:55 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-11-09 23:41:27 -0500 |
commit | 91565c4068042b3d8e37e64e393ca105476419bd (patch) | |
tree | 3281cb89e60641766c8cfe94ebf4fbe47baa54f0 | |
parent | f6614b7bb405a9b35dd28baea989a749492c46b2 (diff) |
spi/xilinx: Eliminate pdata references from common code.
The current code has the OF binding modifying the platform_data
pointer which it must not do, and the common code doesn't really need
to use a pdata pointer. This patch eliminates the platform_data
references from the common part of the driver in preparation for
merging the OF and non-OF versions.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Tested-by: Michal Simek <monstr@monstr.eu>
-rw-r--r-- | drivers/spi/xilinx_spi.c | 14 | ||||
-rw-r--r-- | drivers/spi/xilinx_spi.h | 2 | ||||
-rw-r--r-- | drivers/spi/xilinx_spi_of.c | 17 | ||||
-rw-r--r-- | drivers/spi/xilinx_spi_pltfm.c | 4 |
4 files changed, 12 insertions, 25 deletions
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c index 80f2db5bcfd6..efb28ba4a4ec 100644 --- a/drivers/spi/xilinx_spi.c +++ b/drivers/spi/xilinx_spi.c | |||
@@ -351,18 +351,12 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id) | |||
351 | } | 351 | } |
352 | 352 | ||
353 | struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, | 353 | struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, |
354 | u32 irq, s16 bus_num) | 354 | u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word) |
355 | { | 355 | { |
356 | struct spi_master *master; | 356 | struct spi_master *master; |
357 | struct xilinx_spi *xspi; | 357 | struct xilinx_spi *xspi; |
358 | struct xspi_platform_data *pdata = dev->platform_data; | ||
359 | int ret; | 358 | int ret; |
360 | 359 | ||
361 | if (!pdata) { | ||
362 | dev_err(dev, "No platform data attached\n"); | ||
363 | return NULL; | ||
364 | } | ||
365 | |||
366 | master = spi_alloc_master(dev, sizeof(struct xilinx_spi)); | 360 | master = spi_alloc_master(dev, sizeof(struct xilinx_spi)); |
367 | if (!master) | 361 | if (!master) |
368 | return NULL; | 362 | return NULL; |
@@ -389,21 +383,21 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, | |||
389 | } | 383 | } |
390 | 384 | ||
391 | master->bus_num = bus_num; | 385 | master->bus_num = bus_num; |
392 | master->num_chipselect = pdata->num_chipselect; | 386 | master->num_chipselect = num_cs; |
393 | #ifdef CONFIG_OF | 387 | #ifdef CONFIG_OF |
394 | master->dev.of_node = dev->of_node; | 388 | master->dev.of_node = dev->of_node; |
395 | #endif | 389 | #endif |
396 | 390 | ||
397 | xspi->mem = *mem; | 391 | xspi->mem = *mem; |
398 | xspi->irq = irq; | 392 | xspi->irq = irq; |
399 | if (pdata->little_endian) { | 393 | if (little_endian) { |
400 | xspi->read_fn = xspi_read32; | 394 | xspi->read_fn = xspi_read32; |
401 | xspi->write_fn = xspi_write32; | 395 | xspi->write_fn = xspi_write32; |
402 | } else { | 396 | } else { |
403 | xspi->read_fn = xspi_read32_be; | 397 | xspi->read_fn = xspi_read32_be; |
404 | xspi->write_fn = xspi_write32_be; | 398 | xspi->write_fn = xspi_write32_be; |
405 | } | 399 | } |
406 | xspi->bits_per_word = pdata->bits_per_word; | 400 | xspi->bits_per_word = bits_per_word; |
407 | if (xspi->bits_per_word == 8) { | 401 | if (xspi->bits_per_word == 8) { |
408 | xspi->tx_fn = xspi_tx8; | 402 | xspi->tx_fn = xspi_tx8; |
409 | xspi->rx_fn = xspi_rx8; | 403 | xspi->rx_fn = xspi_rx8; |
diff --git a/drivers/spi/xilinx_spi.h b/drivers/spi/xilinx_spi.h index d211accf68d2..d710a33f569f 100644 --- a/drivers/spi/xilinx_spi.h +++ b/drivers/spi/xilinx_spi.h | |||
@@ -26,7 +26,7 @@ | |||
26 | #define XILINX_SPI_NAME "xilinx_spi" | 26 | #define XILINX_SPI_NAME "xilinx_spi" |
27 | 27 | ||
28 | struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, | 28 | struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, |
29 | u32 irq, s16 bus_num); | 29 | u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word); |
30 | 30 | ||
31 | void xilinx_spi_deinit(struct spi_master *master); | 31 | void xilinx_spi_deinit(struct spi_master *master); |
32 | #endif | 32 | #endif |
diff --git a/drivers/spi/xilinx_spi_of.c b/drivers/spi/xilinx_spi_of.c index b66c2dbf20a5..c2d8ade87a38 100644 --- a/drivers/spi/xilinx_spi_of.c +++ b/drivers/spi/xilinx_spi_of.c | |||
@@ -42,12 +42,11 @@ static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev, | |||
42 | const struct of_device_id *match) | 42 | const struct of_device_id *match) |
43 | { | 43 | { |
44 | struct spi_master *master; | 44 | struct spi_master *master; |
45 | struct xspi_platform_data *pdata; | ||
46 | struct resource r_mem; | 45 | struct resource r_mem; |
47 | struct resource r_irq; | 46 | struct resource r_irq; |
48 | int rc = 0; | 47 | int rc = 0; |
49 | const u32 *prop; | 48 | const u32 *prop; |
50 | int len; | 49 | int len, num_cs; |
51 | 50 | ||
52 | rc = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem); | 51 | rc = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem); |
53 | if (rc) { | 52 | if (rc) { |
@@ -61,21 +60,15 @@ static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev, | |||
61 | return -ENODEV; | 60 | return -ENODEV; |
62 | } | 61 | } |
63 | 62 | ||
64 | ofdev->dev.platform_data = | ||
65 | kzalloc(sizeof(struct xspi_platform_data), GFP_KERNEL); | ||
66 | pdata = ofdev->dev.platform_data; | ||
67 | if (!pdata) | ||
68 | return -ENOMEM; | ||
69 | |||
70 | /* number of slave select bits is required */ | 63 | /* number of slave select bits is required */ |
71 | prop = of_get_property(ofdev->dev.of_node, "xlnx,num-ss-bits", &len); | 64 | prop = of_get_property(ofdev->dev.of_node, "xlnx,num-ss-bits", &len); |
72 | if (!prop || len < sizeof(*prop)) { | 65 | if (!prop || len < sizeof(*prop)) { |
73 | dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n"); | 66 | dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n"); |
74 | return -EINVAL; | 67 | return -EINVAL; |
75 | } | 68 | } |
76 | pdata->num_chipselect = *prop; | 69 | num_cs = __be32_to_cpup(prop); |
77 | pdata->bits_per_word = 8; | 70 | master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1, |
78 | master = xilinx_spi_init(&ofdev->dev, &r_mem, r_irq.start, -1); | 71 | num_cs, 0, 8); |
79 | if (!master) | 72 | if (!master) |
80 | return -ENODEV; | 73 | return -ENODEV; |
81 | 74 | ||
@@ -88,8 +81,6 @@ static int __devexit xilinx_spi_remove(struct platform_device *ofdev) | |||
88 | { | 81 | { |
89 | xilinx_spi_deinit(dev_get_drvdata(&ofdev->dev)); | 82 | xilinx_spi_deinit(dev_get_drvdata(&ofdev->dev)); |
90 | dev_set_drvdata(&ofdev->dev, 0); | 83 | dev_set_drvdata(&ofdev->dev, 0); |
91 | kfree(ofdev->dev.platform_data); | ||
92 | ofdev->dev.platform_data = NULL; | ||
93 | return 0; | 84 | return 0; |
94 | } | 85 | } |
95 | 86 | ||
diff --git a/drivers/spi/xilinx_spi_pltfm.c b/drivers/spi/xilinx_spi_pltfm.c index 24debac646a9..a16722acafea 100644 --- a/drivers/spi/xilinx_spi_pltfm.c +++ b/drivers/spi/xilinx_spi_pltfm.c | |||
@@ -54,7 +54,9 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev) | |||
54 | if (irq < 0) | 54 | if (irq < 0) |
55 | return -ENXIO; | 55 | return -ENXIO; |
56 | 56 | ||
57 | master = xilinx_spi_init(&dev->dev, r, irq, dev->id); | 57 | master = xilinx_spi_init(&dev->dev, r, irq, dev->id, |
58 | pdata->num_chipselect, pdata->little_endian, | ||
59 | pdata->bits_per_word); | ||
58 | if (!master) | 60 | if (!master) |
59 | return -ENODEV; | 61 | return -ENODEV; |
60 | 62 | ||