Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp579088imm; Fri, 17 Aug 2018 03:08:48 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy/mNb72L49NXDTWIeJV2NqBqKL4Wi9SSK5ekxzqBKIGBVbhzb2ZGpCebPyGudsc798yz5y X-Received: by 2002:a17:902:22:: with SMTP id 31-v6mr32957832pla.190.1534500528862; Fri, 17 Aug 2018 03:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534500528; cv=none; d=google.com; s=arc-20160816; b=GSR3Y1SQch+jMiK+BxM3FeNWk8YyWHzNwJHuIk8f4SjhgYcG2iS6UDeP2+HC4rPlN0 Kw7jE0rvA0b9Q8DNCNzAEcEB2b0pw/3PPNsuyS/ZYIjfOjJhn0w3a4FKeCsHjzzLO/aj BfvWNpOBtD8ZLwLsru5hMnL94NcSzoImNX3ZSMNllKkNZ5eD8f/s9AZVMu1IGrp5yMey fDO5AHBeA06hPa0hGN1ufAxxMEg80Cm/k5HzvZAzPXWCgQfVLDVFmzQjHBTdBvdgVUpL nRJv/2/kRq282GRZfDALoLSvWCXlajuRjgpzs95UQtcPw7ubTwMrZ8ZIWie5A5eTWD0B SBTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=H/dqmnWOO5moN39wGG7udI78cnIhJRjvN8e6gbF57mw=; b=KGGpLZtyopyn9rYkUxGOpD5E2fsi78FW42j3qpnNHsV3+PRMEXdgXHZ99c+hH59GNd Oix4MFXeTf7YK00kfGB+JkjOquafG/oSoueVbni/Oaa43MQb6T3lBPQlPzHj0IRsEBaT 7rCHp0SQgP9R2f4/QLj/d3uCoPHhFtlZK5RMlpm9chE4kDRsUYXr/m+E2xJxRNHqiOce lwbE+yf95TwxJsLiriunyLNHFXgQnU8J1jxow4/bRov8THBm7z5lQ6nJvOQHEWw0I6DP xSRxaaFKEvOI0xZDfUDXzaQtnLHTvsGKOG43qpzBhy20WILzEH/lgX0bA4zrj2M0JwiR y7Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cf10-v6si1949964plb.9.2018.08.17.03.08.33; Fri, 17 Aug 2018 03:08:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727019AbeHQNKN (ORCPT + 99 others); Fri, 17 Aug 2018 09:10:13 -0400 Received: from inva020.nxp.com ([92.121.34.13]:44332 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726226AbeHQNKN (ORCPT ); Fri, 17 Aug 2018 09:10:13 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 1D5421A026F; Fri, 17 Aug 2018 12:07:22 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 230B41A00F4; Fri, 17 Aug 2018 12:07:19 +0200 (CEST) Received: from mega.am.freescale.net (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 1ACBE402D8; Fri, 17 Aug 2018 18:07:15 +0800 (SGT) From: Chuanhua Han To: broonie@kernel.org, boris.brezillon@bootlin.com Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, cheetah0585@163.com, Chuanhua Han Subject: [PATCH] spi: fsl-espi: master->mem_ops is implemented in the controller Date: Fri, 17 Aug 2018 18:07:05 +0800 Message-Id: <1534500425-9977-1-git-send-email-chuanhua.han@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The length of the transmitted data needs to be adjusted due to the maximum length limit for espi transmission messages Signed-off-by: Chuanhua Han --- drivers/spi/spi-fsl-espi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 1d332e2..4724127 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -22,6 +22,7 @@ #include #include #include +#include /* eSPI Controller registers */ #define ESPI_SPMODE 0x00 /* eSPI mode register */ @@ -659,6 +660,29 @@ static void fsl_espi_init_regs(struct device *dev, bool initial) fsl_espi_write_reg(espi, ESPI_SPMODE, SPMODE_INIT_VAL | SPMODE_ENABLE); } +static int fsl_espi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) +{ + if (!mem || !op) + return -EINVAL; + op->data.nbytes = min3((unsigned long)op->data.nbytes, + spi_max_transfer_size(mem->spi), + spi_max_message_size(mem->spi) - + sizeof(op->cmd.opcode) - + op->addr.nbytes - + op->dummy.nbytes); + return 0; +} + +static int fsl_espi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) +{ + return -ENOTSUPP; +} + +static const struct spi_controller_mem_ops fsl_espi_mem_ops = { + .adjust_op_size = fsl_espi_adjust_op_size, + .exec_op = fsl_espi_exec_op, +}; + static int fsl_espi_probe(struct device *dev, struct resource *mem, unsigned int irq, unsigned int num_cs) { @@ -682,6 +706,7 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem, master->auto_runtime_pm = true; master->max_message_size = fsl_espi_max_message_size; master->num_chipselect = num_cs; + master->mem_ops = &fsl_espi_mem_ops; espi = spi_master_get_devdata(master); spin_lock_init(&espi->lock); -- 2.7.4