Commit 4f4e5436 authored by Emil Renner Berthing's avatar Emil Renner Berthing Committed by Jakub Kicinski

net: usb: cdc_ncm: use new API for bh tasklet

This converts the driver to use the new tasklet API introduced in
commit 12cc923f ("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: default avatarEmil Renner Berthing <kernel@esmil.dk>
Link: https://lore.kernel.org/r/20210130234637.26505-1-kernel@esmil.dkSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 32d1bbb1
...@@ -61,7 +61,7 @@ static bool prefer_mbim; ...@@ -61,7 +61,7 @@ static bool prefer_mbim;
module_param(prefer_mbim, bool, 0644); module_param(prefer_mbim, bool, 0644);
MODULE_PARM_DESC(prefer_mbim, "Prefer MBIM setting on dual NCM/MBIM functions"); MODULE_PARM_DESC(prefer_mbim, "Prefer MBIM setting on dual NCM/MBIM functions");
static void cdc_ncm_txpath_bh(unsigned long param); static void cdc_ncm_txpath_bh(struct tasklet_struct *t);
static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx); static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx);
static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *hr_timer); static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *hr_timer);
static struct usb_driver cdc_ncm_driver; 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_ ...@@ -813,9 +813,11 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
if (!ctx) if (!ctx)
return -ENOMEM; return -ENOMEM;
ctx->dev = dev;
hrtimer_init(&ctx->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_init(&ctx->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
ctx->tx_timer.function = &cdc_ncm_tx_timer_cb; ctx->tx_timer.function = &cdc_ncm_tx_timer_cb;
tasklet_init(&ctx->bh, cdc_ncm_txpath_bh, (unsigned long)dev); tasklet_setup(&ctx->bh, cdc_ncm_txpath_bh);
atomic_set(&ctx->stop, 0); atomic_set(&ctx->stop, 0);
spin_lock_init(&ctx->mtx); spin_lock_init(&ctx->mtx);
...@@ -1472,10 +1474,10 @@ static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *timer) ...@@ -1472,10 +1474,10 @@ static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *timer)
return HRTIMER_NORESTART; return HRTIMER_NORESTART;
} }
static void cdc_ncm_txpath_bh(unsigned long param) static void cdc_ncm_txpath_bh(struct tasklet_struct *t)
{ {
struct usbnet *dev = (struct usbnet *)param; struct cdc_ncm_ctx *ctx = from_tasklet(ctx, t, bh);
struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; struct usbnet *dev = ctx->dev;
spin_lock_bh(&ctx->mtx); spin_lock_bh(&ctx->mtx);
if (ctx->tx_timer_pending != 0) { if (ctx->tx_timer_pending != 0) {
......
...@@ -98,6 +98,8 @@ struct cdc_ncm_ctx { ...@@ -98,6 +98,8 @@ struct cdc_ncm_ctx {
struct hrtimer tx_timer; struct hrtimer tx_timer;
struct tasklet_struct bh; struct tasklet_struct bh;
struct usbnet *dev;
const struct usb_cdc_ncm_desc *func_desc; const struct usb_cdc_ncm_desc *func_desc;
const struct usb_cdc_mbim_desc *mbim_desc; const struct usb_cdc_mbim_desc *mbim_desc;
const struct usb_cdc_mbim_extended_desc *mbim_extended_desc; const struct usb_cdc_mbim_extended_desc *mbim_extended_desc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment