Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp493008imm; Fri, 12 Oct 2018 01:35:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV61vUDQJA5YVe+mVRlqdpZZTbxlrtYADh/9zGHvoPGMSw7sUy6Gv7IlZMARscIv1aG1kne8Q X-Received: by 2002:a62:5982:: with SMTP id k2-v6mr5016816pfj.180.1539333303191; Fri, 12 Oct 2018 01:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539333303; cv=none; d=google.com; s=arc-20160816; b=mEcNjNaWZsEvrkw7WaeW4hSzyGCbq32dCh/ibodE/j+FlcS/4b2mHf5fqDxnHsLrSf 2r0H/HTcueUQVkPRjSs3yWG1BXrHAsmkAgraoAKdV6zWqLsTpKKeO/eJe1NJegtBPvEu X553jgfLBPKGi5ThlEhy4wQadcreMSeLljaaCqJWb+d0BAWMLXXzW1mX08dJHhcIBtAI fh/KyRnRBRcDW3mLSx2uKzCKOdoYRAhlEfx9Z+Ds5ju7b3YDoO27fucuamgeWUGNWLkK cBx81G10uAoi2sa/SmPbd3r80ROfbCUvH97Ej4zMr246di+/VFsjtis55xG6AhOv6MXj K9cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=my5t8LxsshVHXB8VmYxGyb6FW+g0TxTUuzgK/V0GNT8=; b=t4FnjIqrxFX2zEXdGn0vpiAMw+tacGKiAcWVkatyLJeh9y12RrRlV9Vm6S481NiZqX uPF4NAxhRa6illKMoWn90HyjOs945sU8UHgvDTYkfGgqf+neYkjZdPPocHhDmMBa59bt Ds+bVsyoDYYCQuNvoNneu1sip7KnQhQYSsg0Cpw5EFXhI7NLVexhVAUsBklN9Fm5vhiE bNv8UPjDbfgTjqhmcpVHNd55GOtSrkEM4fUl1h7HyR9j64Z4KJA5n0BXMDGIZr/SpzBc XlqLk9rWRQKeKyBZHKwpYuBikGQaercqe2WXBfcaUXzigphGiT03fnBzjZfIx/BSC38m uy5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g16-v6si549735pgd.354.2018.10.12.01.34.48; Fri, 12 Oct 2018 01:35:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728053AbeJLQFf (ORCPT + 99 others); Fri, 12 Oct 2018 12:05:35 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:48208 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727826AbeJLQFe (ORCPT ); Fri, 12 Oct 2018 12:05:34 -0400 Received: from [148.252.241.226] (helo=rainbowdash) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1gAstc-0005Td-U9; Fri, 12 Oct 2018 09:34:09 +0100 Received: from ben by rainbowdash with local (Exim 4.91) (envelope-from ) id 1gAstc-00052n-AO; Fri, 12 Oct 2018 09:34:08 +0100 From: Ben Dooks To: netdev@vger.kernel.org Cc: oneukum@suse.com, davem@davemloft.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel@lists.codethink.co.uk, Ben Dooks Subject: [PATCH 7/8] usbnet: smsc95xx: add usbnet -> priv function Date: Fri, 12 Oct 2018 09:34:04 +0100 Message-Id: <20181012083405.19246-8-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181012083405.19246-1-ben.dooks@codethink.co.uk> References: <20181012083405.19246-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are a number of places in the smsc95xx driver where it gets the private-data from the usbnet passed in. It would be sensible to have one inline function to convert it and change all points in the driver to use that. Signed-off-by: Ben Dooks --- drivers/net/usb/smsc95xx.c | 47 +++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 03c3c02b569c..1eb0795ec90f 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -78,6 +78,11 @@ struct smsc95xx_priv { struct usbnet *dev; }; +static inline struct smsc95xx_priv *usbnet_to_smsc(struct usbnet *dev) +{ + return (struct smsc95xx_priv *)dev->data[0]; +} + static bool turbo_mode = IS_ENABLED(CONFIG_USB_NET_SMSC95XX_TURBO); module_param(turbo_mode, bool, 0644); MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); @@ -467,7 +472,7 @@ static unsigned int smsc95xx_hash(char addr[ETH_ALEN]) static void smsc95xx_set_multicast(struct net_device *netdev) { struct usbnet *dev = netdev_priv(netdev); - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); unsigned long flags; int ret; @@ -562,7 +567,7 @@ static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex, static int smsc95xx_link_reset(struct usbnet *dev) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); struct mii_if_info *mii = &dev->mii; struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; unsigned long flags; @@ -630,7 +635,7 @@ static void smsc95xx_status(struct usbnet *dev, struct urb *urb) static void set_carrier(struct usbnet *dev, bool link) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); if (pdata->link_ok == link) return; @@ -759,7 +764,7 @@ static void smsc95xx_ethtool_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) { struct usbnet *dev = netdev_priv(net); - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); wolinfo->supported = SUPPORTED_WAKE; wolinfo->wolopts = pdata->wolopts; @@ -769,7 +774,7 @@ static int smsc95xx_ethtool_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) { struct usbnet *dev = netdev_priv(net); - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); int ret; pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; @@ -805,7 +810,7 @@ static int get_mdix_status(struct net_device *net) static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl) { struct usbnet *dev = netdev_priv(net); - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); int buf; if ((pdata->chip_id == ID_REV_CHIP_ID_9500A_) || @@ -854,7 +859,7 @@ static int smsc95xx_get_link_ksettings(struct net_device *net, struct ethtool_link_ksettings *cmd) { struct usbnet *dev = netdev_priv(net); - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); int retval; retval = usbnet_get_link_ksettings(net, cmd); @@ -869,7 +874,7 @@ static int smsc95xx_set_link_ksettings(struct net_device *net, const struct ethtool_link_ksettings *cmd) { struct usbnet *dev = netdev_priv(net); - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); int retval; if (pdata->mdix_ctrl != cmd->base.eth_tp_mdix_ctrl) @@ -951,7 +956,7 @@ static int smsc95xx_set_mac_address(struct usbnet *dev) /* starts the TX path */ static int smsc95xx_start_tx_path(struct usbnet *dev) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); unsigned long flags; int ret; @@ -971,7 +976,7 @@ static int smsc95xx_start_tx_path(struct usbnet *dev) /* Starts the Receive path */ static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); unsigned long flags; spin_lock_irqsave(&pdata->mac_cr_lock, flags); @@ -1028,7 +1033,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev) static int smsc95xx_reset(struct usbnet *dev) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); u32 read_buf, write_buf, burst_cap; int ret = 0, timeout; @@ -1271,7 +1276,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc95xx_priv), GFP_KERNEL); - pdata = (struct smsc95xx_priv *)(dev->data[0]); + pdata = usbnet_to_smsc(dev); if (!pdata) return -ENOMEM; @@ -1328,7 +1333,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); if (pdata) { cancel_delayed_work(&pdata->carrier_check); @@ -1388,7 +1393,7 @@ static int smsc95xx_link_ok_nopm(struct usbnet *dev) static int smsc95xx_enter_suspend0(struct usbnet *dev) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); u32 val; int ret; @@ -1427,7 +1432,7 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev) static int smsc95xx_enter_suspend1(struct usbnet *dev) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); struct mii_if_info *mii = &dev->mii; u32 val; int ret; @@ -1475,7 +1480,7 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) static int smsc95xx_enter_suspend2(struct usbnet *dev) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); u32 val; int ret; @@ -1497,7 +1502,7 @@ static int smsc95xx_enter_suspend2(struct usbnet *dev) static int smsc95xx_enter_suspend3(struct usbnet *dev) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); u32 val; int ret; @@ -1536,7 +1541,7 @@ static int smsc95xx_enter_suspend3(struct usbnet *dev) static int smsc95xx_autosuspend(struct usbnet *dev, u32 link_up) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); int ret; if (!netif_running(dev->net)) { @@ -1584,7 +1589,7 @@ static int smsc95xx_autosuspend(struct usbnet *dev, u32 link_up) static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) { struct usbnet *dev = usb_get_intfdata(intf); - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); u32 val, link_up; int ret; @@ -1848,7 +1853,7 @@ static int smsc95xx_resume(struct usb_interface *intf) u32 val; BUG_ON(!dev); - pdata = (struct smsc95xx_priv *)(dev->data[0]); + pdata = usbnet_to_smsc(dev); suspend_flags = pdata->suspend_flags; netdev_dbg(dev->net, "resume suspend_flags=0x%02x\n", suspend_flags); @@ -2084,7 +2089,7 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, static int smsc95xx_manage_power(struct usbnet *dev, int on) { - struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); + struct smsc95xx_priv *pdata = usbnet_to_smsc(dev); dev->intf->needs_remote_wakeup = on; -- 2.19.1