netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH 1/1] net: phy: Fix reading LED reg property
Date: Mon, 24 Apr 2023 16:02:23 +0200	[thread overview]
Message-ID: <4797433.GXAFRqVoOG@steina-w> (raw)
In-Reply-To: <c01a4c59-6668-4ae7-b7cf-54d5a5a7e897@lunn.ch>

Hi Andrew,

Am Montag, 24. April 2023, 15:47:14 CEST schrieb Andrew Lunn:
> On Mon, Apr 24, 2023 at 03:40:02PM +0200, Alexander Stein wrote:
> > 'reg' is always encoded in 32 bits, thus it has to be read using the
> > function with the corresponding bit width.
> 
> Hi Alexander
> 
> Is this an endian thing? Does it return the wrong value on big endian
> systems?

It is an endian issue, but the platform's endianess doesn't matter here. The 
encoding for device properties is (always) big-endian, so a 32-bit 'reg' value 
of '2' looks like this:

$ hexdump -C /sys/firmware/devicetree/base/soc@0/bus@30800000/
ethernet@30bf0000/mdio/ethernet-phy@3/leds/led@2/reg
00000000  00 00 00 02                                       |....|
00000004

Using of_property_read_u8 will only read the first byte, thus all values of 
reg result in 0.

> I deliberately used of_property_read_u8() because it will perform a
> range check, and if the value is bigger or smaller than 0-256 it will
> return an error. Your change does not include such range checks, which
> i don't like.

Sure, I can added this check.

Best regards,
Alexander
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/



  reply	other threads:[~2023-04-24 14:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 13:40 [PATCH 1/1] net: phy: Fix reading LED reg property Alexander Stein
2023-04-24 13:47 ` Andrew Lunn
2023-04-24 14:02   ` Alexander Stein [this message]
2023-04-24 14:51     ` Andrew Lunn

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=4797433.GXAFRqVoOG@steina-w \
    --to=alexander.stein@ew.tq-group.com \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 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).