From patchwork Wed Dec 3 06:56:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 5426991 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6F4B4BEEA8 for ; Wed, 3 Dec 2014 06:56:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E87DB2035D for ; Wed, 3 Dec 2014 06:56:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A6CDE20340 for ; Wed, 3 Dec 2014 06:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751828AbaLCG4y (ORCPT ); Wed, 3 Dec 2014 01:56:54 -0500 Received: from mail-wg0-f52.google.com ([74.125.82.52]:42796 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbaLCG4x (ORCPT ); Wed, 3 Dec 2014 01:56:53 -0500 Received: by mail-wg0-f52.google.com with SMTP id a1so19041848wgh.39 for ; Tue, 02 Dec 2014 22:56:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=s17VOH0Vb62yAusXRThHShJWDu4dS9KkauXSPSv6pTk=; b=Opq5dnbinEs4ZMcGaqBE3IbHTYYdRYscP37v/u/p4QCM84KJOyTz0wBTEU201ZunUD CdvMYmhjO4MTSnldoACZ8KYUlkqdEWVji3FeP+PdbIhAWTZAj+eW1gamBnWt5vxCLnaR bBuXIj/wXKkYgPRrhMBe1AwN+ziZpRxXf146BILpYTU8+ykSFu1Iyb5jsHl8jsVjl+nU IrcpzB6xlAM2K7FmgjKhGpNHpPKtItEBqn2rqxnPLLfhE63WXrBB0kyHlXhok4njpdQL fwTvyysgROVH39JhCMgpOiiOh2jQCygy2z0tmpcGgkWp8rtA1nJUoCOlu7igAVJzMWPD tQ1A== X-Received: by 10.180.240.201 with SMTP id wc9mr10719331wic.59.1417589812205; Tue, 02 Dec 2014 22:56:52 -0800 (PST) Received: from ?IPv6:2003:63:2343:500:d97d:be0b:eaa9:cac7? (p2003006323430500D97DBE0BEAA9CAC7.dip0.t-ipconnect.de. [2003:63:2343:500:d97d:be0b:eaa9:cac7]) by mx.google.com with ESMTPSA id ry19sm34976420wjb.3.2014.12.02.22.56.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Dec 2014 22:56:51 -0800 (PST) Message-ID: <547EB411.1080109@gmail.com> Date: Wed, 03 Dec 2014 07:56:17 +0100 From: Heiner Kallweit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: broonie@kernel.org CC: linux-spi@vger.kernel.org Subject: [PATCH 1/2] spi: fsl-(e)spi: migrate to generic master queueing Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/spi/spi-fsl-espi.c | 13 +++++----- drivers/spi/spi-fsl-lib.c | 59 +--------------------------------------------- drivers/spi/spi-fsl-lib.h | 10 +------- 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 cff2ebd..e5702c9 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, kfree(local_buf); } -static void fsl_espi_do_one_msg(struct spi_message *m) +static int fsl_espi_do_one_msg(struct spi_master *master, + struct spi_message *m) { struct spi_transfer *t; u8 *rx_buf = NULL; @@ -441,8 +442,8 @@ static void fsl_espi_do_one_msg(struct spi_message *m) m->actual_length = espi_trans.actual_length; m->status = espi_trans.status; - if (m->complete) - m->complete(m->context); + spi_finalize_current_message(master); + return 0; } static int fsl_espi_setup(struct spi_device *spi) @@ -607,16 +608,14 @@ static struct spi_master * fsl_espi_probe(struct device *dev, dev_set_drvdata(dev, master); - ret = mpc8xxx_spi_probe(dev, mem, irq); - if (ret) - goto err_probe; + mpc8xxx_spi_probe(dev, mem, irq); master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); master->setup = fsl_espi_setup; master->cleanup = fsl_espi_cleanup; + master->transfer_one_message = fsl_espi_do_one_msg; mpc8xxx_spi = spi_master_get_devdata(master); - mpc8xxx_spi->spi_do_one_msg = fsl_espi_do_one_msg; mpc8xxx_spi->spi_remove = fsl_espi_remove; 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 5ddb5b0..446b737 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) return container_of(pdata, struct mpc8xxx_spi_probe_info, pdata); } -static void mpc8xxx_spi_work(struct work_struct *work) -{ - struct mpc8xxx_spi *mpc8xxx_spi = container_of(work, struct mpc8xxx_spi, - work); - - spin_lock_irq(&mpc8xxx_spi->lock); - while (!list_empty(&mpc8xxx_spi->queue)) { - struct spi_message *m = container_of(mpc8xxx_spi->queue.next, - struct spi_message, queue); - - list_del_init(&m->queue); - spin_unlock_irq(&mpc8xxx_spi->lock); - - if (mpc8xxx_spi->spi_do_one_msg) - mpc8xxx_spi->spi_do_one_msg(m); - - spin_lock_irq(&mpc8xxx_spi->lock); - } - spin_unlock_irq(&mpc8xxx_spi->lock); -} - -int mpc8xxx_spi_transfer(struct spi_device *spi, - struct spi_message *m) -{ - struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); - unsigned long flags; - - m->actual_length = 0; - m->status = -EINPROGRESS; - - spin_lock_irqsave(&mpc8xxx_spi->lock, flags); - list_add_tail(&m->queue, &mpc8xxx_spi->queue); - queue_work(mpc8xxx_spi->workqueue, &mpc8xxx_spi->work); - spin_unlock_irqrestore(&mpc8xxx_spi->lock, flags); - - return 0; -} - const char *mpc8xxx_spi_strmode(unsigned int flags) { if (flags & SPI_QE_CPU_MODE) { @@ -114,13 +76,12 @@ const char *mpc8xxx_spi_strmode(unsigned int flags) return "CPU"; } -int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, +void mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) { struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); struct spi_master *master; struct mpc8xxx_spi *mpc8xxx_spi; - int ret = 0; master = dev_get_drvdata(dev); @@ -128,7 +89,6 @@ int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST | SPI_LOOP; - master->transfer = mpc8xxx_spi_transfer; master->dev.of_node = dev->of_node; mpc8xxx_spi = spi_master_get_devdata(master); @@ -147,22 +107,7 @@ int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, master->bus_num = pdata->bus_num; master->num_chipselect = pdata->max_chipselect; - spin_lock_init(&mpc8xxx_spi->lock); init_completion(&mpc8xxx_spi->done); - INIT_WORK(&mpc8xxx_spi->work, mpc8xxx_spi_work); - INIT_LIST_HEAD(&mpc8xxx_spi->queue); - - mpc8xxx_spi->workqueue = create_singlethread_workqueue( - dev_name(master->dev.parent)); - if (mpc8xxx_spi->workqueue == NULL) { - ret = -EBUSY; - goto err; - } - - return 0; - -err: - return ret; } int mpc8xxx_spi_remove(struct device *dev) @@ -173,8 +118,6 @@ int mpc8xxx_spi_remove(struct device *dev) master = dev_get_drvdata(dev); mpc8xxx_spi = spi_master_get_devdata(master); - flush_workqueue(mpc8xxx_spi->workqueue); - destroy_workqueue(mpc8xxx_spi->workqueue); spi_unregister_master(master); free_irq(mpc8xxx_spi->irq, mpc8xxx_spi); diff --git a/drivers/spi/spi-fsl-lib.h b/drivers/spi/spi-fsl-lib.h index 2fcbfd0..b4ed04e 100644 --- a/drivers/spi/spi-fsl-lib.h +++ b/drivers/spi/spi-fsl-lib.h @@ -55,7 +55,6 @@ struct mpc8xxx_spi { u32(*get_tx) (struct mpc8xxx_spi *); /* hooks for different controller driver */ - void (*spi_do_one_msg) (struct spi_message *m); void (*spi_remove) (struct mpc8xxx_spi *mspi); unsigned int count; @@ -78,12 +77,6 @@ struct mpc8xxx_spi { int bits_per_word, int msb_first); #endif - struct workqueue_struct *workqueue; - struct work_struct work; - - struct list_head queue; - spinlock_t lock; - struct completion done; }; @@ -123,9 +116,8 @@ extern struct mpc8xxx_spi_probe_info *to_of_pinfo( struct fsl_spi_platform_data *pdata); extern int mpc8xxx_spi_bufs(struct mpc8xxx_spi *mspi, struct spi_transfer *t, unsigned int len); -extern int mpc8xxx_spi_transfer(struct spi_device *spi, struct spi_message *m); extern const char *mpc8xxx_spi_strmode(unsigned int flags); -extern int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, +extern void mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq); extern int mpc8xxx_spi_remove(struct device *dev); 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 048f457..e24a9bf 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, return mpc8xxx_spi->count; } -static void fsl_spi_do_one_msg(struct spi_message *m) +static int fsl_spi_do_one_msg(struct spi_master *master, + struct spi_message *m) { struct spi_device *spi = m->spi; struct spi_transfer *t, *first; @@ -408,8 +409,7 @@ static void fsl_spi_do_one_msg(struct spi_message *m) } m->status = status; - if (m->complete) - m->complete(m->context); + spi_finalize_current_message(master); if (status || !cs_change) { ndelay(nsecs); @@ -417,6 +417,7 @@ static void fsl_spi_do_one_msg(struct spi_message *m) } fsl_spi_setup_transfer(spi, NULL); + return 0; } static int fsl_spi_setup(struct spi_device *spi) @@ -624,15 +625,13 @@ static struct spi_master * fsl_spi_probe(struct device *dev, dev_set_drvdata(dev, master); - ret = mpc8xxx_spi_probe(dev, mem, irq); - if (ret) - goto err_probe; + mpc8xxx_spi_probe(dev, mem, irq); master->setup = fsl_spi_setup; master->cleanup = fsl_spi_cleanup; + master->transfer_one_message = fsl_spi_do_one_msg; mpc8xxx_spi = spi_master_get_devdata(master); - mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg; mpc8xxx_spi->spi_remove = fsl_spi_remove; mpc8xxx_spi->max_bits_per_word = 32; mpc8xxx_spi->type = fsl_spi_get_type(dev); @@ -704,7 +703,6 @@ free_irq: err_ioremap: fsl_spi_cpm_free(mpc8xxx_spi); err_cpm_init: -err_probe: spi_master_put(master); err: return ERR_PTR(ret);