]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: usb: ax88179_178a: move priv to driver_priv
authorJustin Chen <justinpopo6@gmail.com>
Thu, 21 Jul 2022 00:28:15 +0000 (17:28 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Jan 2024 17:51:27 +0000 (18:51 +0100)
commit 2bcbd3d8a7b4525cdb741fe82330edb6f5452c7f upstream.

We need more space to save WoL context. So lets allocate memory
for ax88179_data instead of using struct usbnet data field which
only supports 5 words. We continue to use the struct usbnet data
field for multicast filters. However since we no longer have the
private data stored there, we can shift it to the beginning.

Signed-off-by: Justin Chen <justinpopo6@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Cc: Jeffery Miller <jefferymiller@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/usb/ax88179_178a.c

index e41949b0c372bed87cbeccca30fb99b8b83bb946..f11748cc5b22831b03159665a96736000aef0597 100644 (file)
@@ -170,7 +170,6 @@ struct ax88179_data {
        u8  eee_enabled;
        u8  eee_active;
        u16 rxctl;
-       u16 reserved;
        u8 in_pm;
        u32 wol_supported;
        u32 wolopts;
@@ -193,14 +192,14 @@ static const struct {
 
 static void ax88179_set_pm_mode(struct usbnet *dev, bool pm_mode)
 {
-       struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data;
+       struct ax88179_data *ax179_data = dev->driver_priv;
 
        ax179_data->in_pm = pm_mode;
 }
 
 static int ax88179_in_pm(struct usbnet *dev)
 {
-       struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data;
+       struct ax88179_data *ax179_data = dev->driver_priv;
 
        return ax179_data->in_pm;
 }
@@ -733,7 +732,7 @@ ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_eee *data)
 static int ax88179_chk_eee(struct usbnet *dev)
 {
        struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
-       struct ax88179_data *priv = (struct ax88179_data *)dev->data;
+       struct ax88179_data *priv = dev->driver_priv;
 
        mii_ethtool_gset(&dev->mii, &ecmd);
 
@@ -836,7 +835,7 @@ static void ax88179_enable_eee(struct usbnet *dev)
 static int ax88179_get_eee(struct net_device *net, struct ethtool_eee *edata)
 {
        struct usbnet *dev = netdev_priv(net);
-       struct ax88179_data *priv = (struct ax88179_data *)dev->data;
+       struct ax88179_data *priv = dev->driver_priv;
 
        edata->eee_enabled = priv->eee_enabled;
        edata->eee_active = priv->eee_active;
@@ -847,7 +846,7 @@ static int ax88179_get_eee(struct net_device *net, struct ethtool_eee *edata)
 static int ax88179_set_eee(struct net_device *net, struct ethtool_eee *edata)
 {
        struct usbnet *dev = netdev_priv(net);
-       struct ax88179_data *priv = (struct ax88179_data *)dev->data;
+       struct ax88179_data *priv = dev->driver_priv;
        int ret;
 
        priv->eee_enabled = edata->eee_enabled;
@@ -898,8 +897,8 @@ static const struct ethtool_ops ax88179_ethtool_ops = {
 static void ax88179_set_multicast(struct net_device *net)
 {
        struct usbnet *dev = netdev_priv(net);
-       struct ax88179_data *data = (struct ax88179_data *)dev->data;
-       u8 *m_filter = ((u8 *)dev->data) + 12;
+       struct ax88179_data *data = dev->driver_priv;
+       u8 *m_filter = ((u8 *)dev->data);
 
        data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE);
 
@@ -911,7 +910,7 @@ static void ax88179_set_multicast(struct net_device *net)
        } else if (netdev_mc_empty(net)) {
                /* just broadcast and directed */
        } else {
-               /* We use the 20 byte dev->data for our 8 byte filter buffer
+               /* We use dev->data for our 8 byte filter buffer
                 * to avoid allocating memory that is tricky to free later
                 */
                u32 crc_bits;
@@ -1310,11 +1309,15 @@ static void ax88179_get_mac_addr(struct usbnet *dev)
 
 static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
 {
-       struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data;
+       struct ax88179_data *ax179_data;
 
        usbnet_get_endpoints(dev, intf);
 
-       memset(ax179_data, 0, sizeof(*ax179_data));
+       ax179_data = kzalloc(sizeof(*ax179_data), GFP_KERNEL);
+       if (!ax179_data)
+               return -ENOMEM;
+
+       dev->driver_priv = ax179_data;
 
        dev->net->netdev_ops = &ax88179_netdev_ops;
        dev->net->ethtool_ops = &ax88179_ethtool_ops;
@@ -1343,6 +1346,7 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
+       struct ax88179_data *ax179_data = dev->driver_priv;
        u16 tmp16;
 
        /* Configure RX control register => stop operation */
@@ -1355,6 +1359,8 @@ static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf)
        /* Power down ethernet PHY */
        tmp16 = 0;
        ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16);
+
+       kfree(ax179_data);
 }
 
 static void
@@ -1527,7 +1533,7 @@ ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
 
 static int ax88179_link_reset(struct usbnet *dev)
 {
-       struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data;
+       struct ax88179_data *ax179_data = dev->driver_priv;
        u8 tmp[5], link_sts;
        u16 mode, tmp16, delay = HZ / 10;
        u32 tmp32 = 0x40000000;
@@ -1602,7 +1608,7 @@ static int ax88179_reset(struct usbnet *dev)
        u8 buf[5];
        u16 *tmp16;
        u8 *tmp;
-       struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data;
+       struct ax88179_data *ax179_data = dev->driver_priv;
        struct ethtool_eee eee_data;
 
        tmp16 = (u16 *)buf;