aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-fsl-lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-fsl-lib.c')
-rw-r--r--drivers/spi/spi-fsl-lib.c59
1 files changed, 1 insertions, 58 deletions
diff --git a/drivers/spi/spi-fsl-lib.c b/drivers/spi/spi-fsl-lib.c
index 5ddb5b098e4e..446b737e1532 100644
--- a/drivers/spi/spi-fsl-lib.c
+++ b/drivers/spi/spi-fsl-lib.c
@@ -61,44 +61,6 @@ struct mpc8xxx_spi_probe_info *to_of_pinfo(struct fsl_spi_platform_data *pdata)
61 return container_of(pdata, struct mpc8xxx_spi_probe_info, pdata); 61 return container_of(pdata, struct mpc8xxx_spi_probe_info, pdata);
62} 62}
63 63
64static void mpc8xxx_spi_work(struct work_struct *work)
65{
66 struct mpc8xxx_spi *mpc8xxx_spi = container_of(work, struct mpc8xxx_spi,
67 work);
68
69 spin_lock_irq(&mpc8xxx_spi->lock);
70 while (!list_empty(&mpc8xxx_spi->queue)) {
71 struct spi_message *m = container_of(mpc8xxx_spi->queue.next,
72 struct spi_message, queue);
73
74 list_del_init(&m->queue);
75 spin_unlock_irq(&mpc8xxx_spi->lock);
76
77 if (mpc8xxx_spi->spi_do_one_msg)
78 mpc8xxx_spi->spi_do_one_msg(m);
79
80 spin_lock_irq(&mpc8xxx_spi->lock);
81 }
82 spin_unlock_irq(&mpc8xxx_spi->lock);
83}
84
85int mpc8xxx_spi_transfer(struct spi_device *spi,
86 struct spi_message *m)
87{
88 struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
89 unsigned long flags;
90
91 m->actual_length = 0;
92 m->status = -EINPROGRESS;
93
94 spin_lock_irqsave(&mpc8xxx_spi->lock, flags);
95 list_add_tail(&m->queue, &mpc8xxx_spi->queue);
96 queue_work(mpc8xxx_spi->workqueue, &mpc8xxx_spi->work);
97 spin_unlock_irqrestore(&mpc8xxx_spi->lock, flags);
98
99 return 0;
100}
101
102const char *mpc8xxx_spi_strmode(unsigned int flags) 64const char *mpc8xxx_spi_strmode(unsigned int flags)
103{ 65{
104 if (flags & SPI_QE_CPU_MODE) { 66 if (flags & SPI_QE_CPU_MODE) {
@@ -114,13 +76,12 @@ const char *mpc8xxx_spi_strmode(unsigned int flags)
114 return "CPU"; 76 return "CPU";
115} 77}
116 78
117int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, 79void mpc8xxx_spi_probe(struct device *dev, struct resource *mem,
118 unsigned int irq) 80 unsigned int irq)
119{ 81{
120 struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); 82 struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
121 struct spi_master *master; 83 struct spi_master *master;
122 struct mpc8xxx_spi *mpc8xxx_spi; 84 struct mpc8xxx_spi *mpc8xxx_spi;
123 int ret = 0;
124 85
125 master = dev_get_drvdata(dev); 86 master = dev_get_drvdata(dev);
126 87
@@ -128,7 +89,6 @@ int mpc8xxx_spi_probe(struct device *dev, struct resource *mem,
128 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH 89 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH
129 | SPI_LSB_FIRST | SPI_LOOP; 90 | SPI_LSB_FIRST | SPI_LOOP;
130 91
131 master->transfer = mpc8xxx_spi_transfer;
132 master->dev.of_node = dev->of_node; 92 master->dev.of_node = dev->of_node;
133 93
134 mpc8xxx_spi = spi_master_get_devdata(master); 94 mpc8xxx_spi = spi_master_get_devdata(master);
@@ -147,22 +107,7 @@ int mpc8xxx_spi_probe(struct device *dev, struct resource *mem,
147 master->bus_num = pdata->bus_num; 107 master->bus_num = pdata->bus_num;
148 master->num_chipselect = pdata->max_chipselect; 108 master->num_chipselect = pdata->max_chipselect;
149 109
150 spin_lock_init(&mpc8xxx_spi->lock);
151 init_completion(&mpc8xxx_spi->done); 110 init_completion(&mpc8xxx_spi->done);
152 INIT_WORK(&mpc8xxx_spi->work, mpc8xxx_spi_work);
153 INIT_LIST_HEAD(&mpc8xxx_spi->queue);
154
155 mpc8xxx_spi->workqueue = create_singlethread_workqueue(
156 dev_name(master->dev.parent));
157 if (mpc8xxx_spi->workqueue == NULL) {
158 ret = -EBUSY;
159 goto err;
160 }
161
162 return 0;
163
164err:
165 return ret;
166} 111}
167 112
168int mpc8xxx_spi_remove(struct device *dev) 113int mpc8xxx_spi_remove(struct device *dev)
@@ -173,8 +118,6 @@ int mpc8xxx_spi_remove(struct device *dev)
173 master = dev_get_drvdata(dev); 118 master = dev_get_drvdata(dev);
174 mpc8xxx_spi = spi_master_get_devdata(master); 119 mpc8xxx_spi = spi_master_get_devdata(master);
175 120
176 flush_workqueue(mpc8xxx_spi->workqueue);
177 destroy_workqueue(mpc8xxx_spi->workqueue);
178 spi_unregister_master(master); 121 spi_unregister_master(master);
179 122
180 free_irq(mpc8xxx_spi->irq, mpc8xxx_spi); 123 free_irq(mpc8xxx_spi->irq, mpc8xxx_spi);