netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Dmitry Kravkov" <dmitry@broadcom.com>
To: davem@davemloft.net, netdev@vger.kernel.org, eilong@broadcom.com
Cc: romueu@fz.zoreil.com, "Dmitry Kravkov" <dmitry@broadcom.com>,
	"Francious Romieu" <romieu@fz.zoreil.com>
Subject: [PATCH v3 net-next 2/6] bnx2x: fix byte-by-byte nvram write for BE machines
Date: Mon, 22 Apr 2013 13:15:04 +0300	[thread overview]
Message-ID: <1366625708-5678-3-git-send-email-dmitry@broadcom.com> (raw)
In-Reply-To: <1366625708-5678-1-git-send-email-dmitry@broadcom.com>

CC: Francious Romieu <romieu@fz.zoreil.com>
Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
Looks like no one used this inefficient byte-update method.
In order to avoid painfull merging this is a part of net-next series.
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index 79e5196..ec07b2b 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -1569,9 +1569,8 @@ static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf,
 			      int buf_size)
 {
 	int rc;
-	u32 cmd_flags;
-	u32 align_offset;
-	__be32 val;
+	u32 cmd_flags, align_offset, val;
+	__be32 val_be;
 
 	if (offset + buf_size > bp->common.flash_size) {
 		DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
@@ -1590,16 +1589,16 @@ static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf,
 
 	cmd_flags = (MCPR_NVM_COMMAND_FIRST | MCPR_NVM_COMMAND_LAST);
 	align_offset = (offset & ~0x03);
-	rc = bnx2x_nvram_read_dword(bp, align_offset, &val, cmd_flags);
+	rc = bnx2x_nvram_read_dword(bp, align_offset, &val_be, cmd_flags);
 
 	if (rc == 0) {
-		val &= ~(0xff << BYTE_OFFSET(offset));
-		val |= (*data_buf << BYTE_OFFSET(offset));
-
 		/* nvram data is returned as an array of bytes
 		 * convert it back to cpu order
 		 */
-		val = be32_to_cpu(val);
+		val = be32_to_cpu(val_be);
+
+		val &= ~le32_to_cpu(0xff << BYTE_OFFSET(offset));
+		val |= le32_to_cpu(*data_buf << BYTE_OFFSET(offset));
 
 		rc = bnx2x_nvram_write_dword(bp, align_offset, val,
 					     cmd_flags);
-- 
1.8.1.4

  parent reply	other threads:[~2013-04-22 10:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22 10:15 [PATCH v3 net-next 0/6] bnx2x: refactor nvram related code and update version Dmitry Kravkov
2013-04-22 10:15 ` [PATCH v3 net-next 1/6] bnx2x: refactor nvram read procedure Dmitry Kravkov
2013-04-22 10:15 ` Dmitry Kravkov [this message]
2013-04-22 10:15 ` [PATCH v3 net-next 3/6] bnx2x: remove non-necessary assignment Dmitry Kravkov
2013-04-22 10:15 ` [PATCH v3 net-next 4/6] bnx2x: add additional regions for CRC memory test Dmitry Kravkov
2013-04-22 10:15 ` [PATCH v3 net-next 5/6] bnx2x: allow nvram test to run when device is down Dmitry Kravkov
2013-04-22 10:15 ` [PATCH v3 net-next 6/6] bnx2x: update version to 1.78.17-0 Dmitry Kravkov
2013-04-22 13:35 ` [PATCH v3 net-next 0/6] bnx2x: refactor nvram related code and update version Dmitry Kravkov

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=1366625708-5678-3-git-send-email-dmitry@broadcom.com \
    --to=dmitry@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=eilong@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=romieu@fz.zoreil.com \
    --cc=romueu@fz.zoreil.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).