Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942014AbcJSPyq (ORCPT ); Wed, 19 Oct 2016 11:54:46 -0400 Received: from up.free-electrons.com ([163.172.77.33]:34879 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S941337AbcJSPym (ORCPT ); Wed, 19 Oct 2016 11:54:42 -0400 Date: Wed, 19 Oct 2016 17:54:28 +0200 From: Boris Brezillon To: Neil Armstrong Cc: dwmw2@infradead.org, computersforpeace@gmail.com, richard@nod.at, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-oxnas@lists.tuxfamily.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, daniel@makrotopia.org Subject: Re: [PATCH] mtd: nand: Add OX820 NAND Support Message-ID: <20161019175428.6ea3998d@bbrezillon> In-Reply-To: <0f5398bb-52f1-d5bb-834c-dead4f708fd3@baylibre.com> References: <20161019145523.6763-1-narmstrong@baylibre.com> <20161019173704.75592f52@bbrezillon> <0f5398bb-52f1-d5bb-834c-dead4f708fd3@baylibre.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1423 Lines: 40 On Wed, 19 Oct 2016 17:46:01 +0200 Neil Armstrong wrote: > >> +/* Single CS command control */ > >> +static void oxnas_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, > >> + unsigned int ctrl) > >> +{ > >> + struct nand_chip *chip = mtd_to_nand(mtd); > >> + struct oxnas_nand *oxnas = nand_get_controller_data(chip); > >> + > >> + if (ctrl & NAND_CTRL_CHANGE) { > >> + if (ctrl & NAND_CLE) > >> + oxnas->ctrl = OXNAS_NAND_CMD_CLE; > >> + else if (ctrl & NAND_ALE) > >> + oxnas->ctrl = OXNAS_NAND_CMD_ALE; > >> + else > >> + oxnas->ctrl = 0; > >> + } > >> + > >> + if (cmd != NAND_CMD_NONE) > >> + writeb(cmd, oxnas->io_base + oxnas->ctrl); > > > > There's no need to test the NAND_CTRL_CHANGE here, and I don't think > > the CLE or ALE flag is ever set when cmd == CMD_NONE. So, you can kill > > the ->ctrl field and simply do: > > > > if (ctrl & NAND_CLE) > > writeb(cmd, oxnas->io_base + OXNAS_NAND_CMD_CLE); > > else if (ctrl & NAND_ALE) > > writeb(cmd, oxnas->io_base + OXNAS_NAND_CMD_ALE); > > > >> +} > > Hmm, except it's needed back in the oxnas_nand_write_buf() call (don't ask me why) > so I don't see how to simplify more this function. Are you sure? Can you add a WARN(oxnas->ctrl) in oxnas_nand_write_buf() to check if it's ever the case? I'm almost sure there is a call to ->cmd_ctrl() with none of the CLE and ALE flags set before the ->write_buf() call.