All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: ath9k-devel@lists.ath9k.org
Subject: [ath9k-devel] [PATCH 5/5] ath9k: Make EEPROM endianness swapping configurable via devicetree
Date: Tue, 30 Aug 2016 09:57:24 +0200	[thread overview]
Message-ID: <201608300957.24770.arnd@arndb.de> (raw)
In-Reply-To: <CAFBinCCXqX1F3XpU-DFLLB5ZNjU1XVNiTLR-ZB34QgrL8uyv8Q@mail.gmail.com>

On Tuesday 30 August 2016, Martin Blumenstingl wrote:
> new logic (assuming that we went for __le16/__le32 fields):
> - reading data: use le16_to_cpu and le32_to_cpu for all fields
> 
> LE system:
> - LE EEPROM -> no swap will be applied
> - BE EEPROM -> be16_to_cpu / be32_to_cpu (or swab16 / swab32 as before)
> BE system:
> - LE EEPROM -> le16_to_cpu / le32_to_cpu (or swab16 / swab32 as before)
> - BE EEPROM -> no swap will be applied

I think this should be:

LE and BE systems:
 - LE EEPROM -> no swap will be applied
 - BE EEPROM -> or swab16 / swab32

The upside of this is that we no longer care about what the CPU is,
and in my opinion that makes the code easier to understand.

> There is one downside of the "new approach" I can think of: you need
> to swap the data twice in some cases (BE EEPROM on a BE machine).
> - first swap while writing the data to __le16/__le32 fields
> - second swap while reading the data from the __le16/__le32 fields
> If you forget to swap a field in either place then things will be broken.

Correct. Fortunately, "make C=1" with sparse helps you find those bugs
at compile time.

> Maybe someone else wants to state his/her opinion on this - I guess
> some fresh thoughts could help us a lot!

Yes, that would be helpful. It's possible I'm missing something here,
or that changing this will just add confusion with other people.

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: nbd@nbd.name, kvalo@codeaurora.org, ath9k-devel@qca.qualcomm.com,
	linux-wireless@vger.kernel.org, ath9k-devel@lists.ath9k.org,
	devicetree@vger.kernel.org, mark.rutland@arm.com,
	chunkeey@googlemail.com, robh+dt@kernel.org
Subject: Re: [PATCH 5/5] ath9k: Make EEPROM endianness swapping configurable via devicetree
Date: Tue, 30 Aug 2016 09:57:24 +0200	[thread overview]
Message-ID: <201608300957.24770.arnd@arndb.de> (raw)
In-Reply-To: <CAFBinCCXqX1F3XpU-DFLLB5ZNjU1XVNiTLR-ZB34QgrL8uyv8Q@mail.gmail.com>

On Tuesday 30 August 2016, Martin Blumenstingl wrote:
> new logic (assuming that we went for __le16/__le32 fields):
> - reading data: use le16_to_cpu and le32_to_cpu for all fields
> 
> LE system:
> - LE EEPROM -> no swap will be applied
> - BE EEPROM -> be16_to_cpu / be32_to_cpu (or swab16 / swab32 as before)
> BE system:
> - LE EEPROM -> le16_to_cpu / le32_to_cpu (or swab16 / swab32 as before)
> - BE EEPROM -> no swap will be applied

I think this should be:

LE and BE systems:
 - LE EEPROM -> no swap will be applied
 - BE EEPROM -> or swab16 / swab32

The upside of this is that we no longer care about what the CPU is,
and in my opinion that makes the code easier to understand.

> There is one downside of the "new approach" I can think of: you need
> to swap the data twice in some cases (BE EEPROM on a BE machine).
> - first swap while writing the data to __le16/__le32 fields
> - second swap while reading the data from the __le16/__le32 fields
> If you forget to swap a field in either place then things will be broken.

Correct. Fortunately, "make C=1" with sparse helps you find those bugs
at compile time.

> Maybe someone else wants to state his/her opinion on this - I guess
> some fresh thoughts could help us a lot!

Yes, that would be helpful. It's possible I'm missing something here,
or that changing this will just add confusion with other people.

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
	linux-wireless@vger.kernel.org, ath9k-devel@qca.qualcomm.com,
	robh+dt@kernel.org, ath9k-devel@lists.ath9k.org,
	chunkeey@googlemail.com, kvalo@codeaurora.org, nbd@nbd.name
