From: Sascha Hauer <s.hauer@pengutronix.de>
To: Johannes Stezenbach <js@sig21.net>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 4/6] miidev: consistent md and mw on phy regs
Date: Wed, 20 Jun 2012 08:49:16 +0200 [thread overview]
Message-ID: <20120620064916.GF28394@pengutronix.de> (raw)
In-Reply-To: <1340030880-10062-5-git-send-email-js@sig21.net>
On Mon, Jun 18, 2012 at 04:47:58PM +0200, Johannes Stezenbach wrote:
> The dump generated by "md -w -s /dev/phy0"
> suggests individual registers need to be
> addressed by byte offset, not by register number.
> E.g. to set the autonegotiation advertisement register
> for 10Mbit only, use "mw -w -d /dev/phy0 8+2 0x0061".
> The current mix of offset == register number, but
> count == byte count is unintuitive.
>
> Also, to be consistent with "md" on /dev/mem, round up
> the count so "8+1" also works to access one register.
> However, no attempt is made to do read-modify-write
> single byte writes.
>
> Signed-off-by: Johannes Stezenbach <js@sig21.net>
Nice catch. The current behaviour wasn't intended. I probably never
tried to read phy registers with an offset from the command line.
Sascha
> ---
> drivers/net/miidev.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/miidev.c b/drivers/net/miidev.c
> index 98ad790..1c75b87 100644
> --- a/drivers/net/miidev.c
> +++ b/drivers/net/miidev.c
> @@ -204,11 +204,11 @@ static ssize_t miidev_read(struct cdev *cdev, void *_buf, size_t count, ulong of
> uint16_t *buf = _buf;
> struct mii_device *mdev = cdev->priv;
>
> - while (i > 1) {
> - *buf = mii_read(mdev, mdev->address, offset);
> + while (i > 0) {
> + *buf = mii_read(mdev, mdev->address, offset / 2);
> buf++;
> i -= 2;
> - offset++;
> + offset += 2;
> }
>
> return count;
> @@ -220,11 +220,11 @@ static ssize_t miidev_write(struct cdev *cdev, const void *_buf, size_t count, u
> const uint16_t *buf = _buf;
> struct mii_device *mdev = cdev->priv;
>
> - while (i > 1) {
> - mii_write(mdev, mdev->address, offset, *buf);
> + while (i > 0) {
> + mii_write(mdev, mdev->address, offset / 2, *buf);
> buf++;
> i -= 2;
> - offset++;
> + offset += 2;
> }
>
> return count;
> --
> 1.7.10.4
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-06-20 6:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-18 14:47 [PATCH 0/6] misc ethernet fixes and new driver Johannes Stezenbach
2012-06-18 14:47 ` [PATCH 1/6] miidev: fix auto negotiation Johannes Stezenbach
2012-06-18 17:52 ` Roberto Nibali
2012-06-18 19:26 ` Johannes Stezenbach
2012-06-18 14:47 ` [PATCH 2/6] miidev: actually probe the PHY Johannes Stezenbach
2012-06-18 18:27 ` Roberto Nibali
2012-06-18 19:39 ` Johannes Stezenbach
2012-06-18 14:47 ` [PATCH 3/6] miidev: add support for 1000Mbit Johannes Stezenbach
2012-06-18 14:47 ` [PATCH 4/6] miidev: consistent md and mw on phy regs Johannes Stezenbach
2012-06-20 6:49 ` Sascha Hauer [this message]
2012-06-18 14:47 ` [PATCH 5/6] eth: eth MAC addresses are six bytes Johannes Stezenbach
2012-06-18 14:48 ` [PATCH 6/6] drivers/net: add designware driver Johannes Stezenbach
2012-06-20 7:13 ` Sascha Hauer
2012-06-20 8:11 ` Johannes Stezenbach
2012-06-20 8:41 ` Sascha Hauer
2012-06-20 7:15 ` [PATCH 0/6] misc ethernet fixes and new driver Sascha Hauer
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=20120620064916.GF28394@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=js@sig21.net \
/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