Re: [PATCH] spi/s3c64xx: Convert to using core message queue
On Wed, 15 Feb 2012 14:48:32 -0800, Mark Brown broo...@opensource.wolfsonmicro.com wrote: Convert the s3c64xx driver to using the new message queue factored out of the pl022 driver by Linus Walleij, saving us a nice block of code and getting the benefits of improvements implemented in the core. Signed-off-by: Mark Brown broo...@opensource.wolfsonmicro.com Applied, thanks g. --- Only lightly tested thus far. Linus, it'd be really nice if you could add this to your patch queue for this feature until it's merged by Grant. drivers/spi/spi-s3c64xx.c | 125 - 1 files changed, 22 insertions(+), 103 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index b899af66..1174d80 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -128,8 +128,6 @@ #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) -#define SUSPND(10) -#define SPIBUSY (11) #define RXBUSY(12) #define TXBUSY(13) @@ -144,10 +142,8 @@ struct s3c64xx_spi_dma_data { * @clk: Pointer to the spi clock. * @src_clk: Pointer to the clock used to generate SPI signals. * @master: Pointer to the SPI Protocol master. - * @workqueue: Work queue for the SPI xfer requests. * @cntrlr_info: Platform specific data for the controller this driver manages. * @tgl_spi: Pointer to the last CS left untoggled by the cs_change hint. - * @work: Work * @queue: To log SPI xfer requests. * @lock: Controller specific lock. * @state: Set of FLAGS to indicate status. @@ -167,10 +163,8 @@ struct s3c64xx_spi_driver_data { struct clk *src_clk; struct platform_device *pdev; struct spi_master *master; - struct workqueue_struct *workqueue; struct s3c64xx_spi_info *cntrlr_info; struct spi_device *tgl_spi; - struct work_struct work; struct list_headqueue; spinlock_t lock; unsigned long sfr_start; @@ -637,9 +631,10 @@ static void s3c64xx_spi_unmap_mssg(struct s3c64xx_spi_driver_data *sdd, } } -static void handle_msg(struct s3c64xx_spi_driver_data *sdd, - struct spi_message *msg) +static int s3c64xx_spi_transfer_one_message(struct spi_master *master, + struct spi_message *msg) { + struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); struct s3c64xx_spi_info *sci = sdd-cntrlr_info; struct spi_device *spi = msg-spi; struct s3c64xx_spi_csinfo *cs = spi-controller_data; @@ -771,13 +766,15 @@ out: if (msg-complete) msg-complete(msg-context); + + spi_finalize_current_message(master); + + return 0; } -static void s3c64xx_spi_work(struct work_struct *work) +static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) { - struct s3c64xx_spi_driver_data *sdd = container_of(work, - struct s3c64xx_spi_driver_data, work); - unsigned long flags; + struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); /* Acquire DMA channels */ while (!acquire_dma(sdd)) @@ -785,61 +782,18 @@ static void s3c64xx_spi_work(struct work_struct *work) pm_runtime_get_sync(sdd-pdev-dev); - spin_lock_irqsave(sdd-lock, flags); - - while (!list_empty(sdd-queue) - !(sdd-state SUSPND)) { - - struct spi_message *msg; - - msg = container_of(sdd-queue.next, struct spi_message, queue); - - list_del_init(msg-queue); - - /* Set Xfer busy flag */ - sdd-state |= SPIBUSY; - - spin_unlock_irqrestore(sdd-lock, flags); - - handle_msg(sdd, msg); - - spin_lock_irqsave(sdd-lock, flags); - - sdd-state = ~SPIBUSY; - } + return 0; +} - spin_unlock_irqrestore(sdd-lock, flags); +static int s3c64xx_spi_unprepare_transfer(struct spi_master *spi) +{ + struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); /* Free DMA channels */ sdd-ops-release(sdd-rx_dma.ch, s3c64xx_spi_dma_client); sdd-ops-release(sdd-tx_dma.ch, s3c64xx_spi_dma_client); pm_runtime_put(sdd-pdev-dev); -} - -static int s3c64xx_spi_transfer(struct spi_device *spi, - struct spi_message *msg) -{ - struct s3c64xx_spi_driver_data *sdd; - unsigned long flags; - - sdd = spi_master_get_devdata(spi-master); - - spin_lock_irqsave(sdd-lock, flags); - - if (sdd-state SUSPND) { - spin_unlock_irqrestore(sdd-lock, flags); - return -ESHUTDOWN; - } - - msg-status = -EINPROGRESS; -
Re: [PATCH] spi/s3c64xx: Convert to using core message queue
On Wed, Feb 15, 2012 at 11:48 PM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: Convert the s3c64xx driver to using the new message queue factored out of the pl022 driver by Linus Walleij, saving us a nice block of code and getting the benefits of improvements implemented in the core. Signed-off-by: Mark Brown broo...@opensource.wolfsonmicro.com Hi Mark, I tried to include this patch for my patch series but it seems it might be dependent on other stuff already applied in the SPI tree so I couldn't get it to apply. However I guess if Grant picks up the latest (v3) version of the core patch it should apply just as fine on top of that one. Yours, Linus Walleij -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
[PATCH] spi/s3c64xx: Convert to using core message queue
Convert the s3c64xx driver to using the new message queue factored out of the pl022 driver by Linus Walleij, saving us a nice block of code and getting the benefits of improvements implemented in the core. Signed-off-by: Mark Brown broo...@opensource.wolfsonmicro.com --- Only lightly tested thus far. Linus, it'd be really nice if you could add this to your patch queue for this feature until it's merged by Grant. drivers/spi/spi-s3c64xx.c | 125 - 1 files changed, 22 insertions(+), 103 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index b899af66..1174d80 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -128,8 +128,6 @@ #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) -#define SUSPND(10) -#define SPIBUSY (11) #define RXBUSY(12) #define TXBUSY(13) @@ -144,10 +142,8 @@ struct s3c64xx_spi_dma_data { * @clk: Pointer to the spi clock. * @src_clk: Pointer to the clock used to generate SPI signals. * @master: Pointer to the SPI Protocol master. - * @workqueue: Work queue for the SPI xfer requests. * @cntrlr_info: Platform specific data for the controller this driver manages. * @tgl_spi: Pointer to the last CS left untoggled by the cs_change hint. - * @work: Work * @queue: To log SPI xfer requests. * @lock: Controller specific lock. * @state: Set of FLAGS to indicate status. @@ -167,10 +163,8 @@ struct s3c64xx_spi_driver_data { struct clk *src_clk; struct platform_device *pdev; struct spi_master *master; - struct workqueue_struct *workqueue; struct s3c64xx_spi_info *cntrlr_info; struct spi_device *tgl_spi; - struct work_struct work; struct list_headqueue; spinlock_t lock; unsigned long sfr_start; @@ -637,9 +631,10 @@ static void s3c64xx_spi_unmap_mssg(struct s3c64xx_spi_driver_data *sdd, } } -static void handle_msg(struct s3c64xx_spi_driver_data *sdd, - struct spi_message *msg) +static int s3c64xx_spi_transfer_one_message(struct spi_master *master, + struct spi_message *msg) { + struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); struct s3c64xx_spi_info *sci = sdd-cntrlr_info; struct spi_device *spi = msg-spi; struct s3c64xx_spi_csinfo *cs = spi-controller_data; @@ -771,13 +766,15 @@ out: if (msg-complete) msg-complete(msg-context); + + spi_finalize_current_message(master); + + return 0; } -static void s3c64xx_spi_work(struct work_struct *work) +static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) { - struct s3c64xx_spi_driver_data *sdd = container_of(work, - struct s3c64xx_spi_driver_data, work); - unsigned long flags; + struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); /* Acquire DMA channels */ while (!acquire_dma(sdd)) @@ -785,61 +782,18 @@ static void s3c64xx_spi_work(struct work_struct *work) pm_runtime_get_sync(sdd-pdev-dev); - spin_lock_irqsave(sdd-lock, flags); - - while (!list_empty(sdd-queue) -!(sdd-state SUSPND)) { - - struct spi_message *msg; - - msg = container_of(sdd-queue.next, struct spi_message, queue); - - list_del_init(msg-queue); - - /* Set Xfer busy flag */ - sdd-state |= SPIBUSY; - - spin_unlock_irqrestore(sdd-lock, flags); - - handle_msg(sdd, msg); - - spin_lock_irqsave(sdd-lock, flags); - - sdd-state = ~SPIBUSY; - } + return 0; +} - spin_unlock_irqrestore(sdd-lock, flags); +static int s3c64xx_spi_unprepare_transfer(struct spi_master *spi) +{ + struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); /* Free DMA channels */ sdd-ops-release(sdd-rx_dma.ch, s3c64xx_spi_dma_client); sdd-ops-release(sdd-tx_dma.ch, s3c64xx_spi_dma_client); pm_runtime_put(sdd-pdev-dev); -} - -static int s3c64xx_spi_transfer(struct spi_device *spi, - struct spi_message *msg) -{ - struct s3c64xx_spi_driver_data *sdd; - unsigned long flags; - - sdd = spi_master_get_devdata(spi-master); - - spin_lock_irqsave(sdd-lock, flags); - - if (sdd-state SUSPND) { - spin_unlock_irqrestore(sdd-lock, flags); - return -ESHUTDOWN; - } - - msg-status = -EINPROGRESS; - msg-actual_length = 0; - - list_add_tail(msg-queue, sdd-queue); - - queue_work(sdd-workqueue, sdd-work); - -
Re: [PATCH] spi/s3c64xx: Convert to using core message queue
On Wed, Feb 15, 2012 at 11:48 PM, Mark Brown broo...@opensource.wolfsonmicro.com wrote: Convert the s3c64xx driver to using the new message queue factored out of the pl022 driver by Linus Walleij, saving us a nice block of code and getting the benefits of improvements implemented in the core. Signed-off-by: Mark Brown broo...@opensource.wolfsonmicro.com Acked-by: Linus Walleij linus.wall...@linaro.org Only lightly tested thus far. Linus, it'd be really nice if you could add this to your patch queue for this feature until it's merged by Grant. I just pinged Grant on the main (v2) patch, if there are issues to be resolved I will carry this patch in the series, if Grant is happy with v2 we can just push this on top I guess... Thanks, Linus Walleij -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general