Skip to content

Commit 4f4e543

Browse files
esmilkuba-moo
authored andcommitted
net: usb: cdc_ncm: use new API for bh tasklet
This converts the driver to use the new tasklet API introduced in commit 12cc923 ("tasklet: Introduce new initialization API") It is unfortunate that we need to add a pointer to the driver context to get back to the usbnet device, but the space will be reclaimed once there are no more users of the old API left and we can remove the data value and flag from the tasklet struct. Signed-off-by: Emil Renner Berthing <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 32d1bbb commit 4f4e543

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

drivers/net/usb/cdc_ncm.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static bool prefer_mbim;
6161
module_param(prefer_mbim, bool, 0644);
6262
MODULE_PARM_DESC(prefer_mbim, "Prefer MBIM setting on dual NCM/MBIM functions");
6363

64-
static void cdc_ncm_txpath_bh(unsigned long param);
64+
static void cdc_ncm_txpath_bh(struct tasklet_struct *t);
6565
static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx);
6666
static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *hr_timer);
6767
static struct usb_driver cdc_ncm_driver;
@@ -813,9 +813,11 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
813813
if (!ctx)
814814
return -ENOMEM;
815815

816+
ctx->dev = dev;
817+
816818
hrtimer_init(&ctx->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
817819
ctx->tx_timer.function = &cdc_ncm_tx_timer_cb;
818-
tasklet_init(&ctx->bh, cdc_ncm_txpath_bh, (unsigned long)dev);
820+
tasklet_setup(&ctx->bh, cdc_ncm_txpath_bh);
819821
atomic_set(&ctx->stop, 0);
820822
spin_lock_init(&ctx->mtx);
821823

@@ -1472,10 +1474,10 @@ static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *timer)
14721474
return HRTIMER_NORESTART;
14731475
}
14741476

1475-
static void cdc_ncm_txpath_bh(unsigned long param)
1477+
static void cdc_ncm_txpath_bh(struct tasklet_struct *t)
14761478
{
1477-
struct usbnet *dev = (struct usbnet *)param;
1478-
struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
1479+
struct cdc_ncm_ctx *ctx = from_tasklet(ctx, t, bh);
1480+
struct usbnet *dev = ctx->dev;
14791481

14801482
spin_lock_bh(&ctx->mtx);
14811483
if (ctx->tx_timer_pending != 0) {

include/linux/usb/cdc_ncm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ struct cdc_ncm_ctx {
9898
struct hrtimer tx_timer;
9999
struct tasklet_struct bh;
100100

101+
struct usbnet *dev;
102+
101103
const struct usb_cdc_ncm_desc *func_desc;
102104
const struct usb_cdc_mbim_desc *mbim_desc;
103105
const struct usb_cdc_mbim_extended_desc *mbim_extended_desc;

0 commit comments

Comments
 (0)