devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Andrei.Simion@microchip.com>
To: <brgl@bgdev.pl>
Cc: <robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<Nicolas.Ferre@microchip.com>, <alexandre.belloni@bootlin.com>,
	<claudiu.beznea@tuxon.dev>, <arnd@arndb.de>,
	<gregkh@linuxfoundation.org>, <linux-i2c@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<claudiu.beznea@microchip.com>
Subject: Re: [PATCH v3 1/3] eeprom: at24: avoid adjusting offset for 24AA025E{48, 64}
Date: Mon, 1 Jul 2024 12:17:13 +0000	[thread overview]
Message-ID: <e9878950-5751-475c-aa39-cb96ddec3911@microchip.com> (raw)
In-Reply-To: <CAMRc=MfiYZOzA+T6+_jZgz-=UsHxGO5vhS8zhjX2ckUf2YxG_w@mail.gmail.com>

On 01.07.2024 14:16, Bartosz Golaszewski wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Mon, Jul 1, 2024 at 12:20 PM <Andrei.Simion@microchip.com> wrote:
>>
>> On 01.07.2024 11:46, Bartosz Golaszewski wrote:
>>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>>>
>>> On Mon, Jul 1, 2024 at 9:23 AM <Andrei.Simion@microchip.com> wrote:
>>>>
>>>>>>
>>>>>> For those types of eeprom 24AA025E{48, 64} adjusting offset is not required (at24_get_offset_adj()).
>>>>>> So, indeed, it is an entanglement in logic.
>>>>>> To keep the implementation as it is:
>>>>>> adjoff (which is a flag that indicates when to use the adjusting offset) needs to be 1 for old compatibles but for these new ones needs to be 0.
>>>>>>
>>>>>> I think that is enough not to break the existing users. What are your thoughts?
>>>>>>
>>>>>
>>>>> Wait... is the adjoff field effectively a boolean? Why u8?
>>>>>
>>>>
>>>> struct at24_data contains offset_adj which will get value calling at24_get_offset_adj()) if adjoff is true (1).
>>>> Yes, adjoff needs to be treated as a boolean. I will change it in the next version.
>>>>
>>>
>>> No, wait. Why can't you just do:
>>>
>>> AT24_CHIP_DATA(at24_data_24aa025e48, 48 / 8, AT24_FLAG_READONLY);
>>>
>>> and avoid this whole new macro variant entirely?
>>>
>>
>> just AT24_CHIP_DATA(at24_data_24aa025e48, 48 / 8, AT24_FLAG_READONLY):
>> # hexdump -C /sys/bus/nvmem/devices/1-00532/cells/eui48@fa\,0
>> 00000000  ff ff ff ff ff ff                                 |......|
>> 00000006
>> # hexdump -C /sys/bus/nvmem/devices/1-00521/cells/eui48@fa\,0
>> 00000000  ff ff ff ff ff ff                                 |......|
>> 00000006
>>
>> with this patch (adjoff false and new macro)
>> # hexdump -C /sys/bus/nvmem/devices/1-00521/cells/eui48@fa\,0
>> 00000000  04 91 62 [the rest bytes]                                 |..b...|
>> 00000006
>> # hexdump -C /sys/bus/nvmem/devices/1-00532/cells/eui48@fa\,0
>> 00000000  04 91 62 [the rest bytes]                                 |..b..m|
>> 00000006
>> #
>>
> 
> Ok, but your goal is for at24_get_offset_adj() to return 0, isn't it?
> This is what line
> 
> at24->offset_adj = cdata->adjoff ? at24_get_offset_adj(flags, byte_len) : 0;
> 
> is effectively achieving. What's the difference between this patch and
> the solution I'm proposing? Isn't the offset_adj field 0 in both
> cases? Is there any other difference I'm not seeing?
> 
> Because I still think we can avoid all this churn.
> 

I've rechecked what you said and see the function implementation at24_get_offset_adj(flags, byte_len) and made a mistake.
I didn't see that you said only AT24_FLAG_READONLY. (Sorry for the wrong output)
Ok, if I put only AT24_FLAG_READONLY then at24_get_offset_adj(flags,  byte_len)  returns 0 -> I've got in both 'cells/eui48@fa\,0' the MAC address.

Best Regards,
Andrei

> Bart


  reply	other threads:[~2024-07-01 12:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-28  8:01 [PATCH v3 0/3] Read MAC address through NVMEM for sama7g5ek Andrei Simion
2024-06-28  8:01 ` [PATCH v3 1/3] eeprom: at24: avoid adjusting offset for 24AA025E{48, 64} Andrei Simion
2024-06-28  8:30   ` Bartosz Golaszewski
2024-06-28 14:17     ` Andrei.Simion
2024-06-28 14:46       ` Bartosz Golaszewski
2024-07-01  7:23         ` Andrei.Simion
2024-07-01  8:46           ` Bartosz Golaszewski
2024-07-01 10:20             ` Andrei.Simion
2024-07-01 11:16               ` Bartosz Golaszewski
2024-07-01 12:17                 ` Andrei.Simion [this message]
2024-06-28  8:01 ` [PATCH v3 2/3] ARM: dts: at91: at91-sama7g5ek: add EEPROMs Andrei Simion
2024-06-28  8:01 ` [PATCH v3 3/3] dt-bindings: eeprom: at24: Add Microchip 24AA025E48/24AA025E64 Andrei Simion
2024-06-28  9:09   ` Conor Dooley
2024-07-01 14:37     ` Andrei.Simion
2024-07-01 14:47       ` Conor Dooley
2024-07-01 14:56         ` Andrei.Simion
2024-06-28  8:29 ` [PATCH v3 0/3] Read MAC address through NVMEM for sama7g5ek Arnd Bergmann
2024-06-28 14:06   ` Andrei.Simion
2024-06-28 14:25     ` Arnd Bergmann

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=e9878950-5751-475c-aa39-cb96ddec3911@microchip.com \
    --to=andrei.simion@microchip.com \
    --cc=Nicolas.Ferre@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=arnd@arndb.de \
    --cc=brgl@bgdev.pl \
    --cc=claudiu.beznea@microchip.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).