From patchwork Fri Feb 14 01:55:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3649241 X-Patchwork-Delegate: broonie@sirena.org.uk 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 AB455BF13A for ; Fri, 14 Feb 2014 01:56:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB6F3201ED for ; Fri, 14 Feb 2014 01:56:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCB7520203 for ; Fri, 14 Feb 2014 01:56:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751582AbaBNB4A (ORCPT ); Thu, 13 Feb 2014 20:56:00 -0500 Received: from mail-pb0-f48.google.com ([209.85.160.48]:40904 "EHLO mail-pb0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750987AbaBNB4A (ORCPT ); Thu, 13 Feb 2014 20:56:00 -0500 Received: by mail-pb0-f48.google.com with SMTP id rr13so11655230pbb.35 for ; Thu, 13 Feb 2014 17:55:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-type:mime-version:content-transfer-encoding; bh=LQ1WQ4RkM41VR/BzZ+jRm5CJrCPb/GMQBHVyn86LS4k=; b=XR5bjqI7c7tjQfj/88qh/2XC56CN8rWQii+HOjtnwWjllgCJgrI/6m2+GN0ZUMe7o0 lDS/GQcXxUs8pURCbUFfIkNWchudcQhDz5HmwKgtvF4g2MuMEMM5/ABeIVsiLq4Jzs2Q w0K06E6ZacmrnGeUFFtFkuAyU15jHbMzv7SrIXg0i6iZ5QwumxDHmtFMVLlkhQgv5Ses 73SzFDUQw7ZyEcUapDTr2omk1JJydQKV2q5iEmZ8n2QlB+ogOwtTsGarz3ECQs8IadFC 72dLq1ndtPZS1ttx3eOwa46fBBBVMVFOsbCkz5UktxyzAM/K42nCigwORdkvyIfyAEV0 BXxQ== X-Gm-Message-State: ALoCoQnRgC786RLXb1riy6nUg/txrZVHvYmOVHPd+NCEVieo4gdmQ6IQVSyTKlF6KY3JbirU0W6Z X-Received: by 10.68.129.201 with SMTP id ny9mr5767252pbb.70.1392342959650; Thu, 13 Feb 2014 17:55:59 -0800 (PST) Received: from [192.168.0.102] (218-164-130-78.dynamic.hinet.net. [218.164.130.78]) by mx.google.com with ESMTPSA id ix5sm11033208pbd.36.2014.02.13.17.55.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Feb 2014 17:55:59 -0800 (PST) Message-ID: <1392342955.22981.4.camel@phoenix> Subject: [RFT][PATCH 3/3] spi: coldfire-qspi: Use core message handling From: Axel Lin To: Mark Brown Cc: Steven King , linux-spi@vger.kernel.org Date: Fri, 14 Feb 2014 09:55:55 +0800 In-Reply-To: <1392342780.22981.0.camel@phoenix> References: <1392342780.22981.0.camel@phoenix> X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Convert to use default implementation of transfer_one_message(). Signed-off-by: Axel Lin --- Hi Steven, I don't have this h/w, can you help testing if this patch works. Thanks, Axel drivers/spi/spi-coldfire-qspi.c | 81 +++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 47 deletions(-) diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c index 0fcec3b..c29bbb0 100644 --- a/drivers/spi/spi-coldfire-qspi.c +++ b/drivers/spi/spi-coldfire-qspi.c @@ -298,58 +298,44 @@ static void mcfqspi_transfer_msg16(struct mcfqspi *mcfqspi, unsigned count, } } -static int mcfqspi_transfer_one_message(struct spi_master *master, - struct spi_message *msg) +static void mcfqspi_set_cs(struct spi_device *spi, bool enable) { - struct mcfqspi *mcfqspi = spi_master_get_devdata(master); - struct spi_device *spi = msg->spi; - struct spi_transfer *t; - int status = 0; - - list_for_each_entry(t, &msg->transfers, transfer_list) { - bool cs_high = spi->mode & SPI_CS_HIGH; - u16 qmr = MCFQSPI_QMR_MSTR; - - qmr |= t->bits_per_word << 10; - if (spi->mode & SPI_CPHA) - qmr |= MCFQSPI_QMR_CPHA; - if (spi->mode & SPI_CPOL) - qmr |= MCFQSPI_QMR_CPOL; - if (t->speed_hz) - qmr |= mcfqspi_qmr_baud(t->speed_hz); - else - qmr |= mcfqspi_qmr_baud(spi->max_speed_hz); - mcfqspi_wr_qmr(mcfqspi, qmr); + struct mcfqspi *mcfqspi = spi_master_get_devdata(spi->master); + bool cs_high = spi->mode & SPI_CS_HIGH; + if (enable) mcfqspi_cs_select(mcfqspi, spi->chip_select, cs_high); + else + mcfqspi_cs_deselect(mcfqspi, spi->chip_select, cs_high); +} - mcfqspi_wr_qir(mcfqspi, MCFQSPI_QIR_SPIFE); - if (t->bits_per_word == 8) - mcfqspi_transfer_msg8(mcfqspi, t->len, t->tx_buf, - t->rx_buf); - else - mcfqspi_transfer_msg16(mcfqspi, t->len / 2, t->tx_buf, - t->rx_buf); - mcfqspi_wr_qir(mcfqspi, 0); - - if (t->delay_usecs) - udelay(t->delay_usecs); - if (t->cs_change) { - if (!list_is_last(&t->transfer_list, &msg->transfers)) - mcfqspi_cs_deselect(mcfqspi, spi->chip_select, - cs_high); - } else { - if (list_is_last(&t->transfer_list, &msg->transfers)) - mcfqspi_cs_deselect(mcfqspi, spi->chip_select, - cs_high); - } - msg->actual_length += t->len; - } - msg->status = status; - spi_finalize_current_message(master); +static int mcfqspi_transfer_one(struct spi_master *master, + struct spi_device *spi, + struct spi_transfer *t) +{ + struct mcfqspi *mcfqspi = spi_master_get_devdata(master); + u16 qmr = MCFQSPI_QMR_MSTR; + + qmr |= t->bits_per_word << 10; + if (spi->mode & SPI_CPHA) + qmr |= MCFQSPI_QMR_CPHA; + if (spi->mode & SPI_CPOL) + qmr |= MCFQSPI_QMR_CPOL; + if (t->speed_hz) + qmr |= mcfqspi_qmr_baud(t->speed_hz); + else + qmr |= mcfqspi_qmr_baud(spi->max_speed_hz); + mcfqspi_wr_qmr(mcfqspi, qmr); - return status; + mcfqspi_wr_qir(mcfqspi, MCFQSPI_QIR_SPIFE); + if (t->bits_per_word == 8) + mcfqspi_transfer_msg8(mcfqspi, t->len, t->tx_buf, t->rx_buf); + else + mcfqspi_transfer_msg16(mcfqspi, t->len / 2, t->tx_buf, + t->rx_buf); + mcfqspi_wr_qir(mcfqspi, 0); + return 0; } static int mcfqspi_setup(struct spi_device *spi) @@ -432,7 +418,8 @@ static int mcfqspi_probe(struct platform_device *pdev) master->mode_bits = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA; master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 16); master->setup = mcfqspi_setup; - master->transfer_one_message = mcfqspi_transfer_one_message; + master->set_cs = mcfqspi_set_cs; + master->transfer_one = mcfqspi_transfer_one; master->auto_runtime_pm = true; platform_set_drvdata(pdev, master);