linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kernel@lists.codethink.co.uk, gregkh@linuxfoundation.org,
	bjorn@mork.no, steve.glendinning@shawell.net,
	Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH 1/7] net: smsc75xx: add usbnet -> priv function
Date: Fri, 12 Oct 2018 10:16:36 +0100	[thread overview]
Message-ID: <20181012091642.21294-2-ben.dooks@codethink.co.uk> (raw)
In-Reply-To: <20181012091642.21294-1-ben.dooks@codethink.co.uk>

There are a number of places in the smsc75xx 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 <ben.dooks@codethink.co.uk>
---
 drivers/net/usb/smsc75xx.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 05553d252446..6d12fcd9b4b0 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -73,6 +73,11 @@ struct smsc75xx_priv {
 	u8 suspend_flags;
 };
 
+static inline struct smsc75xx_priv *usbnet_to_smsc(struct usbnet *dev)
+{
+	return (struct smsc75xx_priv *)dev->data[0];
+}
+
 struct usb_context {
 	struct usb_ctrlrequest req;
 	struct usbnet *dev;
@@ -469,7 +474,7 @@ static int smsc75xx_dataport_wait_not_busy(struct usbnet *dev)
 static int smsc75xx_dataport_write(struct usbnet *dev, u32 ram_select, u32 addr,
 				   u32 length, u32 *buf)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	u32 dp_sel;
 	int i, ret;
 
@@ -553,7 +558,7 @@ static void smsc75xx_deferred_multicast_write(struct work_struct *param)
 static void smsc75xx_set_multicast(struct net_device *netdev)
 {
 	struct usbnet *dev = netdev_priv(netdev);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	unsigned long flags;
 	int i;
 
@@ -718,7 +723,7 @@ static void smsc75xx_ethtool_get_wol(struct net_device *net,
 				     struct ethtool_wolinfo *wolinfo)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 
 	wolinfo->supported = SUPPORTED_WAKE;
 	wolinfo->wolopts = pdata->wolopts;
@@ -728,7 +733,7 @@ static int smsc75xx_ethtool_set_wol(struct net_device *net,
 				    struct ethtool_wolinfo *wolinfo)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	int ret;
 
 	pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
@@ -945,7 +950,7 @@ static int smsc75xx_set_features(struct net_device *netdev,
 	netdev_features_t features)
 {
 	struct usbnet *dev = netdev_priv(netdev);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	unsigned long flags;
 	int ret;
 
@@ -1051,7 +1056,7 @@ static int smsc75xx_phy_gig_workaround(struct usbnet *dev)
 
 static int smsc75xx_reset(struct usbnet *dev)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	u32 buf;
 	int ret = 0, timeout;
 
@@ -1515,7 +1520,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	if (pdata) {
 		netif_dbg(dev, ifdown, dev->net, "free pdata\n");
 		kfree(pdata);
@@ -1571,7 +1576,7 @@ static int smsc75xx_write_wuff(struct usbnet *dev, int filter, u32 wuf_cfg,
 
 static int smsc75xx_enter_suspend0(struct usbnet *dev)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	u32 val;
 	int ret;
 
@@ -1597,7 +1602,7 @@ static int smsc75xx_enter_suspend0(struct usbnet *dev)
 
 static int smsc75xx_enter_suspend1(struct usbnet *dev)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	u32 val;
 	int ret;
 
@@ -1633,7 +1638,7 @@ static int smsc75xx_enter_suspend1(struct usbnet *dev)
 
 static int smsc75xx_enter_suspend2(struct usbnet *dev)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	u32 val;
 	int ret;
 
@@ -1659,7 +1664,7 @@ static int smsc75xx_enter_suspend2(struct usbnet *dev)
 
 static int smsc75xx_enter_suspend3(struct usbnet *dev)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	u32 val;
 	int ret;
 
@@ -1794,7 +1799,7 @@ static int smsc75xx_autosuspend(struct usbnet *dev, u32 link_up)
 static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
 {
 	struct usbnet *dev = usb_get_intfdata(intf);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	u32 val, link_up;
 	int ret;
 
@@ -2095,7 +2100,7 @@ static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
 static int smsc75xx_resume(struct usb_interface *intf)
 {
 	struct usbnet *dev = usb_get_intfdata(intf);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = usbnet_to_smsc(dev);
 	u8 suspend_flags = pdata->suspend_flags;
 	int ret;
 	u32 val;
-- 
2.19.1


  reply	other threads:[~2018-10-12  9:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12  9:16 usbnet private-data accessor functions Ben Dooks
2018-10-12  9:16 ` Ben Dooks [this message]
2018-10-12 10:19   ` [PATCH 1/7] net: smsc75xx: add usbnet -> priv function Greg KH
2018-10-12  9:16 ` [PATCH 2/7] net: asix: " Ben Dooks
2018-10-12 10:20   ` Greg KH
2018-10-12  9:16 ` [PATCH 3/7] net: usb: asix88179_178a: " Ben Dooks
2018-10-12 10:20   ` Greg KH
2018-10-12  9:16 ` [PATCH 4/7] net: qmi_wwan: " Ben Dooks
2018-10-12 10:20   ` Greg KH
2018-10-12 10:44   ` Bjørn Mork
2018-10-12 13:22     ` Ben Dooks
2018-10-12  9:16 ` [PATCH 5/7] net: cdc_ether: " Ben Dooks
2018-10-12 10:20   ` Greg KH
2018-10-12  9:16 ` [PATCH 6/7] net: huawei_cdc_ncm: " Ben Dooks
2018-10-12 10:20   ` Greg KH
2018-10-12  9:16 ` [PATCH 7/7] net: usb: sr9800: " Ben Dooks
2018-10-12 10:20   ` Greg KH
2018-10-12 15:38 ` usbnet private-data accessor functions Oliver Neukum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181012091642.21294-2-ben.dooks@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=bjorn@mork.no \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@lists.codethink.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=steve.glendinning@shawell.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).