[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ff883ecb-104a-72c3-2169-5200bbd45bc6@microchip.com>
Date: Thu, 31 Oct 2019 14:18:55 +0000
From: <Tudor.Ambarus@...rochip.com>
To: <boris.brezillon@...labora.com>
CC: <richard@....at>, <linux-mtd@...ts.infradead.org>,
<vigneshr@...com>, <linux-kernel@...r.kernel.org>,
<miquel.raynal@...tlin.com>
Subject: Re: [PATCH v3 13/32] mtd: spi-nor: Print error messages inside Reg
Ops methods
On 10/31/2019 01:05 PM, Boris Brezillon wrote:
> External E-Mail
>
>
> On Tue, 29 Oct 2019 11:17:09 +0000
> <Tudor.Ambarus@...rochip.com> wrote:
>
>> From: Tudor Ambarus <tudor.ambarus@...rochip.com>
>>
>> Spare the callers of printing error messages by themselves.
>>
>> Signed-off-by: Tudor Ambarus <tudor.ambarus@...rochip.com>
>> ---
>> drivers/mtd/spi-nor/spi-nor.c | 165 +++++++++++++++++++++++++++++++-----------
>> 1 file changed, 123 insertions(+), 42 deletions(-)
>>
>> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
>> index e5ed9012cd50..bc46b946ac77 100644
>> --- a/drivers/mtd/spi-nor/spi-nor.c
>> +++ b/drivers/mtd/spi-nor/spi-nor.c
>> @@ -394,6 +394,8 @@ static ssize_t spi_nor_write_data(struct spi_nor *nor, loff_t to, size_t len,
>> */
>> static int spi_nor_write_enable(struct spi_nor *nor)
>> {
>> + int ret;
>> +
>> if (nor->spimem) {
>> struct spi_mem_op op =
>> SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WREN, 1),
>> @@ -401,10 +403,16 @@ static int spi_nor_write_enable(struct spi_nor *nor)
>> SPI_MEM_OP_NO_DUMMY,
>> SPI_MEM_OP_NO_DATA);
>>
>> - return spi_mem_exec_op(nor->spimem, &op);
>> + ret = spi_mem_exec_op(nor->spimem, &op);
>> + } else {
>> + ret = nor->controller_ops->write_reg(nor, SPINOR_OP_WREN,
>> + NULL, 0);
>> }
>>
>> - return nor->controller_ops->write_reg(nor, SPINOR_OP_WREN, NULL, 0);
>> + if (ret)
>> + dev_err(nor->dev, "error %d on Write Enable\n", ret);
>
> I thought we agreed on using dev_err_once() here (applies to other
> dev_err() calls). If it fails once it's unlikely to succeed on
> subsequent calls, and I don't think spamming the kernel logs is very
> useful.
>
I used dev_err() and not dev_err_once() because if spi_nor_write_enable() fails,
we stop the execution and just return the spi_nor_write_enable()'s error. The
kernel logs will not be spammed because it will be just an error reported.
dev_err_once() would make sense if we change the method's return type from int
to void, but why to ignore possible errors from write enable/disable?
Powered by blists - more mailing lists