@@ -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;
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(-)