Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp6281463pxb; Thu, 27 Jan 2022 10:11:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1MHLJ+/Tj2N+UCkuEEDz7uDC90vFib6ib5xem1bKro0UJK8KaZpbkStb860ugrpSYFPAK X-Received: by 2002:a17:907:a088:: with SMTP id hu8mr3287964ejc.439.1643307114877; Thu, 27 Jan 2022 10:11:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643307114; cv=none; d=google.com; s=arc-20160816; b=E4PrL/vwPT9h5lkCAk5SmommQQXRQVAfSl/TJ3zkSoEo1zOllQd0uBCtGRGIBRw+uo thQSwNCtq60DImUYSHbhsp65kmLJ/N84NTMBh3A3FUCWTluvkV2n1aVnomBWaCZw8Kvs 5GcCMXj8shPruCmiVZ3H1jAFddDhItqj+MhoOuQmvdxJb4cWGc/jozPmmIYT7lkKe0c8 +IZn0bQyP7RLansbLhyYy0SAFw2gWe3DQfr52iaSBd1UESUkp4CIchY61MjkYQlIn2cv wnJ8xdbB8U7MUUCuKbGCyJK7xxhmMzWCbMmRllw1FVPWozR1Cd9j72EVr7qojIKL2HDb 8sTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BrNu+JKzTE5GjUaVhsDpYIHtowTrnTGaOpAvuIk/gKs=; b=lHbWRtY9n3RThkuUHJlAl6qbt9mBnoYs8A76J4vSECnO6IgVVDfbKctGHd8gFZ1QPP MfMiZw1SwIoUJwJtnZfbAjcLNr9ySB4oJrxwLMFlIYFObQHh5pNuRDJREZefMiYXnzaM shU27DP4kW6+mlNpywFEgG+3om8QUeFu7RNnETFoDol1Qw2wm5Xs9gZtA8OMRfYi8sak Byu/bQmvwZ5RfIWKNgprOzqcEr5FD3OKskD+r1BnspuOVdmgeN1gtMMC02PItnvcZNx6 THcRDaocHQIe1aYYur7it8BN52lc/heXVPLHsLo7TfyLM/RrtgjkF5hySTNo1ooAW8YT 0Vxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qw4si1532178ejc.115.2022.01.27.10.11.29; Thu, 27 Jan 2022 10:11:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239776AbiA0Kt3 (ORCPT + 99 others); Thu, 27 Jan 2022 05:49:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239294AbiA0KtQ (ORCPT ); Thu, 27 Jan 2022 05:49:16 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EFEFC061748 for ; Thu, 27 Jan 2022 02:49:16 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nD2Kz-0007ko-3G; Thu, 27 Jan 2022 11:49:09 +0100 Received: from ore by dude.hi.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1nD2Kx-003lzO-RJ; Thu, 27 Jan 2022 11:49:07 +0100 From: Oleksij Rempel To: Oliver Neukum , "David S. Miller" , Jakub Kicinski , Rob Herring Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH net-next v1 4/4] usbnet: add support for label from device tree Date: Thu, 27 Jan 2022 11:49:05 +0100 Message-Id: <20220127104905.899341-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220127104905.899341-1-o.rempel@pengutronix.de> References: <20220127104905.899341-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to the option to set a netdev name in device tree for switch ports by using the property "label" in the DSA framework, this patch adds this functionality to the usbnet infrastructure. This will help to name the interfaces properly throughout supported devices. This provides stable interface names which are useful especially in embedded use cases. Signed-off-by: Oleksij Rempel --- drivers/net/usb/usbnet.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 9a6450f796dc..3fdca0cfda88 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -33,6 +33,7 @@ #include #include #include +#include /*-------------------------------------------------------------------------*/ @@ -1762,6 +1763,20 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) if ((dev->driver_info->flags & FLAG_WWAN) != 0) strscpy(net->name, "wwan%d", sizeof(net->name)); + if (IS_ENABLED(CONFIG_OF)) { + const char *label = NULL; + + /* try reading label from device tree node */ + if (xdev->dev.of_node) + label = of_get_property(xdev->dev.of_node, + "label", NULL); + if (label) { + strscpy(net->name, label, sizeof(net->name)); + dev_info(&udev->dev, "netdev name from dt: %s\n", + net->name); + } + } + /* devices that cannot do ARP */ if ((dev->driver_info->flags & FLAG_NOARP) != 0) net->flags |= IFF_NOARP; -- 2.30.2