Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2727366imm; Sun, 30 Sep 2018 03:40:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV61+o62Piu/1GC+56CXd8FvKa0ePOnBJ39ecLgblB3vzhCcvKdHtWUJ1bQYqTaCrFnzJY+2T X-Received: by 2002:a17:902:2e:: with SMTP id 43-v6mr5014329pla.290.1538304048733; Sun, 30 Sep 2018 03:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538304048; cv=none; d=google.com; s=arc-20160816; b=vB+1el/xenDRQqchgmUZJ53sS3MumMRwr8b/e4pYd7XJzRkHEwwACSZJkqcrN/yHVU 3yLnVqSL5J0jYP6oKZSxRq7eyFURRe5pftltCKb20xZGgpb28CcX52dlfvKO6rpkkJV3 yRoFI85s4BxZPwbTudgW6tSSrrlCAXiwNVTl2S7Se8IwKDzXaEZPQUwBRPkkERQEz/ca 3HBF4yokSSwV5ZZc0cd4XiE2Q1UNzvGf05rfLA0Kh3V7ELTY1o7ETN97uTvzD1++mUEq kN3jAJGmLB0FbhAddhevaCN7LvFjDABjh2lt2AGi2D4AOqBy+ditEOsw3aPqsoFVEvao wJag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=d5CELgufVLqIjIviMUfY8RpuedYEP6wFzTbJ64HvdzU=; b=sLdErFs0OpaTSyTCXYqwocUk+vj2GMIX3gUrgGoP6wFIAkmqPUwtHm3hmz9KvnXbJT 6QH1cuDUAfGqzJpsiMb1I+s/n7Ejer88Z9uf1lKzWeWyzgpLzAhkJoPPg0h2t/JyPHNf q6ZsF0XhDnIv0xXmfcq17ouRRw+JqqpZYvBrQXTwjUuBUZw4tLBKLZv4YSmH0L0xYmQz W78o9z5N3u75GGMd1E5q2/sdIBFzRgjwnCkcgg2xOH/UtHpM/FfV0r9Adg8z1yDsJkoI DLKYNj/MGqcvZOsmaFzA3Vek8AZEfyjCUw0MChYBCD7KD93gictC40lW2eKKgDyZwpa2 2EvQ== 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 l4-v6si8090641pgf.344.2018.09.30.03.40.34; Sun, 30 Sep 2018 03:40: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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728297AbeI3RMu convert rfc822-to-8bit (ORCPT + 99 others); Sun, 30 Sep 2018 13:12:50 -0400 Received: from mail.bootlin.com ([62.4.15.54]:38746 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727821AbeI3RMu (ORCPT ); Sun, 30 Sep 2018 13:12:50 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 39B8A207D8; Sun, 30 Sep 2018 12:40:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id EF6FA20379; Sun, 30 Sep 2018 12:40:07 +0200 (CEST) Date: Sun, 30 Sep 2018 12:40:08 +0200 From: Boris Brezillon To: Chuanhua Han Cc: "broonie@kernel.org" , "linux-spi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "eha@deif.com" Subject: Re: [PATCH v2 1/4] spi: spi-mem: Add the spi_set_xfer_bpw function Message-ID: <20180930124008.365831bf@bbrezillon> In-Reply-To: References: <20180930092535.24544-1-chuanhua.han@nxp.com> <20180930120425.7715cb29@bbrezillon> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 30 Sep 2018 10:18:18 +0000 Chuanhua Han wrote: > > -----Original Message----- > > From: Boris Brezillon > > Sent: 2018年9月30日 18:04 > > To: Chuanhua Han > > Cc: broonie@kernel.org; linux-spi@vger.kernel.org; > > linux-kernel@vger.kernel.org; eha@deif.com > > Subject: Re: [PATCH v2 1/4] spi: spi-mem: Add the spi_set_xfer_bpw function > > > > Hi Chuanhua, > > > > On Sun, 30 Sep 2018 17:25:32 +0800 > > Chuanhua Han wrote: > > > > > Before we add this spi_transfer to the spi_message chain table, we > > > need bits_per_word_mask based on spi_control to set the bits_per_word > > > of this spi_transfer. > > > > Let's make it clearer: this is wrong. The spi-mem protocol is just using bytes, > > not custom size words. Fix the fsl-dspi driver if needed, but don't try to adjust > > xfer->bits_per_word in spi-mem.c, because this is inappropriate. > The value of bits_per_word is only known before the spi_message_add_tail function is called, No, it's not. It's known from the beginning, and spi_setup() defaults to 8 when spidev->bits_per_word is 0, which is exactly what we want. Then, when you send a message through, spi_sync(), spi_validate() makes sure that each transfer in the message has a xfer->bits_per_word != 0 and when that's not the case, it sets it to spi->bits_per_word [2]. Really, there's nothing to fix in spi-mem.c, because it's already doing the right thing (leaving ->bits_per_word to 0 so that it's set to spi->bits_per_word, which should be 8). Maybe we have a bug somewhere else though. [1]https://elixir.bootlin.com/linux/v4.19-rc5/source/drivers/spi/spi.c#L2803 [2]https://elixir.bootlin.com/linux/v4.19-rc5/source/drivers/spi/spi.c#L2869