Skip to content

Commit

Permalink
drivers: net: Don't print unpopulated net_device name
Browse files Browse the repository at this point in the history
For ethernet devices, net_device.name will be eth%d before
register_netdev() is called. Don't print the net_device name until
the format string is replaced.

Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
Cc: Marcel Ziswiler <marcel@ziswiler.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Barry Song <Baohua.Song@csr.com>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Harvey Hunt authored and David S. Miller committed May 17, 2016
1 parent 39651ab commit 3274940
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
11 changes: 7 additions & 4 deletions drivers/net/ethernet/davicom/dm9000.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,7 @@ dm9000_probe(struct platform_device *pdev)
int reset_gpios;
enum of_gpio_flags flags;
struct regulator *power;
bool inv_mac_addr = false;

power = devm_regulator_get(dev, "vcc");
if (IS_ERR(power)) {
Expand Down Expand Up @@ -1686,9 +1687,7 @@ dm9000_probe(struct platform_device *pdev)
}

if (!is_valid_ether_addr(ndev->dev_addr)) {
dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
"set using ifconfig\n", ndev->name);

inv_mac_addr = true;
eth_hw_addr_random(ndev);
mac_src = "random";
}
Expand All @@ -1697,11 +1696,15 @@ dm9000_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ndev);
ret = register_netdev(ndev);

if (ret == 0)
if (ret == 0) {
if (inv_mac_addr)
dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please set using ip\n",
ndev->name);
printk(KERN_INFO "%s: dm9000%c at %p,%p IRQ %d MAC: %pM (%s)\n",
ndev->name, dm9000_type_to_char(db->type),
db->io_addr, db->io_data, ndev->irq,
ndev->dev_addr, mac_src);
}
return 0;

out:
Expand Down
7 changes: 5 additions & 2 deletions drivers/net/ethernet/micrel/ks8695net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,7 @@ ks8695_probe(struct platform_device *pdev)
struct resource *rxirq_res, *txirq_res, *linkirq_res;
int ret = 0;
int buff_n;
bool inv_mac_addr = false;
u32 machigh, maclow;

/* Initialise a net_device */
Expand Down Expand Up @@ -1456,8 +1457,7 @@ ks8695_probe(struct platform_device *pdev)
ndev->dev_addr[5] = maclow & 0xFF;

if (!is_valid_ether_addr(ndev->dev_addr))
dev_warn(ksp->dev, "%s: Invalid ethernet MAC address. Please "
"set using ifconfig\n", ndev->name);
inv_mac_addr = true;

/* In order to be efficient memory-wise, we allocate both
* rings in one go.
Expand Down Expand Up @@ -1520,6 +1520,9 @@ ks8695_probe(struct platform_device *pdev)
ret = register_netdev(ndev);

if (ret == 0) {
if (inv_mac_addr)
dev_warn(ksp->dev, "%s: Invalid ethernet MAC address. Please set using ip\n",
ndev->name);
dev_info(ksp->dev, "ks8695 ethernet (%s) MAC: %pM\n",
ks8695_port_type(ksp), ndev->dev_addr);
} else {
Expand Down
12 changes: 8 additions & 4 deletions drivers/net/ethernet/netx-eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ static int netx_eth_enable(struct net_device *ndev)
{
struct netx_eth_priv *priv = netdev_priv(ndev);
unsigned int mac4321, mac65;
int running, i;
int running, i, ret;
bool inv_mac_addr = false;

ndev->netdev_ops = &netx_eth_netdev_ops;
ndev->watchdog_timeo = msecs_to_jiffies(5000);
Expand Down Expand Up @@ -358,15 +359,18 @@ static int netx_eth_enable(struct net_device *ndev)
xc_start(priv->xc);

if (!is_valid_ether_addr(ndev->dev_addr))
printk("%s: Invalid ethernet MAC address. Please "
"set using ifconfig\n", ndev->name);
inv_mac_addr = true;

for (i=2; i<=18; i++)
pfifo_push(EMPTY_PTR_FIFO(priv->id),
FIFO_PTR_FRAMENO(i) | FIFO_PTR_SEGMENT(priv->id));

return register_netdev(ndev);
ret = register_netdev(ndev);
if (inv_mac_addr)
printk("%s: Invalid ethernet MAC address. Please set using ip\n",
ndev->name);

return ret;
}

static int netx_eth_drv_probe(struct platform_device *pdev)
Expand Down

0 comments on commit 3274940

Please sign in to comment.