From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Doug Berger <opendmb@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
bcm-kernel-feedback-list@broadcom.com,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, Jeremy Linton <jeremy.linton@arm.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 4/5] net: bcmgenet: Use get_unligned_beXX() and put_unaligned_beXX()
Date: Tue, 21 Apr 2020 00:51:20 +0300 [thread overview]
Message-ID: <20200420215121.17735-5-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200420215121.17735-1-andriy.shevchenko@linux.intel.com>
It's convenient to use get_unligned_beXX() and put_unaligned_beXX() helpers
to get or set MAC instead of open-coded variants.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 86666e9ab3e7..2c9881032a24 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2702,9 +2702,8 @@ static void bcmgenet_umac_reset(struct bcmgenet_priv *priv)
static void bcmgenet_set_hw_addr(struct bcmgenet_priv *priv,
unsigned char *addr)
{
- bcmgenet_umac_writel(priv, (addr[0] << 24) | (addr[1] << 16) |
- (addr[2] << 8) | addr[3], UMAC_MAC0);
- bcmgenet_umac_writel(priv, (addr[4] << 8) | addr[5], UMAC_MAC1);
+ bcmgenet_umac_writel(priv, get_unaligned_be32(&addr[0]), UMAC_MAC0);
+ bcmgenet_umac_writel(priv, get_unaligned_be16(&addr[4]), UMAC_MAC1);
}
static void bcmgenet_get_hw_addr(struct bcmgenet_priv *priv,
@@ -2713,13 +2712,9 @@ static void bcmgenet_get_hw_addr(struct bcmgenet_priv *priv,
u32 addr_tmp;
addr_tmp = bcmgenet_umac_readl(priv, UMAC_MAC0);
- addr[0] = addr_tmp >> 24;
- addr[1] = (addr_tmp >> 16) & 0xff;
- addr[2] = (addr_tmp >> 8) & 0xff;
- addr[3] = addr_tmp & 0xff;
+ put_unaligned_be32(addr_tmp, &addr[0]);
addr_tmp = bcmgenet_umac_readl(priv, UMAC_MAC1);
- addr[4] = (addr_tmp >> 8) & 0xff;
- addr[5] = addr_tmp & 0xff;
+ put_unaligned_be16(addr_tmp, &addr[4]);
}
/* Returns a reusable dma control register value */
--
2.26.1
next prev parent reply other threads:[~2020-04-20 21:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 21:51 [PATCH v2 0/5] net: bcmgenet: Clean up after ACPI enablement Andy Shevchenko
2020-04-20 21:51 ` [PATCH v2 1/5] net: bcmgenet: Drop ACPI_PTR() to avoid compiler warning Andy Shevchenko
2020-04-20 21:51 ` [PATCH v2 2/5] net: bcmgenet: Drop useless OF code Andy Shevchenko
2020-04-20 22:09 ` Florian Fainelli
2020-04-20 21:51 ` [PATCH v2 3/5] net: bcmgenet: Use devm_clk_get_optional() to get the clocks Andy Shevchenko
2020-04-20 21:51 ` Andy Shevchenko [this message]
2020-04-20 21:51 ` [PATCH v2 5/5] net: bcmgenet: Drop too many parentheses in bcmgenet_probe() Andy Shevchenko
2020-04-20 22:09 ` Florian Fainelli
2020-04-20 23:25 ` [PATCH v2 0/5] net: bcmgenet: Clean up after ACPI enablement David Miller
2020-04-21 13:14 ` Jeremy Linton
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=20200420215121.17735-5-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=jeremy.linton@arm.com \
--cc=netdev@vger.kernel.org \
--cc=opendmb@gmail.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).