Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1996493ybp; Thu, 10 Oct 2019 00:18:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzu6falU+3vnys0MFqFyR2bTjYpNl2dzvV/uRM3rIYKqDcSeE4WMbIixM76xzBB+RxOMWFy X-Received: by 2002:a17:906:3049:: with SMTP id d9mr6661322ejd.288.1570691917034; Thu, 10 Oct 2019 00:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570691917; cv=none; d=google.com; s=arc-20160816; b=E8FzAvYX4Hy/39tcXIlGL6NPuS42qViYdjxXgvXsrMfa3tO3Vyp9wC7CikE0TE9q1h CYg+GxtlCfnL3Y/Cqo4rNjqQHsGXNXsa/Bulc0oUgkAcFWLIaI8P1bssr0Pgmi9360Ba FV1RlhzqUUWXd15FBjMGiRTaXYK1qA+4BnGR85+PS5SuqMfDuDq4sO5Pzp/O+HhLoNgE /lzdfnsHRDASijrERChP8dE3TaXMw2VC3qRRd55v3TQ5YrCHPcFiiG0e0aHiA7f2wU3p v0C6TwALZDQ0wf3UiKrnyloMnjI88EPyP2rtqEv7BqSUs8iJtrmyAK9sp22BhXY1EoRs yFeg== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=byJsD0+H7ebg3LHP9i4wQtJbWeUCBO03SdJybyV7dnQ=; b=ZKhyZnxuylPySsCLypRbDqGncvwOMjOKcInB8VrrkZKdzdj8Odh5/BjcURupewinKw 9zE2HcFd1u47ORGwcKCHO3/Vt6312pT3l2mXGIFOovi8WH3qa2NG9Np1llK9YlGf/FaT Ss1m+wTLyg2xu1APA0IJu+N2aVx8sF4axLbnevDsRF6Bc/TdZglbQJcKpBwTz+4YAduO M3fsgi/N2PBSqvhjaA8Lp4qnM8CkupTFkkN6/53Rx0KbPbnMErLdKLfSjG2cGzGkKdsy g55jF0088b7lKwmfKdsQqMT7WbF3sDs4zt7SKdvhW6XPGCtHPFX2id72qZ5zBdiHQKpz kRNA== 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11si2579789ejb.240.2019.10.10.00.18.14; Thu, 10 Oct 2019 00:18:37 -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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733010AbfJJHQC (ORCPT + 99 others); Thu, 10 Oct 2019 03:16:02 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:44368 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726864AbfJJHOB (ORCPT ); Thu, 10 Oct 2019 03:14:01 -0400 Received: from dhcp-172-31-174-146.wireless.concordia.ca (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (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 979B1290767; Thu, 10 Oct 2019 08:13:59 +0100 (BST) Date: Thu, 10 Oct 2019 09:13:56 +0200 From: Boris Brezillon To: Cc: , , , , , linux-aspeed@lists.ozlabs.org, andrew@aj.id.au, richard@nod.at, linux-kernel@vger.kernel.org, vz@mleia.com, linux-mediatek@lists.infradead.org, joel@jms.id.au, miquel.raynal@bootlin.com, matthias.bgg@gmail.com, computersforpeace@gmail.com, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 05/22] mtd: spi-nor: Rework read_sr() Message-ID: <20191010091356.5d9a4e44@dhcp-172-31-174-146.wireless.concordia.ca> In-Reply-To: <20190924074533.6618-6-tudor.ambarus@microchip.com> References: <20190924074533.6618-1-tudor.ambarus@microchip.com> <20190924074533.6618-6-tudor.ambarus@microchip.com> Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 24 Sep 2019 07:46:08 +0000 wrote: > From: Tudor Ambarus > > static int read_sr(struct spi_nor *nor) > becomes > static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) > > The new function returns 0 on success and -errno otherwise. > We let the callers pass the pointer to the buffer where the > value of the Status Register will be written. This way we avoid > the casts between int and u8, which can be confusing. > > Prepend spi_nor_ to the function name, all functions should begin > with that. > > S/pr_err/dev_err and drop duplicated dev_err in callers, in case the > function returns error. Too many things done in a single patch, can you split that please? > > Signed-off-by: Tudor Ambarus > --- > drivers/mtd/spi-nor/spi-nor.c | 131 +++++++++++++++++++++--------------------- > 1 file changed, 65 insertions(+), 66 deletions(-) > > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c > index 7d0c1b598250..a23783641146 100644 > --- a/drivers/mtd/spi-nor/spi-nor.c > +++ b/drivers/mtd/spi-nor/spi-nor.c > @@ -388,12 +388,14 @@ static ssize_t spi_nor_write_data(struct spi_nor *nor, loff_t to, size_t len, > return nor->controller_ops->write(nor, to, len, buf); > } > > -/* > - * Read the status register, returning its value in the location > - * Return the status register value. > - * Returns negative if error occurred. > +/** > + * spi_nor_read_sr() - Read the Status Register. > + * @nor: pointer to 'struct spi_nor' > + * @sr: buffer where the value of the Status Register will be written. You should definitely mention that this sr pointer has to be DMA-safe. > + * > + * Return: 0 on success, -errno otherwise. > */ > -static int read_sr(struct spi_nor *nor) > +static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) > { > int ret; > > @@ -402,20 +404,17 @@ static int read_sr(struct spi_nor *nor) > SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDSR, 1), > SPI_MEM_OP_NO_ADDR, > SPI_MEM_OP_NO_DUMMY, > - SPI_MEM_OP_DATA_IN(1, nor->bouncebuf, 1)); > + SPI_MEM_OP_DATA_IN(1, sr, 1)); > > ret = spi_mem_exec_op(nor->spimem, &op); > } else { > - ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDSR, > - nor->bouncebuf, 1); > + ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDSR, sr, 1); > } > > - if (ret < 0) { > - pr_err("error %d reading SR\n", (int) ret); > - return ret; > - } > + if (ret) > + dev_err(nor->dev, "error %d reading SR\n", ret); > > - return nor->bouncebuf[0]; > + return ret; > }