From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from [2a02:8b8:656::164] (helo=bar.sig21.net) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SgdFo-0007hK-RU for barebox@lists.infradead.org; Mon, 18 Jun 2012 14:48:33 +0000 Received: from p5099b351.dip0.t-ipconnect.de ([80.153.179.81] helo=zzz.local) by bar.sig21.net with esmtpsa (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.72) (envelope-from ) id 1SgdFM-0008C4-1w for barebox@lists.infradead.org; Mon, 18 Jun 2012 16:48:09 +0200 Received: from js by zzz.local with local (Exim 4.80) (envelope-from ) id 1SgdFL-0002ff-Fa for barebox@lists.infradead.org; Mon, 18 Jun 2012 16:48:03 +0200 From: Johannes Stezenbach Date: Mon, 18 Jun 2012 16:47:58 +0200 Message-Id: <1340030880-10062-5-git-send-email-js@sig21.net> In-Reply-To: <1340030880-10062-1-git-send-email-js@sig21.net> References: <1340030880-10062-1-git-send-email-js@sig21.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: barebox-bounces@lists.infradead.org Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 4/6] miidev: consistent md and mw on phy regs To: barebox@lists.infradead.org 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 --- 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