From patchwork Sun Sep 4 08:00:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9312419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 982AB600CA for ; Sun, 4 Sep 2016 08:07:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89A48287DA for ; Sun, 4 Sep 2016 08:07:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EA99288F0; Sun, 4 Sep 2016 08:07:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.4 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C296287DA for ; Sun, 4 Sep 2016 08:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752488AbcIDIHl (ORCPT ); Sun, 4 Sep 2016 04:07:41 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36498 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752219AbcIDIHg (ORCPT ); Sun, 4 Sep 2016 04:07:36 -0400 Received: by mail-wm0-f65.google.com with SMTP id l65so895732wmf.3 for ; Sun, 04 Sep 2016 01:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=QQBfhbLe2yP7/sBUfZAMT02dXcYDjuTnTz4n0iFkWxU=; b=mmCHiEY3U/U9jYV0APjAPLp+XCO/x1Q4021/zTw4ONNMdM5UfheiJvbwETyV+PVuF8 pPpkJs2YcJWqNh+xjfMNIRoUeifboA2tLa5x1s7lw+99mRln72WeV6RrucjqgAJ40tDt CvQtGRK/rSznY3cn4EDAHBXYgcxJdKzHFVlCvcVoveGB18WIzcjh/AfSwBy+ksAP0qyw W8ZHtwHZfm+iu/McZH+xeJMbZA1cFBEg2TG1EvJIKt66UqGvw7sPXXzct2ClqgBmJNIN YZ6Q86aO7V8JV/RwdjBKVRxbRuiLFPQcde90Opo+798S7pb+qQCPceM2ZqN1k9yucGQG LJyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=QQBfhbLe2yP7/sBUfZAMT02dXcYDjuTnTz4n0iFkWxU=; b=lDllhJWQeswyAaPLuvHZ03P5t8+Z86x0TLD2FrAFaUK8UlU3EhnxaOLEFoHrvYtrYE RGQaH3Dl88ctgTpgTpVVdTz6xiP10r/OXdOJYc6D9Hl7tbYAqb8EIVYJdsDe9mP71C+z QCT7fES2SEkxsWqL62rYjluhU3qKzUV4tEyd3qnB2dNs4J6d2rcwvTe455YivFv3j6+s 7jkcnxZ+3ZGj+KZtdj3ndljii0JbMGTG6bLY2+RlRbMu+mHfIH5RaMSZRcM9UkHZTTVk PWq63EPgH1/vLx7J+NuFQnb5YW9+y2eR65/arrhA/x3wqD1/DTrwbGW804tnETBFhp+y cAdQ== X-Gm-Message-State: AE9vXwMVTcE0KDaP0eY5BRFjXKFOzgTHTPVd6ZSBX43GRl4p+ZH3PfYKcIB87GtDhs5Jig== X-Received: by 10.28.125.80 with SMTP id y77mr10544742wmc.25.1472976455289; Sun, 04 Sep 2016 01:07:35 -0700 (PDT) Received: from ?IPv6:2003:62:5f43:9500:c1f5:c528:a3d:f8c4? (p200300625F439500C1F5C5280A3DF8C4.dip0.t-ipconnect.de. [2003:62:5f43:9500:c1f5:c528:a3d:f8c4]) by smtp.googlemail.com with ESMTPSA id a3sm19881360wjw.15.2016.09.04.01.07.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Sep 2016 01:07:34 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH v2 10/18] spi: fsl-espi: merge fsl_espi_cmd_trans and fsl_espi_rw_trans To: Mark Brown References: Cc: "linux-spi@vger.kernel.org" Message-ID: <077f4dc7-be65-41e4-07c3-73bd8b486ae0@gmail.com> Date: Sun, 4 Sep 2016 10:00:56 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP fsl_espi_cmd_trans and fsl_espi_rw_trans share most of the code so we can merge them. Signed-off-by: Heiner Kallweit --- v2: - rebased --- drivers/spi/spi-fsl-espi.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 8554f18..f8a6dd1 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -299,23 +299,8 @@ static int fsl_espi_do_trans(struct spi_message *m, struct spi_transfer *trans) return ret; } -static int fsl_espi_cmd_trans(struct spi_message *m, - struct spi_transfer *trans, u8 *rx_buff) -{ - struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); - int ret; - - fsl_espi_copy_to_buf(m, mspi); - - trans->tx_buf = mspi->local_buf; - trans->rx_buf = mspi->local_buf; - ret = fsl_espi_do_trans(m, trans); - - return ret; -} - -static int fsl_espi_rw_trans(struct spi_message *m, - struct spi_transfer *trans, u8 *rx_buff) +static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans, + u8 *rx_buff) { struct mpc8xxx_spi *mspi = spi_master_get_devdata(m->spi->master); unsigned int tx_only; @@ -327,12 +312,9 @@ static int fsl_espi_rw_trans(struct spi_message *m, trans->rx_buf = mspi->local_buf; ret = fsl_espi_do_trans(m, trans); - if (!ret) { - /* If there is at least one RX byte then copy it to rx_buff */ - if (trans->len > tx_only) - memcpy(rx_buff, trans->rx_buf + tx_only, - trans->len - tx_only); - } + /* If there is at least one RX byte then copy it to rx_buff */ + if (!ret && rx_buff && trans->len > tx_only) + memcpy(rx_buff, trans->rx_buf + tx_only, trans->len - tx_only); return ret; } @@ -354,10 +336,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, trans.len = xfer_len; - if (!rx_buf) - ret = fsl_espi_cmd_trans(m, &trans, NULL); - else - ret = fsl_espi_rw_trans(m, &trans, rx_buf); + ret = fsl_espi_trans(m, &trans, rx_buf); m->actual_length = ret ? 0 : trans.len;