Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1474831

[Patch v4 09/12] net: ethernet: xilinx: Generate random mac if none found

From Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
Newsgroups linux.kernel
Subject [Patch v4 09/12] net: ethernet: xilinx: Generate random mac if none found
Date 2016-09-02 02:50 +0200
Message-ID <scKQa-Fd-21@gated-at.bofh.it> (permalink)
References <scIlj-7GM-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


At the moment, if the emaclite device doesn't find a mac address
from any source, it simply uses 0x0 with a warning printed.

Instead of using a 0x0 mac address, use a randomly generated one.

Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>

---
V3 -> V4
Curly braces after if check for correct styling

V2 -> V3
No change

V1 -> V2
New patch
---
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 3cee84a..efc8d2e 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1131,11 +1131,13 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
 	lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong");
 	mac_address = of_get_mac_address(ofdev->dev.of_node);
 
-	if (mac_address)
+	if (mac_address) {
 		/* Set the MAC address. */
 		memcpy(ndev->dev_addr, mac_address, ETH_ALEN);
-	else
-		dev_warn(dev, "No MAC address found\n");
+	} else {
+		dev_warn(dev, "No MAC address found. Generating Random one\n");
+		eth_hw_addr_random(ndev);
+	}
 
 	/* Clear the Tx CSR's in case this is a restart */
 	__raw_writel(0, lp->base_addr + XEL_TSR_OFFSET);
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[Patch v4 00/12] microblaze/MIPS: xilfpga: intc and peripheral Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:40 +0200
  [Patch v4 10/12] net: ethernet: xilinx: Enable emaclite for MIPS Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:40 +0200
  [Patch v4 05/12] MIPS: xilfpga: Use irqchip_init instead of the legacy way Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:40 +0200
  [Patch v4 11/12] MIPS: xilfpga: Add DT node for AXI emaclite Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:40 +0200
  [Patch v4 02/12] irqchip: axi-intc: Clean up irqdomain argument and read/write Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:40 +0200
    Re: [Patch v4 02/12] irqchip: axi-intc: Clean up irqdomain argument  and read/write kbuild test robot <lkp@intel.com> - 2016-09-02 03:30 +0200
  [Patch v4 03/12] irqchip: axi-intc: Rename get_irq to xintc_get_irq Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:40 +0200
  [Patch v4 07/12] MIPS: xilfpga: Update DT node and specify uart irq Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:50 +0200
  [Patch v4 04/12] irqchip: axi-intc: Add support for parent intc Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:50 +0200
  [Patch v4 08/12] MIPS: Xilfpga: Add DT node for AXI I2C Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:50 +0200
  [Patch v4 09/12] net: ethernet: xilinx: Generate random mac if none found Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:50 +0200
  [Patch v4 12/12] MIPS: xilfpga: Update defconfig Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:50 +0200
  [Patch v4 01/12] microblaze: irqchip: Move intc driver to irqchip Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 02:50 +0200
    Re: [Patch v4 01/12] microblaze: irqchip: Move intc driver to irqchip Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 12:00 +0200
    Re: [Patch v4 01/12] microblaze: irqchip: Move intc driver to irqchip Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 12:10 +0200
      Re: [Patch v4 01/12] microblaze: irqchip: Move intc driver to irqchip Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> - 2016-09-02 13:50 +0200
        Re: [Patch v4 01/12] microblaze: irqchip: Move intc driver to irqchip Jason Cooper <jason@lakedaemon.net> - 2016-09-02 14:50 +0200
      Re: [Patch v4 01/12] microblaze: irqchip: Move intc driver to irqchip Jason Cooper <jason@lakedaemon.net> - 2016-09-02 15:30 +0200
      Re: [Patch v4 01/12] microblaze: irqchip: Move intc driver to irqchip Marc Zyngier <marc.zyngier@arm.com> - 2016-09-02 15:40 +0200

csiph-web