Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4392468yba; Sun, 19 May 2019 18:21:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1DwyUoAZ7W2onj5MMN/QFrwJHAbxaij3TWGgPohQTyOh65uuD785YdKGPLhcipaz31vc7 X-Received: by 2002:a17:902:12f:: with SMTP id 44mr26541457plb.137.1558315290455; Sun, 19 May 2019 18:21:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558315290; cv=none; d=google.com; s=arc-20160816; b=a+hcZcm0Mn5DHyVjAVd4fGvrFhumhd8f9JUNnhhoPjoT1LYxStq16LpGJpDopLoOuj ZfPM522C8Vzzy7+unbLFXLbAwh2b72TIXua+82l84gHW18qlEoYp2xo08wrvz8Xz0qsY WBibBPY7uwvbE4Q0jNHnvk2QO+KYHk2GhYetMlVgilBHQ2umXx03sEGPe2a9OGTSoC90 R0DLQQZw9eRzngdCOKob+zuZu9QtgktGnrr/QMiDd0tpnYf3MMznuRxWFTBsX28XWlRW LJ+DmdjmlFdUNFJCDsUDr2RxgDA2JB7mK+tdsFIeCjtqLplUFjBcspGUTp5PF030SbpQ 3YfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=rW07CalhZ2Xq5vnoKcoUmzQ2epRMQjOs8R/2UZfMw8Q=; b=P5R6yVSNV7Csle+0o/ZmcgzuGktqRDVObQoFqNv3ahXAlPRHAvP0d3+WfHyIh9rySh X4fiu6K2r/ogHQxbxLKeBP53kReXU+6TnJUzbAqdyv/Do99yzPOVg2wsU+IK0+F5khWC dFgParfg7akDaJ7Usfnv5YSbGsECZF0IxnrHOd8XE77F6WJCNaz9PA8661fd5Ro7aUE0 9ZurkTgeEZoSiZKpNLIkY617euVsxu4vX7YVY4f0MBpDqEACrWO70Xulf17ytSrOBP7E aJbbfa+A9Cfe8Au9ajBqvQP5JcjZng27chq/69jm3bGpsQYlb8Va58JtejD95OH+zOI9 +xZw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14si17649150pgk.423.2019.05.19.18.21.03; Sun, 19 May 2019 18:21:30 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730107AbfESU2B (ORCPT + 99 others); Sun, 19 May 2019 16:28:01 -0400 Received: from mx.allycomm.com ([138.68.30.55]:36120 "EHLO mx.allycomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730085AbfESU2B (ORCPT ); Sun, 19 May 2019 16:28:01 -0400 Received: from ubuntu.pn.wagsky.com (c-69-181-42-248.hsd1.ca.comcast.net [69.181.42.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx.allycomm.com (Postfix) with ESMTPSA id 16A7E38EBC; Sun, 19 May 2019 13:27:59 -0700 (PDT) Subject: Re: [PATCH v2 1/3] mtd: spinand: Add #define-s for page-read ops with three-byte addresses To: Schrempf Frieder , Marek Vasut , Boris Brezillon , Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris Cc: "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" References: <20190514215315.19228-1-lede@allycomm.com> <20190514215315.19228-2-lede@allycomm.com> <355bcf8d-bce6-1b82-0f57-539c8d9b6cac@gmail.com> From: Jeff Kletsky Message-ID: Date: Sun, 19 May 2019 13:27:58 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/14/19 11:49 PM, Schrempf Frieder wrote: > On 15.05.19 08:17, Marek Vasut wrote: >> On 5/14/19 11:53 PM, Jeff Kletsky wrote: >>> From: Jeff Kletsky >> That #define in $subject is called a macro. >> >> Seems this patch adds a lot of almost duplicate code, can it be somehow >> de-duplicated ? > We could add another parameter naddr or addrlen to the > SPINAND_PAGE_READ_FROM_CACHE_XX_OPs and pass the value 2 for all > existing chips except for GD5F1GQ4UFxxG which needs 3 bytes address length. > > This would cause one more argument to each of the macro calls in all > chip drivers. As long as there are only two flavors (2 and 3 bytes) I'm > not sure if this really would make things easier and also this is "only" > preprocessor code. > > So anyways, I would be fine with both approaches, Jeff's current one or > one with another parameter for the address length. > > By the way: Jeff, you didn't carry my Reviewed-by tag to v2. So I will > just reply again to add the tags. > >>> The GigaDevice GD5F1GQ4UFxxG SPI NAND utilizes three-byte addresses >>> for its page-read ops. >>> >>> http://www.gigadevice.com/datasheet/gd5f1gq4xfxxg/ >>> >>> Signed-off-by: Jeff Kletsky >>> --- >>> include/linux/mtd/spinand.h | 30 ++++++++++++++++++++++++++++++ >>> 1 file changed, 30 insertions(+) >>> >>> diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h >>> index b92e2aa955b6..05fe98eebe27 100644 >>> --- a/include/linux/mtd/spinand.h >>> +++ b/include/linux/mtd/spinand.h >>> @@ -68,30 +68,60 @@ >>> SPI_MEM_OP_DUMMY(ndummy, 1), \ >>> SPI_MEM_OP_DATA_IN(len, buf, 1)) >>> >>> +#define SPINAND_PAGE_READ_FROM_CACHE_OP_3A(fast, addr, ndummy, buf, len) \ >>> + SPI_MEM_OP(SPI_MEM_OP_CMD(fast ? 0x0b : 0x03, 1), \ >>> + SPI_MEM_OP_ADDR(3, addr, 1), \ >>> + SPI_MEM_OP_DUMMY(ndummy, 1), \ >>> + SPI_MEM_OP_DATA_IN(len, buf, 1)) >>> + >>> #define SPINAND_PAGE_READ_FROM_CACHE_X2_OP(addr, ndummy, buf, len) \ >>> SPI_MEM_OP(SPI_MEM_OP_CMD(0x3b, 1), \ >>> SPI_MEM_OP_ADDR(2, addr, 1), \ >>> SPI_MEM_OP_DUMMY(ndummy, 1), \ >>> SPI_MEM_OP_DATA_IN(len, buf, 2)) >>> >>> [ _3A addition repeated three more times for similar ops ... ] It's easy enough to change the wording, and will do so on the next revision. However, it's not clear to me that there is consensus on if the present set of macros is acceptable/preferred over definition of a set of ones that accept an additional parameter. At least from my perspective and as Schrempf Frieder has hinted at, these macros are syntactic sugar and all result in equivalent C code. Either should compile to the same run-time size and performance (assuming reasonably that a construct like `true ? 0x0b : 0x03` is optimized out). Adding an additional parameter, at least for me, wouldn't improve readability of the code and is offset by the need to refactor four other files. Even though it should be a simple/trivial refactor, I do not have any examples of the four other manufacturers' chips to be able to confirm proper operation. I'll prepare a reworded set of patches with the present macro structure. If there is strong feeling for refactoring the macro set, please let me know. Jeff