From: Jose Alonso <joalonsof@gmail.com>
To: justinpopo6@gmail.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, linux-usb@vger.kernel.org,
jannh@google.com, jackychou@asix.com.tw,
jesionowskigreg@gmail.com, pabeni@redhat.com, kuba@kernel.org,
edumazet@google.com, davem@davemloft.net, f.fainelli@gmail.com
Cc: justin.chen@broadcom.com
Subject: Re: [PATCH 4/5] net: usb: ax88179_178a: move priv to driver_priv
Date: Tue, 19 Jul 2022 14:38:16 -0300 [thread overview]
Message-ID: <82e4bfdb91b91ea52286bae11ca458bfc1c23d17.camel@gmail.com> (raw)
In-Reply-To: <1658188689-30846-5-git-send-email-justinpopo6@gmail.com>
On Mon, 2022-07-18 at 16:58 -0700, justinpopo6@gmail.com wrote:
> From: Justin Chen <justinpopo6@gmail.com>
>
> 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>
> ---
> drivers/net/usb/ax88179_178a.c | 31 +++++++++++++++++++------------
> 1 file changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
> index 60742bb..cb7b89f 100644
> --- a/drivers/net/usb/ax88179_178a.c
> +++ b/drivers/net/usb/ax88179_178a.c
> @@ -170,7 +170,6 @@ struct ax88179_data {
> u8 eee_enabled;
> u8 eee_active;
> u16 rxctl;
> - u16 reserved;
> u8 in_pm;
> };
>
> @@ -190,14 +189,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;
> }
> @@ -693,7 +692,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);
>
> @@ -796,7 +795,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;
> @@ -807,7 +806,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;
> @@ -858,8 +857,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);
>
> @@ -871,7 +870,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;
> @@ -1273,10 +1272,15 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
> u8 buf[5];
> u16 *tmp16;
> u8 *tmp;
> - struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data;
> + struct ax88179_data *ax179_data;
>
> usbnet_get_endpoints(dev, intf);
>
> + ax179_data = kzalloc(sizeof(*ax179_data), GFP_KERNEL);
> + if (!ax179_data)
> + return -ENOMEM;
> +
> + dev->driver_priv = ax179_data;
> tmp16 = (u16 *)buf;
> tmp = (u8 *)buf;
following this line there is an unnecessary:
memset(ax179_data, 0, sizeof(*ax179_data));
>
> @@ -1310,6 +1314,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 */
> @@ -1322,6 +1327,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
> @@ -1498,7 +1505,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;
> @@ -1573,7 +1580,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;
--
Jose Alonso
next prev parent reply other threads:[~2022-07-19 17:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 23:58 [PATCH 0/5] net: usb: ax88179_178a: improvements and bug fixes justinpopo6
2022-07-18 23:58 ` [PATCH 1/5] net: usb: ax88179_178a: remove redundant init code justinpopo6
2022-07-19 20:41 ` Jakub Kicinski
2022-07-18 23:58 ` [PATCH 2/5] net: usb: ax88179_178a: clean up pm calls justinpopo6
2022-07-18 23:58 ` [PATCH 3/5] net: usb: ax88179_178a: restore state on resume justinpopo6
2022-07-18 23:58 ` [PATCH 4/5] net: usb: ax88179_178a: move priv to driver_priv justinpopo6
2022-07-19 17:38 ` Jose Alonso [this message]
2022-07-18 23:58 ` [PATCH 5/5] net: usb: ax88179_178a: wol optimizations justinpopo6
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=82e4bfdb91b91ea52286bae11ca458bfc1c23d17.camel@gmail.com \
--to=joalonsof@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=jackychou@asix.com.tw \
--cc=jannh@google.com \
--cc=jesionowskigreg@gmail.com \
--cc=justin.chen@broadcom.com \
--cc=justinpopo6@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.