Subject: Re: [PATCH 5/5] ath9k: Make EEPROM endianness swapping configurable via devicetree
Date: Tue, 30 Aug 2016 09:57:24 +0200	[thread overview]
Message-ID: <201608300957.24770.arnd@arndb.de> (raw)
In-Reply-To: <CAFBinCCXqX1F3XpU-DFLLB5ZNjU1XVNiTLR-ZB34QgrL8uyv8Q@mail.gmail.com>

On Tuesday 30 August 2016, Martin Blumenstingl wrote:
> new logic (assuming that we went for __le16/__le32 fields):
> - reading data: use le16_to_cpu and le32_to_cpu for all fields
> 
> LE system:
> - LE EEPROM -> no swap will be applied
> - BE EEPROM -> be16_to_cpu / be32_to_cpu (or swab16 / swab32 as before)
> BE system:
> - LE EEPROM -> le16_to_cpu / le32_to_cpu (or swab16 / swab32 as before)
> - BE EEPROM -> no swap will be applied

I think this should be:

LE and BE systems:
 - LE EEPROM -> no swap will be applied
 - BE EEPROM -> or swab16 / swab32

The upside of this is that we no longer care about what the CPU is,
and in my opinion that makes the code easier to understand.

> There is one downside of the "new approach" I can think of: you need
> to swap the data twice in some cases (BE EEPROM on a BE machine).
> - first swap while writing the data to __le16/__le32 fields
> - second swap while reading the data from the __le16/__le32 fields
> If you forget to swap a field in either place then things will be broken.

Correct. Fortunately, "make C=1" with sparse helps you find those bugs
at compile time.

> Maybe someone else wants to state his/her opinion on this - I guess
> some fresh thoughts could help us a lot!

