aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2011-07-09 13:16:40 -0400
committerGrant Likely <grant.likely@secretlab.ca>2011-07-14 15:47:13 -0400
commitc2387cb9e55f9c85ed33a5bf086f348312158133 (patch)
tree5ce8c1bb62bd6ebd7f6d09ad778faa2e92d1b9c5 /drivers/spi
parent04ee585495a6d474d1ff9a821b52abf7db99cad3 (diff)
spi/imx: copy gpio number passed by platform data into driver private data
It copies gpio number passed via platform data embedded pointer into driver private data, so that we do not need to refer to this embedded pointer passed by platform data after probe function exits. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-imx.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 87981b417967..591ebc3546d6 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -84,7 +84,6 @@ struct spi_imx_data {
84 int irq; 84 int irq;
85 struct clk *clk; 85 struct clk *clk;
86 unsigned long spi_clk; 86 unsigned long spi_clk;
87 int *chipselect;
88 87
89 unsigned int count; 88 unsigned int count;
90 void (*tx)(struct spi_imx_data *); 89 void (*tx)(struct spi_imx_data *);
@@ -94,6 +93,7 @@ struct spi_imx_data {
94 unsigned int txfifo; /* number of words pushed in tx FIFO */ 93 unsigned int txfifo; /* number of words pushed in tx FIFO */
95 94
96 struct spi_imx_devtype_data *devtype_data; 95 struct spi_imx_devtype_data *devtype_data;
96 int chipselect[0];
97}; 97};
98 98
99static inline int is_imx27_cspi(struct spi_imx_data *d) 99static inline int is_imx27_cspi(struct spi_imx_data *d)
@@ -741,7 +741,7 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
741 struct spi_master *master; 741 struct spi_master *master;
742 struct spi_imx_data *spi_imx; 742 struct spi_imx_data *spi_imx;
743 struct resource *res; 743 struct resource *res;
744 int i, ret; 744 int i, ret, num_cs;
745 745
746 mxc_platform_info = dev_get_platdata(&pdev->dev); 746 mxc_platform_info = dev_get_platdata(&pdev->dev);
747 if (!mxc_platform_info) { 747 if (!mxc_platform_info) {
@@ -749,20 +749,22 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
749 return -EINVAL; 749 return -EINVAL;
750 } 750 }
751 751
752 master = spi_alloc_master(&pdev->dev, sizeof(struct spi_imx_data)); 752 num_cs = mxc_platform_info->num_chipselect;
753 master = spi_alloc_master(&pdev->dev,
754 sizeof(struct spi_imx_data) + sizeof(int) * num_cs);
753 if (!master) 755 if (!master)
754 return -ENOMEM; 756 return -ENOMEM;
755 757
756 platform_set_drvdata(pdev, master); 758 platform_set_drvdata(pdev, master);
757 759
758 master->bus_num = pdev->id; 760 master->bus_num = pdev->id;
759 master->num_chipselect = mxc_platform_info->num_chipselect; 761 master->num_chipselect = num_cs;
760 762
761 spi_imx = spi_master_get_devdata(master); 763 spi_imx = spi_master_get_devdata(master);
762 spi_imx->bitbang.master = spi_master_get(master); 764 spi_imx->bitbang.master = spi_master_get(master);
763 spi_imx->chipselect = mxc_platform_info->chipselect;
764 765
765 for (i = 0; i < master->num_chipselect; i++) { 766 for (i = 0; i < master->num_chipselect; i++) {
767 spi_imx->chipselect[i] = mxc_platform_info->chipselect[i];
766 if (spi_imx->chipselect[i] < 0) 768 if (spi_imx->chipselect[i] < 0)
767 continue; 769 continue;
768 ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME); 770 ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);