Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1651573pxb; Mon, 23 Aug 2021 00:59:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI1TojGIoyt/cnxu7SyFFqfXDEj8KLIlY/q0XNYk76aC6HFOoqW3b4qQUtSb1QV+C7ce0H X-Received: by 2002:a6b:b502:: with SMTP id e2mr24968684iof.152.1629705572903; Mon, 23 Aug 2021 00:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629705572; cv=none; d=google.com; s=arc-20160816; b=RT7bJnj+/LQ0GnicOsju1Z7+TXQ6oa4h6wKiAw0ghokQWLNpjN41snuv+t5kBaWiQH wRgaliueNnL8vHD1Xu9GyvGT97RdJQrcvclHNUTnmTx/AfwBvQR+uP7keaaC5LPD9Byt aXxPwoog6p6qo2+IMTB7xw7AcpMKjxX1k3r3JWtpbxhG6kaBU2w5npxgnPHt8H4IKZL8 B1m2dQ6nAGwRv5yiaH6zZnlR41FyZK7FtHoLBr6ymPZdQBLetNz0tgSUOQi5v1qb1Bk0 OMO6YURXXabZmlbdZljXDEIJpV3p8a6k2WYtKlVJA2LUYf6wZ5dpSJMaC8c3SNTVfdf6 2Liw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=EFv8DsWFTKfylbztA1iG32Mdanm882hFNe9faAqe210=; b=xeque0wLVIC4W0AR+lgAx65cXDWWqq6/wmvEgRWEI63nLCdfzWdQLyUH/HWIgjKMLy koBtB4bcRlt3JmnAe5pGQz4Q74PQ3UhdABcknl8IUpA6GLBfTL59ThOh43LpjtI+j2QU PJKNddQCUFzKV+7y74J1/9Xb67ZV2IW7j0F/hxfBG3TItA8vb9+Ol7jmR9BsNk/alsbI Hwz5iVSnmZRvtSaC5lixrCpBRDyETMjq46xN9vJxVtNsG7I8i3szoPL+pF4D+Ziqi8WR nZgJUaooPPydYw4cjD6jA/Pm6hwVcxTHEkcOQ5PPd9rTvHEbMt8d0leZCyF3oQVurYWk IT7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n5si15795444jat.10.2021.08.23.00.59.21; Mon, 23 Aug 2021 00:59:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235312AbhHWH60 (ORCPT + 99 others); Mon, 23 Aug 2021 03:58:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235243AbhHWH6Z (ORCPT ); Mon, 23 Aug 2021 03:58:25 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B82EAC061575; Mon, 23 Aug 2021 00:57:43 -0700 (PDT) Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:b93f:9fae:b276:a89a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id CAB921F424B6; Mon, 23 Aug 2021 08:57:41 +0100 (BST) Date: Mon, 23 Aug 2021 09:57:38 +0200 From: Boris Brezillon To: Apurva Nandan Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mark Brown , Patrice Chotard , , , , Pratyush Yadav Subject: Re: [PATCH 01/13] spi: spi-mem: Add DTR templates for cmd, address, dummy and data phase Message-ID: <20210823095738.297d33e9@collabora.com> In-Reply-To: <20210713130538.646-2-a-nandan@ti.com> References: <20210713130538.646-1-a-nandan@ti.com> <20210713130538.646-2-a-nandan@ti.com> Organization: Collabora X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 13 Jul 2021 13:05:26 +0000 Apurva Nandan wrote: > Setting dtr field of spi_mem_op is useful when creating templates > for DTR ops in spinand.h. Also, 2 bytes cmd phases are required when > operating in Octal DTR SPI mode. > > Create new templates for dtr mode cmd, address, dummy and data phase > in spi_mem_op, which set the dtr field to 1 and also allow passing > the nbytes for the cmd phase. > > Signed-off-by: Apurva Nandan > --- > include/linux/spi/spi-mem.h | 87 ++++++++++++++++++++++++++----------- > 1 file changed, 61 insertions(+), 26 deletions(-) > > diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h > index 85e2ff7b840d..73e52a3ecf66 100644 > --- a/include/linux/spi/spi-mem.h > +++ b/include/linux/spi/spi-mem.h > @@ -13,46 +13,81 @@ > > #include > > -#define SPI_MEM_OP_CMD(__opcode, __buswidth) \ > - { \ > - .buswidth = __buswidth, \ > - .opcode = __opcode, \ > - .nbytes = 1, \ > +#define SPI_MEM_OP_CMD_ALL_ARGS(__nbytes, __opcode, __buswidth, __dtr) \ > + { \ > + .buswidth = __buswidth, \ > + .opcode = __opcode, \ > + .nbytes = __nbytes, \ > + .dtr = __dtr, \ > } > > -#define SPI_MEM_OP_ADDR(__nbytes, __val, __buswidth) \ > - { \ > - .nbytes = __nbytes, \ > - .val = __val, \ > - .buswidth = __buswidth, \ > +#define SPI_MEM_OP_CMD(__opcode, __buswidth) \ > + SPI_MEM_OP_CMD_ALL_ARGS(1, __opcode, __buswidth, 0) > + > +#define SPI_MEM_OP_CMD_DTR(__nbytes, __opcode, __buswidth) \ > + SPI_MEM_OP_CMD_ALL_ARGS(__nbytes, __opcode, __buswidth, 1) I don't see the benefit of those ALL_ARGS() macros compared to the definition of the _DTR() variants using raw struct initializers, but if you think we will add more optional args and really care about saving a few lines of code, maybe it'd be better to have something like: #define SPI_MEM_OP_DTR .dtr = true #define SPI_MEM_OP_CMD_BYTES(val) .nbytes = val #define SPI_MEM_OP_EXT_CMD(__opcode, __buswidth, ...) \ { \ .buswidth = __buswidth, \ .opcode = __opcode, \ __VA_ARGS__, \ } #define SPI_MEM_OP_CMD(__opcode, __buswidth) \ SPI_MEM_OP_EXT_CMD(__opcode, __buswidth, \ SPI_MEM_OP_CMD_BYTES(1)) #define SPI_MEM_OP_CMD_DTR(__nbytes, __opcode, __buswidth) \ SPI_MEM_OP_EXT_CMD(__opcode, __buswidth, \ SPI_MEM_OP_CMD_BYTES(__nbytes), \ SPI_MEM_OP_DTR) so you don't have to patch all users every time you add an argument.