diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2014-12-03 01:56:17 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-12-03 08:05:47 -0500 |
commit | c592becbe704127ef0b89233ff7f285637491154 (patch) | |
tree | cca527460f97f6879e7eb73d010faccf77cd3a2d | |
parent | f114040e3ea6e07372334ade75d1ee0775c355e1 (diff) |
spi: fsl-(e)spi: migrate to generic master queueing
Migrates the fsl-(e)spi driver to use the generic master queuing.
Avoids the "master is unqueued, this is deprecated" warning.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-fsl-espi.c | 13 | ||||
-rw-r--r-- | drivers/spi/spi-fsl-lib.c | 59 | ||||
-rw-r--r-- | drivers/spi/spi-fsl-lib.h | 10 | ||||
-rw-r--r-- | drivers/spi/spi-fsl-spi.c | 14 |
4 files changed, 14 insertions, 82 deletions
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index a7f94b6a9e70..90be6405e789 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c | |||
@@ -411,7 +411,8 @@ static void fsl_espi_rw_trans(struct spi_message *m, | |||
411 | kfree(local_buf); | 411 | kfree(local_buf); |
412 | } | 412 | } |
413 | 413 | ||
414 | static void fsl_espi_do_one_msg(struct spi_message *m) | 414 | static int fsl_espi_do_one_msg(struct spi_master *master, |
415 | struct spi_message *m) | ||
415 | { | 416 | { |
416 | struct spi_transfer *t; | 417 | struct spi_transfer *t; |
417 | u8 *rx_buf = NULL; | 418 | u8 *rx_buf = NULL; |
@@ -441,8 +442,8 @@ static void fsl_espi_do_one_msg(struct spi_message *m) | |||
441 | 442 | ||
442 | m->actual_length = espi_trans.actual_length; | 443 | m->actual_length = espi_trans.actual_length; |
443 | m->status = espi_trans.status; | 444 | m->status = espi_trans.status; |
444 | if (m->complete) | 445 | spi_finalize_current_message(master); |
445 | m->complete(m->context); | 446 | return 0; |
446 | } | 447 | } |
447 | 448 | ||
448 | static int fsl_espi_setup(struct spi_device *spi) | 449 | static int fsl_espi_setup(struct spi_device *spi) |
@@ -607,16 +608,14 @@ static struct spi_master * fsl_espi_probe(struct device *dev, | |||
607 | 608 | ||
608 | dev_set_drvdata(dev, master); | 609 | dev_set_drvdata(dev, master); |
609 | 610 | ||
610 | ret = mpc8xxx_spi_probe(dev, mem, irq); | 611 | mpc8xxx_spi_probe(dev, mem, irq); |
611 | if (ret) | ||
612 | goto err_probe; | ||
613 | 612 | ||
614 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); | 613 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); |
615 | master->setup = fsl_espi_setup; | 614 | master->setup = fsl_espi_setup; |
616 | master->cleanup = fsl_espi_cleanup; | 615 | master->cleanup = fsl_espi_cleanup; |
616 | master->transfer_one_message = fsl_espi_do_one_msg; | ||
617 | 617 | ||
618 | mpc8xxx_spi = spi_master_get_devdata(master); | 618 | mpc8xxx_spi = spi_master_get_devdata(master); |
619 | mpc8xxx_spi->spi_do_one_msg = fsl_espi_do_one_msg; | ||
620 | mpc8xxx_spi->spi_remove = fsl_espi_remove; | 619 | mpc8xxx_spi->spi_remove = fsl_espi_remove; |
621 | 620 | ||
622 | mpc8xxx_spi->reg_base = ioremap(mem->start, resource_size(mem)); | 621 | mpc8xxx_spi->reg_base = ioremap(mem->start, resource_size(mem)); |
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 | ||
64 | static 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 | |||
85 | int 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 | |||
102 | const char *mpc8xxx_spi_strmode(unsigned int flags) | 64 | const 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 | ||
117 | int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, | 79 | void 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 | |||
164 | err: | ||
165 | return ret; | ||
166 | } | 111 | } |
167 | 112 | ||
168 | int mpc8xxx_spi_remove(struct device *dev) | 113 | int 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); |
diff --git a/drivers/spi/spi-fsl-lib.h b/drivers/spi/spi-fsl-lib.h index 2fcbfd01d109..b4ed04e8862f 100644 --- a/drivers/spi/spi-fsl-lib.h +++ b/drivers/spi/spi-fsl-lib.h | |||
@@ -55,7 +55,6 @@ struct mpc8xxx_spi { | |||
55 | u32(*get_tx) (struct mpc8xxx_spi *); | 55 | u32(*get_tx) (struct mpc8xxx_spi *); |
56 | 56 | ||
57 | /* hooks for different controller driver */ | 57 | /* hooks for different controller driver */ |
58 | void (*spi_do_one_msg) (struct spi_message *m); | ||
59 | void (*spi_remove) (struct mpc8xxx_spi *mspi); | 58 | void (*spi_remove) (struct mpc8xxx_spi *mspi); |
60 | 59 | ||
61 | unsigned int count; | 60 | unsigned int count; |
@@ -78,12 +77,6 @@ struct mpc8xxx_spi { | |||
78 | int bits_per_word, int msb_first); | 77 | int bits_per_word, int msb_first); |
79 | #endif | 78 | #endif |
80 | 79 | ||
81 | struct workqueue_struct *workqueue; | ||
82 | struct work_struct work; | ||
83 | |||
84 | struct list_head queue; | ||
85 | spinlock_t lock; | ||
86 | |||
87 | struct completion done; | 80 | struct completion done; |
88 | }; | 81 | }; |
89 | 82 | ||
@@ -123,9 +116,8 @@ extern struct mpc8xxx_spi_probe_info *to_of_pinfo( | |||
123 | struct fsl_spi_platform_data *pdata); | 116 | struct fsl_spi_platform_data *pdata); |
124 | extern int mpc8xxx_spi_bufs(struct mpc8xxx_spi *mspi, | 117 | extern int mpc8xxx_spi_bufs(struct mpc8xxx_spi *mspi, |
125 | struct spi_transfer *t, unsigned int len); | 118 | struct spi_transfer *t, unsigned int len); |
126 | extern int mpc8xxx_spi_transfer(struct spi_device *spi, struct spi_message *m); | ||
127 | extern const char *mpc8xxx_spi_strmode(unsigned int flags); | 119 | extern const char *mpc8xxx_spi_strmode(unsigned int flags); |
128 | extern int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, | 120 | extern void mpc8xxx_spi_probe(struct device *dev, struct resource *mem, |
129 | unsigned int irq); | 121 | unsigned int irq); |
130 | extern int mpc8xxx_spi_remove(struct device *dev); | 122 | extern int mpc8xxx_spi_remove(struct device *dev); |
131 | extern int of_mpc8xxx_spi_probe(struct platform_device *ofdev); | 123 | extern int of_mpc8xxx_spi_probe(struct platform_device *ofdev); |
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index ed792880c9d6..6b94428a0223 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c | |||
@@ -353,7 +353,8 @@ static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t, | |||
353 | return mpc8xxx_spi->count; | 353 | return mpc8xxx_spi->count; |
354 | } | 354 | } |
355 | 355 | ||
356 | static void fsl_spi_do_one_msg(struct spi_message *m) | 356 | static int fsl_spi_do_one_msg(struct spi_master *master, |
357 | struct spi_message *m) | ||
357 | { | 358 | { |
358 | struct spi_device *spi = m->spi; | 359 | struct spi_device *spi = m->spi; |
359 | struct spi_transfer *t, *first; | 360 | struct spi_transfer *t, *first; |
@@ -408,8 +409,7 @@ static void fsl_spi_do_one_msg(struct spi_message *m) | |||
408 | } | 409 | } |
409 | 410 | ||
410 | m->status = status; | 411 | m->status = status; |
411 | if (m->complete) | 412 | spi_finalize_current_message(master); |
412 | m->complete(m->context); | ||
413 | 413 | ||
414 | if (status || !cs_change) { | 414 | if (status || !cs_change) { |
415 | ndelay(nsecs); | 415 | ndelay(nsecs); |
@@ -417,6 +417,7 @@ static void fsl_spi_do_one_msg(struct spi_message *m) | |||
417 | } | 417 | } |
418 | 418 | ||
419 | fsl_spi_setup_transfer(spi, NULL); | 419 | fsl_spi_setup_transfer(spi, NULL); |
420 | return 0; | ||
420 | } | 421 | } |
421 | 422 | ||
422 | static int fsl_spi_setup(struct spi_device *spi) | 423 | static int fsl_spi_setup(struct spi_device *spi) |
@@ -624,15 +625,13 @@ static struct spi_master * fsl_spi_probe(struct device *dev, | |||
624 | 625 | ||
625 | dev_set_drvdata(dev, master); | 626 | dev_set_drvdata(dev, master); |
626 | 627 | ||
627 | ret = mpc8xxx_spi_probe(dev, mem, irq); | 628 | mpc8xxx_spi_probe(dev, mem, irq); |
628 | if (ret) | ||
629 | goto err_probe; | ||
630 | 629 | ||
631 | master->setup = fsl_spi_setup; | 630 | master->setup = fsl_spi_setup; |
632 | master->cleanup = fsl_spi_cleanup; | 631 | master->cleanup = fsl_spi_cleanup; |
632 | master->transfer_one_message = fsl_spi_do_one_msg; | ||
633 | 633 | ||
634 | mpc8xxx_spi = spi_master_get_devdata(master); | 634 | mpc8xxx_spi = spi_master_get_devdata(master); |
635 | mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg; | ||
636 | mpc8xxx_spi->spi_remove = fsl_spi_remove; | 635 | mpc8xxx_spi->spi_remove = fsl_spi_remove; |
637 | mpc8xxx_spi->max_bits_per_word = 32; | 636 | mpc8xxx_spi->max_bits_per_word = 32; |
638 | mpc8xxx_spi->type = fsl_spi_get_type(dev); | 637 | mpc8xxx_spi->type = fsl_spi_get_type(dev); |
@@ -704,7 +703,6 @@ free_irq: | |||
704 | err_ioremap: | 703 | err_ioremap: |
705 | fsl_spi_cpm_free(mpc8xxx_spi); | 704 | fsl_spi_cpm_free(mpc8xxx_spi); |
706 | err_cpm_init: | 705 | err_cpm_init: |
707 | err_probe: | ||
708 | spi_master_put(master); | 706 | spi_master_put(master); |
709 | err: | 707 | err: |
710 | return ERR_PTR(ret); | 708 | return ERR_PTR(ret); |