From: Oliver Neukum <oneukum@suse.com>
To: andrew@lunn.ch, bjorn@mork.no, netdev@vger.kernel.org
Cc: Oliver Neukum <oneukum@suse.com>
Subject: [RFCv3 10/13] net: usb: sierra_net: use dynamic private allocation
Date: Mon, 9 Mar 2026 17:53:33 +0100 [thread overview]
Message-ID: <20260309165614.861929-10-oneukum@suse.com> (raw)
In-Reply-To: <20260309165614.861929-1-oneukum@suse.com>
The old style private room was too small for sierra_net.
With dynamic allocation that factor is gone.
Remove handling private allocations in the driver.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/net/usb/sierra_net.c | 42 +++++++++++-------------------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 5a32796a7a89..9a721413bdf4 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -187,19 +187,6 @@ static const struct net_device_ops sierra_net_device_ops = {
.ndo_validate_addr = eth_validate_addr,
};
-/* get private data associated with passed in usbnet device */
-static inline struct sierra_net_data *sierra_net_get_private(struct usbnet *dev)
-{
- return (struct sierra_net_data *)dev->data[0];
-}
-
-/* set private data associated with passed in usbnet device */
-static inline void sierra_net_set_private(struct usbnet *dev,
- struct sierra_net_data *priv)
-{
- dev->data[0] = (unsigned long)priv;
-}
-
/* is packet IPv4/IPv6 */
static inline int is_ip(struct sk_buff *skb)
{
@@ -317,7 +304,7 @@ static void build_hip(u8 *buf, const u16 payloadlen,
static int sierra_net_send_cmd(struct usbnet *dev,
u8 *cmd, int cmdlen, const char * cmd_name)
{
- struct sierra_net_data *priv = sierra_net_get_private(dev);
+ struct sierra_net_data *priv = usbnet_priv(dev);
int status;
status = usbnet_write_cmd(dev, USB_CDC_SEND_ENCAPSULATED_COMMAND,
@@ -333,7 +320,7 @@ static int sierra_net_send_cmd(struct usbnet *dev,
static int sierra_net_send_sync(struct usbnet *dev)
{
int status;
- struct sierra_net_data *priv = sierra_net_get_private(dev);
+ struct sierra_net_data *priv = usbnet_priv(dev);
dev_dbg(&dev->udev->dev, "%s", __func__);
@@ -410,7 +397,7 @@ static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen)
static void sierra_net_handle_lsi(struct usbnet *dev, char *data,
struct hip_hdr *hh)
{
- struct sierra_net_data *priv = sierra_net_get_private(dev);
+ struct sierra_net_data *priv = usbnet_priv(dev);
int link_up;
link_up = sierra_net_parse_lsi(dev, data + hh->hdrlen,
@@ -431,7 +418,7 @@ static void sierra_net_handle_lsi(struct usbnet *dev, char *data,
static void sierra_net_dosync(struct usbnet *dev)
{
int status;
- struct sierra_net_data *priv = sierra_net_get_private(dev);
+ struct sierra_net_data *priv = usbnet_priv(dev);
dev_dbg(&dev->udev->dev, "%s", __func__);
@@ -560,7 +547,7 @@ static void sierra_net_kevent(struct work_struct *work)
static void sierra_net_defer_kevent(struct usbnet *dev, int work)
{
- struct sierra_net_data *priv = sierra_net_get_private(dev);
+ struct sierra_net_data *priv = usbnet_priv(dev);
set_bit(work, &priv->kevent_flags);
schedule_work(&priv->sierra_net_kevent);
@@ -608,8 +595,10 @@ static void sierra_net_status(struct usbnet *dev, struct urb *urb)
static u32 sierra_net_get_link(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
+ struct sierra_net_data *priv = usbnet_priv(dev);
+
/* Report link is down whenever the interface is down */
- return sierra_net_get_private(dev)->link_up && netif_running(net);
+ return priv->link_up && netif_running(net);
}
static const struct ethtool_ops sierra_net_ethtool_ops = {
@@ -653,7 +642,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
u8 numendpoints;
u16 fwattr = 0;
int status;
- struct sierra_net_data *priv;
+ struct sierra_net_data *priv = usbnet_priv(dev);
static const u8 sync_tmplate[sizeof(priv->sync_msg)] = {
0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00};
static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = {
@@ -682,11 +671,8 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
dev_err(&dev->udev->dev, "No status endpoint found");
return -ENODEV;
}
- /* Initialize sierra private data */
- priv = kzalloc_obj(*priv);
- if (!priv)
- return -ENOMEM;
+ /* Initialize sierra private data */
priv->usbnet = dev;
priv->ifnum = ifacenum;
dev->net->netdev_ops = &sierra_net_device_ops;
@@ -718,8 +704,6 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
dev->net->ethtool_ops = &sierra_net_ethtool_ops;
netif_carrier_off(dev->net);
- sierra_net_set_private(dev, priv);
-
priv->kevent_flags = 0;
/* Use the shared workqueue */
@@ -747,7 +731,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
static void sierra_net_unbind(struct usbnet *dev, struct usb_interface *intf)
{
int status;
- struct sierra_net_data *priv = sierra_net_get_private(dev);
+ struct sierra_net_data *priv = usbnet_priv(dev);
dev_dbg(&dev->udev->dev, "%s", __func__);
@@ -764,7 +748,6 @@ static void sierra_net_unbind(struct usbnet *dev, struct usb_interface *intf)
usbnet_status_stop(dev);
- sierra_net_set_private(dev, NULL);
kfree(priv);
}
@@ -851,7 +834,7 @@ static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
static struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev,
struct sk_buff *skb, gfp_t flags)
{
- struct sierra_net_data *priv = sierra_net_get_private(dev);
+ struct sierra_net_data *priv = usbnet_priv(dev);
u16 len;
bool need_tail;
@@ -905,6 +888,7 @@ static const struct driver_info sierra_net_info_direct_ip = {
.status = sierra_net_status,
.rx_fixup = sierra_net_rx_fixup,
.tx_fixup = sierra_net_tx_fixup,
+ .required_room = sizeof(struct sierra_net_data),
};
static int
--
2.53.0
next prev parent reply other threads:[~2026-03-09 16:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 16:53 [RFCv3 01/13] net: usb: usbnet: use proper ep number macros Oliver Neukum
2026-03-09 16:53 ` [RFCv3 02/13] net: usb: move updating filter and status from cdc to usbnet Oliver Neukum
2026-03-09 16:53 ` [RFCv3 03/13] net: usb: centralize usbnet_cdc_zte_rx_fixup in usbnet Oliver Neukum
2026-03-09 16:53 ` [RFCv4 04/13] net: usb: usbnet: add access helper for private data Oliver Neukum
2026-03-09 16:53 ` [RFCv5 05/13] net: usb: use accessor helper for usbnet " Oliver Neukum
2026-03-09 17:46 ` Bjørn Mork
2026-03-10 13:00 ` Oliver Neukum
2026-03-10 13:23 ` Bjørn Mork
2026-03-09 16:53 ` [RFCv3 06/13] net: usb: usbnet: add cdc_state to struct usbnet Oliver Neukum
2026-03-09 16:53 ` [RFCv3 07/13] net: usb: use cdc_state in " Oliver Neukum
2026-03-09 16:53 ` [RFCv3 08/13] net: usb: usbnet: allow drivers to specify private space needed Oliver Neukum
2026-03-09 16:53 ` [RFCv3 09/13] net: usb: use allocation on demand for usbnet Oliver Neukum
2026-03-09 16:53 ` Oliver Neukum [this message]
2026-03-09 16:53 ` [RFCv3 11/13] net: usb: cdc_ncm: use dynamic private allocation Oliver Neukum
2026-03-09 16:53 ` [RFCv3 12/13] net: usb: smsc95xx: " Oliver Neukum
2026-03-09 16:53 ` [RFCv3 13/13] net: usb: lg-vl600: " 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=20260309165614.861929-10-oneukum@suse.com \
--to=oneukum@suse.com \
--cc=andrew@lunn.ch \
--cc=bjorn@mork.no \
--cc=netdev@vger.kernel.org \
/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