From patchwork Wed Sep 7 20:53:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9319913 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 0244560869 for ; Wed, 7 Sep 2016 20:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5A8529425 for ; Wed, 7 Sep 2016 20:55:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAB8429428; Wed, 7 Sep 2016 20:55:53 +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 6E9DB29427 for ; Wed, 7 Sep 2016 20:55:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757149AbcIGUzu (ORCPT ); Wed, 7 Sep 2016 16:55:50 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33545 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756999AbcIGUzr (ORCPT ); Wed, 7 Sep 2016 16:55:47 -0400 Received: by mail-wm0-f68.google.com with SMTP id b187so852452wme.0 for ; Wed, 07 Sep 2016 13:55:47 -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=vi7qVBFU2hAhLiJeg98lvfCAw6AUEUhHYDWGPSWSqrk=; b=el03tNn/XGqdXBQ85BisCBshW7mmfUQ/fglr60WBij3FpWjAEp7ukiUgFykpaIwPsh jhsdgiCBCEyR5IaYRAipLr0dr+HDxqaRa0SV3IuuIjJEnOTx1Oa+eBGgmF5IoWSVzq5I Ore8ORKRyT+U3OJpzGrmtFigrb8ECJCR6deoxV6jPrMNVXr6HlPObVHw9ciEL83nvB/4 z1TNNR+VTk5Yad1L4RTlSRII1qeQWTj6sJrUowAUzuVaCFK03USkGYqdM4Tvv3XDzmMA pXOF8mJi7eO25un2au7H+1NrmCNtIPH1TGlF8Q2uS0SiG88Ku2hSlubKtwA7y/2hrh+9 qCKg== 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=vi7qVBFU2hAhLiJeg98lvfCAw6AUEUhHYDWGPSWSqrk=; b=cSx2mw0CfgsjuEN+mTQbJ0LR6WKLwFkSzL0xBUfHwy1DJwZODOGHtQ9VqAxzM8Z6g2 PUaZ6Bo2uINuU6rsoqW9135bX576JfbGSAjnQH44SKlNXONEcb4suNlgiLNsJLLsGo2I 9HGcmXc+hgWNxOItZnlqrFK3OVuZ43i+gqz9sQwuMbp9g/7ROuEyyS8gxcCvR0kPxkaa hZv+OUb4CpAjW1LmoKiuHeW9LtoJHbnzr7exxvgGEvGokd7es/ykiXePYQOu0TQ7uAkw 6iujtvBHoacfhPVEbVbTc0k17VxE9GaYZPbqtt4UH7DfmfzNi3uGMgFPy2iTznzoFqc0 uyhA== X-Gm-Message-State: AE9vXwPhOPLrJ8kP/HY4e2Ng4Cm1bL8YdsUMcEMChRbfw0HnAYdp4GzXfEa2UB6Y6tI6Xw== X-Received: by 10.194.87.34 with SMTP id u2mr48886624wjz.118.1473281746534; Wed, 07 Sep 2016 13:55:46 -0700 (PDT) Received: from ?IPv6:2003:62:5f43:9500:6565:4488:ad4:60db? (p200300625F439500656544880AD460DB.dip0.t-ipconnect.de. [2003:62:5f43:9500:6565:4488:ad4:60db]) by smtp.googlemail.com with ESMTPSA id ka5sm39931205wjb.7.2016.09.07.13.55.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Sep 2016 13:55:46 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH v3 09/15] spi: fsl-espi: merge fsl_espi_bufs and fsl_espi_cpu_bufs To: Mark Brown References: Cc: "linux-spi@vger.kernel.org" Message-ID: <60c463fc-3a46-8787-164b-821efd80fd16@gmail.com> Date: Wed, 7 Sep 2016 22:53:01 +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_bufs and fsl_espi_cpu_bufs are very small that we can merge them. Signed-off-by: Heiner Kallweit --- v2: - rebased v3: - new numbering --- drivers/spi/spi-fsl-espi.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 8d6a570..190ca5c 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -206,31 +206,15 @@ static void fsl_espi_setup_transfer(struct spi_device *spi, fsl_espi_change_mode(spi); } -static void fsl_espi_cpu_bufs(struct mpc8xxx_spi *mspi, struct spi_transfer *t, - unsigned int len) -{ - u32 word; - struct fsl_espi_reg *reg_base = mspi->reg_base; - - mspi->count = len; - - /* enable rx ints */ - mpc8xxx_spi_write_reg(®_base->mask, SPIM_NE); - - /* transmit word */ - word = mspi->get_tx(mspi); - mpc8xxx_spi_write_reg(®_base->transmit, word); -} - static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) { struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); struct fsl_espi_reg *reg_base = mpc8xxx_spi->reg_base; - unsigned int len = t->len; + u32 word; int ret; mpc8xxx_spi->len = t->len; - len = roundup(len, 4) / 4; + mpc8xxx_spi->count = roundup(t->len, 4) / 4; mpc8xxx_spi->tx = t->tx_buf; mpc8xxx_spi->rx = t->rx_buf; @@ -246,7 +230,12 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) mpc8xxx_spi_write_reg(®_base->command, (SPCOM_CS(spi->chip_select) | SPCOM_TRANLEN(t->len - 1))); - fsl_espi_cpu_bufs(mpc8xxx_spi, t, len); + /* enable rx ints */ + mpc8xxx_spi_write_reg(®_base->mask, SPIM_NE); + + /* transmit word */ + word = mpc8xxx_spi->get_tx(mpc8xxx_spi); + mpc8xxx_spi_write_reg(®_base->transmit, word); /* Won't hang up forever, SPI bus sometimes got lost interrupts... */ ret = wait_for_completion_timeout(&mpc8xxx_spi->done, 2 * HZ);