All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: Tudor.Ambarus@microchip.com
Cc: vigneshr@ti.com, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org, miquel.raynal@bootlin.com,
	richard@nod.at
Subject: Re: [PATCH v4 1/4] mtd: spi-nor: add OTP support
Date: Mon, 15 Mar 2021 11:01:53 +0100	[thread overview]
Message-ID: <bbbc6230b7d60a2421520ce7d163be56@walle.cc> (raw)
In-Reply-To: <f0ffd9b3-94d1-05ca-7e90-5014bf7a3db4@microchip.com>

Am 2021-03-15 10:44, schrieb Tudor.Ambarus@microchip.com:
> On 3/15/21 11:39 AM, Tudor Ambarus - M18064 wrote:
>> On 3/15/21 11:23 AM, Michael Walle wrote:
>> 
>> cut
>> 
>>>>> diff --git a/drivers/mtd/spi-nor/otp.c b/drivers/mtd/spi-nor/otp.c
>>>>> new file mode 100644
>>>>> index 000000000000..4e301fd5156b
>>>>> --- /dev/null
>>>>> +++ b/drivers/mtd/spi-nor/otp.c
>>>>> @@ -0,0 +1,218 @@
>>>>> +// SPDX-License-Identifier: GPL-2.0
>>>>> +/*
>>>>> + * OTP support for SPI NOR flashes
>>>>> + *
>>>>> + * Copyright (C) 2021 Michael Walle <michael@walle.cc>> + */
>>>>> +
>>>>> +#include <linux/log2.h>
>>>>> +#include <linux/mtd/mtd.h>
>>>>> +#include <linux/mtd/spi-nor.h>
>>>>> +
>>>>> +#include "core.h"
>>>>> +
>>>>> +#define spi_nor_otp_ops(nor) ((nor)->params->otp.ops)
>>>>> +#define spi_nor_otp_region_len(nor) ((nor)->params->otp.org->len)
>>>>> +#define spi_nor_otp_n_regions(nor)
>>>>> ((nor)->params->otp.org->n_regions)
>>>> 
>>>> I don't like these wrappers because they gratuiously hide what's 
>>>> really
>>>> there.
>>>> I find the code more easier to read without these wrappers, because 
>>>> I
>>>> don't
>>>> have to memorize what these wrappers are doing, and I better see how
>>>> the code
>>>> is organized.
>>> 
>>> TBH I find it easier on the eye and I've never seen so much 
>>> dereferences
>>> as in mtd/spi-nor.
> 
> the dereferences will still be there, but will be just hidden by these 
> wrappers,
> don't they? Why would one prefer the wrappers?

That's why I wrote "easier on the eye", yes that is subjective. But
there are also technical aspects, for example, the helpers all
operate on "struct nor*", so you don't have to use the
dereference chain or build up local variables. For example, see
spi_nor_otp_read_write(), it doesn't have to know
anything about the "struct spi_nor_otp_organization".

And of course you could change the actual implementation
without touching the code everywhere,.

-michael

WARNING: multiple messages have this Message-ID (diff)
From: Michael Walle <michael@walle.cc>
To: Tudor.Ambarus@microchip.com
Cc: vigneshr@ti.com, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org, miquel.raynal@bootlin.com,
	richard@nod.at
Subject: Re: [PATCH v4 1/4] mtd: spi-nor: add OTP support
Date: Mon, 15 Mar 2021 11:01:53 +0100	[thread overview]
Message-ID: <bbbc6230b7d60a2421520ce7d163be56@walle.cc> (raw)
In-Reply-To: <f0ffd9b3-94d1-05ca-7e90-5014bf7a3db4@microchip.com>

