From patchwork Wed Jan 26 00:37:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 12724407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F117CC5AC75 for ; Wed, 26 Jan 2022 00:40:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aSTnawni15rJyjLc8a7SRcvmV+IStUc2hfyihZ2BRbw=; b=IaNuaYCgq+o4DB syhKyyb23WQbf/HszOoIjVDzXPKYgaLPVyyFB6S0J+d9nBh8Pp3JNzyGq/4N2vsblEWdzE4+UaQ/I TfbTYvByHFQFisDMLXvyUql0vW/JpbmwfckUJb6XvkPisWo6XqYNoz+PuNFg3PuFOYkvma3WCzWrI BMPkUUyMPjgCrnY9+8zKURwVw6ThJrFhKqFFEKaOPX+iw9jDiL0XihOGfJHuQhw6wRO415Bbqpdpl x3/GnZ4mCxhAzi9KPJ+I1dyDxV00Dj3gpOoVgJVTBKVqaShXcZ2ePFEy8bdksZkyE9Pt07Q+2XncZ 85kWcGQVze/omy7NUzHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCWKn-009k3M-A1; Wed, 26 Jan 2022 00:38:49 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCWK7-009jty-G1 for linux-arm-kernel@lists.infradead.org; Wed, 26 Jan 2022 00:38:10 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9A2E9614ED; Wed, 26 Jan 2022 00:38:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C20C7C340E0; Wed, 26 Jan 2022 00:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643157486; bh=8EPKyibJPLFnHUibBxFOVRIZAK8CWCm519c3Pj97zX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XEV65wnTHrrJMFVD1o4AVGvnyx+XZkTw54t5/+klLsvCw29pnWZleaxwW2LYDes8A /l4HvF1G38v12ijoQzQNuxi30GcCoIUxv/JEn6ZK/e3Fpxfdr8rUuvLmAG9rDGyqjS HmgPtVnZyE0td0tc6HVEVBsbpcefWLd0LuS4RNp45PNZPwHQeHX6lbXFnPZihDnBqo gGhLgList6tuwUvwyfOLbEbTckvIS0MIXlhDU6gaj0PbIOfDjviuTw4/tGab+k9qxh CAlXGCvQPAcP0TwF6sfr+E3FsY5R0uRJ925BO9nISIH+z5nEwdnd0L7W4i+FP0R5lG +WBaNVH6jME5A== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, dave@thedillows.org, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, Jakub Kicinski Subject: [PATCH net v2 2/6] ethernet: tundra: don't write directly to netdev->dev_addr Date: Tue, 25 Jan 2022 16:37:57 -0800 Message-Id: <20220126003801.1736586-3-kuba@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220126003801.1736586-1-kuba@kernel.org> References: <20220126003801.1736586-1-kuba@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220125_163807_636884_A268714B X-CRM114-Status: GOOD ( 15.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org netdev->dev_addr is const now. Maintain the questionable offsetting in ndo_set_mac_address. Compile tested holly_defconfig and mpc7448_hpc2_defconfig. Fixes: adeef3e32146 ("net: constify netdev->dev_addr") Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/tundra/tsi108_eth.c | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/tundra/tsi108_eth.c b/drivers/net/ethernet/tundra/tsi108_eth.c index cf0917b29e30..5251fc324221 100644 --- a/drivers/net/ethernet/tundra/tsi108_eth.c +++ b/drivers/net/ethernet/tundra/tsi108_eth.c @@ -1091,20 +1091,22 @@ static int tsi108_get_mac(struct net_device *dev) struct tsi108_prv_data *data = netdev_priv(dev); u32 word1 = TSI_READ(TSI108_MAC_ADDR1); u32 word2 = TSI_READ(TSI108_MAC_ADDR2); + u8 addr[ETH_ALEN]; /* Note that the octets are reversed from what the manual says, * producing an even weirder ordering... */ if (word2 == 0 && word1 == 0) { - dev->dev_addr[0] = 0x00; - dev->dev_addr[1] = 0x06; - dev->dev_addr[2] = 0xd2; - dev->dev_addr[3] = 0x00; - dev->dev_addr[4] = 0x00; + addr[0] = 0x00; + addr[1] = 0x06; + addr[2] = 0xd2; + addr[3] = 0x00; + addr[4] = 0x00; if (0x8 == data->phy) - dev->dev_addr[5] = 0x01; + addr[5] = 0x01; else - dev->dev_addr[5] = 0x02; + addr[5] = 0x02; + eth_hw_addr_set(dev, addr); word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24); @@ -1114,12 +1116,13 @@ static int tsi108_get_mac(struct net_device *dev) TSI_WRITE(TSI108_MAC_ADDR1, word1); TSI_WRITE(TSI108_MAC_ADDR2, word2); } else { - dev->dev_addr[0] = (word2 >> 16) & 0xff; - dev->dev_addr[1] = (word2 >> 24) & 0xff; - dev->dev_addr[2] = (word1 >> 0) & 0xff; - dev->dev_addr[3] = (word1 >> 8) & 0xff; - dev->dev_addr[4] = (word1 >> 16) & 0xff; - dev->dev_addr[5] = (word1 >> 24) & 0xff; + addr[0] = (word2 >> 16) & 0xff; + addr[1] = (word2 >> 24) & 0xff; + addr[2] = (word1 >> 0) & 0xff; + addr[3] = (word1 >> 8) & 0xff; + addr[4] = (word1 >> 16) & 0xff; + addr[5] = (word1 >> 24) & 0xff; + eth_hw_addr_set(dev, addr); } if (!is_valid_ether_addr(dev->dev_addr)) { @@ -1136,14 +1139,12 @@ static int tsi108_set_mac(struct net_device *dev, void *addr) { struct tsi108_prv_data *data = netdev_priv(dev); u32 word1, word2; - int i; if (!is_valid_ether_addr(addr)) return -EADDRNOTAVAIL; - for (i = 0; i < 6; i++) - /* +2 is for the offset of the HW addr type */ - dev->dev_addr[i] = ((unsigned char *)addr)[i + 2]; + /* +2 is for the offset of the HW addr type */ + eth_hw_addr_set(dev, ((unsigned char *)addr) + 2); word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24);