Re: [PATCH net] drivers: net: Don't print unpopulated net_device name

From: Stephen Hemminger
Date: Tue May 10 2016 - 14:31:39 EST


On Tue, 10 May 2016 17:43:21 +0100
Harvey Hunt <harvey.hunt@xxxxxxxxxx> wrote:

> 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.
>
> Cc: Robert Jarzmik <robert.jarzmik@xxxxxxx>
> Cc: Barry Song <Baohua.Song@xxxxxxx>
> Cc: Marcel Ziswiler <marcel@xxxxxxxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
>
> Signed-off-by: Harvey Hunt <harvey.hunt@xxxxxxxxxx>
> ---
> I've tested this patch on a board that has a DM9000, but haven't
> tested the other two network devices.
>
> drivers/net/ethernet/davicom/dm9000.c | 3 +--
> drivers/net/ethernet/micrel/ks8695net.c | 3 +--
> drivers/net/ethernet/netx-eth.c | 3 +--
> 3 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
> index 48d9194..89dcaa1 100644
> --- a/drivers/net/ethernet/davicom/dm9000.c
> +++ b/drivers/net/ethernet/davicom/dm9000.c
> @@ -1686,8 +1686,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);
> + dev_warn(db->dev, "Invalid ethernet MAC address. Please set using ifconfig\n");

ifconfig is deprecated, therefore please don't tell users to use it.