From patchwork Wed Jul 15 15:56:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Wxcaf=C3=A9?= X-Patchwork-Id: 11665859 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D95D1392 for ; Wed, 15 Jul 2020 15:56:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40A16206D5 for ; Wed, 15 Jul 2020 15:56:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbgGOP4X (ORCPT ); Wed, 15 Jul 2020 11:56:23 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:61791 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725798AbgGOP4X (ORCPT ); Wed, 15 Jul 2020 11:56:23 -0400 Received: from cwh (fob.gandi.net [217.70.181.1]) (Authenticated sender: wxcafe@wxcafe.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 54A594000A; Wed, 15 Jul 2020 15:56:20 +0000 (UTC) Message-ID: Subject: [PATCH 3/4] cdc_ncm: replace the way cdc_ncm hooks into From: =?iso-8859-1?q?Wxcaf=E9?= To: linux-usb@vger.kernel.org Cc: Miguel =?iso-8859-1?q?Rodr=EDguez_P=E9rez?= , oliver@neukum.org, netdev@vger.kernel.org Date: Wed, 15 Jul 2020 11:56:15 -0400 User-Agent: Evolution 3.36.3 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From 352445fcbac243b8f10e1840726d67b41a45853d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel Rodr=C3=ADguez P=C3=A9rez? Date: Tue, 14 Jul 2020 18:10:34 -0400 Subject: [PATCH 3/4] cdc_ncm: replace the way cdc_ncm hooks into usbnet_change_mtu Previously cdc_ncm overwrited netdev_ops used by usbnet thus preventing hooking into set_rx_mode. This patch preserves usbnet hooks into netdev_ops, and add an additional one for change_mtu needed by cdc_ncm. Signed-off-by: Miguel Rodríguez Pérez Signed-off-by: Wxcafé --- drivers/net/usb/cdc_ncm.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 8929669b5e6d..2abaf5f8b23b 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -787,16 +787,7 @@ int cdc_ncm_change_mtu(struct net_device *net, int new_mtu) } EXPORT_SYMBOL_GPL(cdc_ncm_change_mtu); -static const struct net_device_ops cdc_ncm_netdev_ops = { - .ndo_open = usbnet_open, - .ndo_stop = usbnet_stop, - .ndo_start_xmit = usbnet_start_xmit, - .ndo_tx_timeout = usbnet_tx_timeout, - .ndo_get_stats64 = usbnet_get_stats64, - .ndo_change_mtu = cdc_ncm_change_mtu, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, -}; +static struct net_device_ops cdc_ncm_netdev_ops; int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting, int drvflags) { @@ -953,6 +944,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ dev->net->sysfs_groups[0] = &cdc_ncm_sysfs_attr_group; /* must handle MTU changes */ + cdc_ncm_netdev_ops = *dev->net->netdev_ops; + cdc_ncm_netdev_ops.ndo_change_mtu = cdc_ncm_change_mtu; dev->net->netdev_ops = &cdc_ncm_netdev_ops; dev->net->max_mtu = cdc_ncm_max_dgram_size(dev) - cdc_ncm_eth_hlen(dev);