Am 2021-03-15 10:44, schrieb Tudor.Ambarus@microchip.com:
> On 3/15/21 11:39 AM, Tudor Ambarus - M18064 wrote:
>> On 3/15/21 11:23 AM, Michael Walle wrote:
>> 
>> cut
>> 
>>>>> diff --git a/drivers/mtd/spi-nor/otp.c b/drivers/mtd/spi-nor/otp.c
>>>>> new file mode 100644
>>>>> index 000000000000..4e301fd5156b
>>>>> --- /dev/null
>>>>> +++ b/drivers/mtd/spi-nor/otp.c
>>>>> @@ -0,0 +1,218 @@
>>>>> +// SPDX-License-Identifier: GPL-2.0
>>>>> +/*
>>>>> + * OTP support for SPI NOR flashes
>>>>> + *
>>>>> + * Copyright (C) 2021 Michael Walle <michael@walle.cc>> + */
>>>>> +
>>>>> +#include <linux/log2.h>
>>>>> +#include <linux/mtd/mtd.h>
>>>>> +#include <linux/mtd/spi-nor.h>
>>>>> +
>>>>> +#include "core.h"
>>>>> +
>>>>> +#define spi_nor_otp_ops(nor) ((nor)->params->otp.ops)
>>>>> +#define spi_nor_otp_region_len(nor) ((nor)->params->otp.org->len)
>>>>> +#define spi_nor_otp_n_regions(nor)
>>>>> ((nor)->params->otp.org->n_regions)
>>>> 
>>>> I don't like these wrappers because they gratuiously hide what's 
>>>> really
>>>> there.
>>>> I find the code more easier to read without these wrappers, because 
>>>> I
>>>> don't
>>>> have to memorize what these wrappers are doing, and I better see how
>>>> the code
>>>> is organized.
>>> 
>>> TBH I find it easier on the eye and I've never seen so much 
>>> dereferences
>>> as in mtd/spi-nor.
> 
> the dereferences will still be there, but will be just hidden by these 
> wrappers,
> don't they? Why would one prefer the wrappers?

That's why I wrote "easier on the eye", yes that is subjective. But
there are also technical aspects, for example, the helpers all
operate on "struct nor*", so you don't have to use the
dereference chain or build up local variables. For example, see
spi_nor_otp_read_write(), it doesn't have to know
anything about the "struct spi_nor_otp_organization".

And of course you could change the actual implementation
without touching the code everywhere,.

-michael

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2021-03-15 10:02 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-06  0:05 [PATCH v4 0/4] mtd: spi-nor: OTP support Michael Walle
2021-03-06  0:05 ` Michael Walle
2021-03-06  0:05 ` [PATCH v4 1/4] mtd: spi-nor: add " Michael Walle
2021-03-06  0:05   ` Michael Walle
2021-03-15  7:28   ` Tudor.Ambarus
2021-03-15  7:28     ` Tudor.Ambarus
2021-03-15  9:23     ` Michael Walle
2021-03-15  9:23       ` Michael Walle
2021-03-15  9:39       ` Tudor.Ambarus
2021-03-15  9:39         ` Tudor.Ambarus
2021-03-15  9:44         ` Tudor.Ambarus
2021-03-15  9:44           ` Tudor.Ambarus
2021-03-15 10:01           ` Michael Walle [this message]
2021-03-15 10:01             ` Michael Walle
2021-03-06  0:05 ` [PATCH v4 2/4] mtd: spi-nor: implement OTP support for Winbond and similar flashes Michael Walle
2021-03-06  0:05   ` Michael Walle
2021-03-15  8:20   ` Tudor.Ambarus
2021-03-15  8:20     ` Tudor.Ambarus
2021-03-15 10:29     ` Michael Walle
2021-03-15 10:29       ` Michael Walle
2021-03-15  8:31   ` Tudor.Ambarus
2021-03-15  8:31     ` Tudor.Ambarus
2021-03-15 10:43     ` Michael Walle
2021-03-15 10:43       ` Michael Walle
2021-03-06  0:05 ` [PATCH v4 3/4] mtd: spi-nor: winbond: add OTP support to w25q32fw/jw Michael Walle
2021-03-06  0:05   ` Michael Walle
2021-03-15  8:26   ` Tudor.Ambarus
2021-03-15  8:26     ` Tudor.Ambarus
2021-03-15  9:26     ` Michael Walle
2021-03-15  9:26       ` Michael Walle
2021-03-15  9:34       ` Tudor.Ambarus
2021-03-15  9:34         ` Tudor.Ambarus
2021-03-06  0:05 ` [PATCH v4 4/4] mtd: spi-nor: implement OTP erase for Winbond and similar flashes Michael Walle
2021-03-06  0:05   ` Michael Walle
2021-03-06  0:20   ` Michael Walle
2021-03-06  0:20     ` Michael Walle
2021-03-07  8:48   ` kernel test robot
2021-03-07  8:48     ` kernel test robot
2021-03-07  8:48     ` kernel test robot
2021-03-15  8:42   ` Tudor.Ambarus
2021-03-15  8:42     ` Tudor.Ambarus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bbbc6230b7d60a2421520ce7d163be56@walle.cc \
    --to=michael@walle.cc \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.