Yes, that would be helpful. It's possible I'm missing something here,
or that changing this will just add confusion with other people.

	Arnd

  reply	other threads:[~2016-08-30  7:57 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-21 14:49 [ath9k-devel] [PATCH 0/5] ath9k: EEPROM swapping improvements Martin Blumenstingl
2016-08-21 14:49 ` Martin Blumenstingl
2016-08-21 14:49 ` Martin Blumenstingl
2016-08-21 14:49 ` [ath9k-devel] [PATCH 1/5] ath9k: Add a #define for the EEPROM "eepmisc" endianness bit Martin Blumenstingl
2016-08-21 14:49   ` Martin Blumenstingl
2016-08-21 14:49   ` Martin Blumenstingl
2016-08-22 11:42   ` [ath9k-devel] " Arnd Bergmann
2016-08-22 11:42     ` Arnd Bergmann
2016-08-22 11:42     ` Arnd Bergmann
2016-08-21 14:49 ` [ath9k-devel] [PATCH 2/5] ath9k: Set the "big endian" bit of the AR9003 EEPROM templates Martin Blumenstingl
2016-08-21 14:49   ` Martin Blumenstingl
2016-08-21 14:49   ` Martin Blumenstingl
2016-08-22 11:47   ` [ath9k-devel] " Arnd Bergmann
2016-08-22 11:47     ` Arnd Bergmann
2016-08-22 11:47     ` Arnd Bergmann
2016-08-22 11:56     ` [ath9k-devel] " Martin Blumenstingl
2016-08-22 11:56       ` Martin Blumenstingl
2016-08-22 11:56       ` Martin Blumenstingl
2016-08-22 15:31       ` [ath9k-devel] " Arnd Bergmann
2016-08-22 15:31         ` Arnd Bergmann
2016-08-22 15:31         ` Arnd Bergmann
2016-08-22 20:31         ` [ath9k-devel] " Martin Blumenstingl
2016-08-22 20:31           ` Martin Blumenstingl
2016-08-22 20:31           ` Martin Blumenstingl
2016-08-21 14:49 ` [ath9k-devel] [PATCH 3/5] ath9k: Add an eeprom_ops callback for retrieving the eepmisc value Martin Blumenstingl
2016-08-21 14:49   ` Martin Blumenstingl
2016-08-21 14:49   ` Martin Blumenstingl
2016-08-21 14:49 ` [ath9k-devel] [PATCH 4/5] ath9k: Make the EEPROM swapping check use the eepmisc register Martin Blumenstingl
2016-08-21 14:49   ` Martin Blumenstingl
2016-08-21 14:49   ` Martin Blumenstingl
2016-08-21 14:49 ` [ath9k-devel] [PATCH 5/5] ath9k: Make EEPROM endianness swapping configurable via devicetree Martin Blumenstingl
2016-08-21 14:49   ` Martin Blumenstingl
2016-08-21 14:49   ` Martin Blumenstingl
2016-08-22 11:52   ` [ath9k-devel] " Arnd Bergmann
2016-08-22 11:52     ` Arnd Bergmann
2016-08-22 11:52     ` Arnd Bergmann
2016-08-28 21:10     ` [ath9k-devel] " Martin Blumenstingl
2016-08-28 21:10       ` Martin Blumenstingl
2016-08-28 21:10       ` Martin Blumenstingl
2016-08-29 12:10       ` [ath9k-devel] " Arnd Bergmann
2016-08-29 12:10         ` Arnd Bergmann
2016-08-29 12:10         ` Arnd Bergmann
2016-08-29 19:45         ` [ath9k-devel] " Martin Blumenstingl
2016-08-29 19:45           ` Martin Blumenstingl
2016-08-29 19:45           ` Martin Blumenstingl
2016-08-29 21:25           ` [ath9k-devel] " Arnd Bergmann
2016-08-29 21:25             ` Arnd Bergmann
2016-08-29 21:25             ` Arnd Bergmann
2016-08-29 22:07             ` [ath9k-devel] " Martin Blumenstingl
2016-08-29 22:07               ` Martin Blumenstingl
2016-08-29 22:07               ` Martin Blumenstingl
2016-08-30  7:57               ` Arnd Bergmann [this message]
2016-08-30  7:57                 ` Arnd Bergmann
2016-08-30  7:57                 ` Arnd Bergmann
2016-10-02 22:29 ` [ath9k-devel] [PATCH v2 0/7] ath9k: EEPROM swapping improvements Martin Blumenstingl
2016-10-02 22:29   ` Martin Blumenstingl
2016-10-02 22:29   ` Martin Blumenstingl
2016-10-02 22:29   ` [ath9k-devel] [PATCH v2 1/7] ath9k: Add a #define for the EEPROM "eepmisc" endianness bit Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29   ` [ath9k-devel] [PATCH v2 2/7] ath9k: indicate that the AR9003 EEPROM template values are little endian Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29   ` [ath9k-devel] [PATCH v2 3/7] ath9k: Add an eeprom_ops callback for retrieving the eepmisc value Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29   ` [ath9k-devel] [PATCH v2 4/7] ath9k: replace eeprom_param EEP_MINOR_REV with get_eeprom_rev Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29   ` [ath9k-devel] [PATCH v2 5/7] ath9k: consistently use get_eeprom_rev(ah) Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29   ` [ath9k-devel] [PATCH v2 6/7] ath9k: Make the EEPROM swapping check use the eepmisc register Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29   ` [ath9k-devel] [PATCH v2 7/7] ath9k: define all EEPROM fields in Little Endian format Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-02 22:29     ` Martin Blumenstingl
2016-10-12 13:18   ` [ath9k-devel] [PATCH v2 0/7] ath9k: EEPROM swapping improvements Kalle Valo
2016-10-12 13:18     ` Kalle Valo
2016-10-12 13:18     ` Kalle Valo
2016-11-25 15:06     ` [ath9k-devel] " Valo, Kalle
2016-11-25 15:06       ` Valo, Kalle
2016-11-25 15:06       ` Valo, Kalle
2016-11-25 23:49       ` [ath9k-devel] " Martin Blumenstingl
2016-11-25 23:49         ` Martin Blumenstingl
2016-11-25 23:49         ` Martin Blumenstingl
2016-12-12 20:05       ` [ath9k-devel] " Martin Blumenstingl
2016-12-12 20:05         ` Martin Blumenstingl
2016-12-12 20:05         ` Martin Blumenstingl
2016-12-13 12:03         ` [ath9k-devel] " Valo, Kalle
2016-12-13 12:03           ` Valo, Kalle
2016-12-13 12:03           ` Valo, Kalle
2016-12-14  6:45         ` [ath9k-devel] " Adrian Chadd
2016-12-14  6:45           ` Adrian Chadd
2016-12-14  6:45           ` Adrian Chadd
2016-12-17 14:40           ` [ath9k-devel] " Martin Blumenstingl
2016-12-17 14:40             ` Martin Blumenstingl
2016-12-17 14:40             ` Martin Blumenstingl
2016-12-15  8:34   ` [ath9k-devel] " Valo, Kalle
2016-12-15  8:34     ` Valo, Kalle
2016-12-15  8:34     ` Valo, Kalle

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=201608300957.24770.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=ath9k-devel@lists.ath9k.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 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.