From patchwork Thu Jul 17 14:09:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Veaceslav Falico X-Patchwork-Id: 371183 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 92BC4140080 for ; Fri, 18 Jul 2014 00:14:57 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933886AbaGQOOc (ORCPT ); Thu, 17 Jul 2014 10:14:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12033 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933823AbaGQOOP (ORCPT ); Thu, 17 Jul 2014 10:14:15 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6HEEBLf011073 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Jul 2014 10:14:11 -0400 Received: from darkmag.usersys.redhat.com (dhcp-27-102.brq.redhat.com [10.34.27.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6HEE6Z4018049; Thu, 17 Jul 2014 10:14:10 -0400 From: Veaceslav Falico To: netdev@vger.kernel.org Cc: Veaceslav Falico , "David S. Miller" , Tom Gundersen Subject: [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available Date: Thu, 17 Jul 2014 16:09:45 +0200 Message-Id: <1405606186-13703-2-git-send-email-vfalico@gmail.com> In-Reply-To: <1405606186-13703-1-git-send-email-vfalico@gmail.com> References: <1405606186-13703-1-git-send-email-vfalico@gmail.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org netdev_name() returns dev->name only when the net_device is in NETREG_REGISTERED state. However, dev->name is always populated on creation, so we can easily use it. There are two cases when there's no real name - when it's an empty string or when the name is in form of "eth%d", then netdev_name() returns "unnamed net_device". CC: "David S. Miller" CC: Tom Gundersen Signed-off-by: Veaceslav Falico --- Notes: v1->v2: Also account for an empty string, as Tom Gundersen suggested. include/linux/netdevice.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 15ed750..70256aa 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3383,8 +3383,8 @@ extern struct pernet_operations __net_initdata loopback_net_ops; static inline const char *netdev_name(const struct net_device *dev) { - if (dev->reg_state != NETREG_REGISTERED) - return "(unregistered net_device)"; + if (!dev->name[0] || strchr(dev->name, '%')) + return "(unnamed net_device)"; return dev->name; }