rt2x00: avoid introducing a USB dependency in the rt2x00lib module
PATCH 1/1 rt2x00: avoid introducing a USB dependency in the rt2x00lib module
Though protected by an ifdef, introducing an usb symbol dependency in the rt2x00lib module is a major inconvenience for distributions that package kernel modules split into individual packages.
Get rid of this unnecessary dependency by calling the usb related function from a more suitable place
--- drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 3 --- drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +0 -3
@@ -1436,14 +1436,11 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)cancel_work_sync (&rt2x00dev->intf_work);cancel_delayed_work_sync (&rt2x00dev->autowakeup_work);cancel_work_sync (&rt2x00dev->sleep_work); -#if IS_ENABLED (CONFIG_RT2X00_LIB_USB )if (rt2x00_is_usb (rt2x00dev)) { -usb_kill_anchored_urbs (rt2x00dev->anchor);hrtimer_cancel (&rt2x00dev->txstatus_timer);cancel_work_sync (&rt2x00dev->rxdone_work);cancel_work_sync (&rt2x00dev->txdone_work); } -#endif if (rt2x00dev->workqueue)destroy_workqueue (rt2x00dev->workqueue);
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +2 -0
@@ -858,11 +858,13 @@ void rt2x00usb_disconnect(struct usb_interface *usb_intf) {struct ieee80211_hw *hw =usb_get_intfdata (usb_intf);struct rt2x00_dev *rt2x00dev = hw->priv; +struct usb_anchor *anchor = rt2x00dev->anchor;/* * Free all allocated data. */ rt2x00lib_remove_dev (rt2x00dev); +usb_kill_anchored_urbs (anchor);rt2x00usb_free_reg (rt2x00dev);ieee80211_free_hw (hw);
Signature · 1 line
2.11.0
Hi
Quoted 6 lines · Felix Fietkau
Though protected by an ifdef, introducing an usb symbol dependency in the rt2x00lib module is a major inconvenience for distributions that package kernel modules split into individual packages.
Get rid of this unnecessary dependency by calling the usb related function from a more suitable place
<snip>
Review
Quoted 2 lines
(quoted diff) +1
-0rt2x00lib_remove_dev(rt2x00dev); + usb_kill_anchored_urbs(anchor);
At this point killing urb's is too late, because we already free structures that are used by urb->callback.
Below patch should solve the problem and not break shutdown sequence:
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +8 -15
@@ -1441,21 +1441,6 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)cancel_work_sync (&rt2x00dev->intf_work);cancel_delayed_work_sync (&rt2x00dev->autowakeup_work);cancel_work_sync (&rt2x00dev->sleep_work); -#if IS_ENABLED (CONFIG_RT2X00_LIB_USB ) -if (rt2x00_is_usb (rt2x00dev)) { -usb_kill_anchored_urbs (rt2x00dev->anchor); -hrtimer_cancel (&rt2x00dev->txstatus_timer); -cancel_work_sync (&rt2x00dev->rxdone_work); -cancel_work_sync (&rt2x00dev->txdone_work); - } -#endif -if (rt2x00dev->workqueue) -destroy_workqueue (rt2x00dev->workqueue); - -/* -* Free the tx status fifo. -*/ -kfifo_free (&rt2x00dev->txstatus_fifo);/* * Kill the tx status tasklet.
@@ -1471,6 +1456,14 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)*/ rt2x00lib_uninitialize (rt2x00dev); +if (rt2x00dev->workqueue) +destroy_workqueue (rt2x00dev->workqueue); + +/* +* Free the tx status fifo. +*/ +kfifo_free (&rt2x00dev->txstatus_fifo); +/* * Free extra components */
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +5 -0
@@ -744,6 +744,11 @@ void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev) {struct data_queue *queue; +usb_kill_anchored_urbs (rt2x00dev->anchor); +hrtimer_cancel (&rt2x00dev->txstatus_timer); +cancel_work_sync (&rt2x00dev->rxdone_work); +cancel_work_sync (&rt2x00dev->txdone_work); +queue_for_each (rt2x00dev, queue)rt2x00usb_free_entries (queue); }
Quoted 64 lines · Stanislaw Gruszka
Hi
Quoted 6 lines · Felix Fietkau
Though protected by an ifdef, introducing an usb symbol dependency in the rt2x00lib module is a major inconvenience for distributions that package kernel modules split into individual packages.
Get rid of this unnecessary dependency by calling the usb related function from a more suitable place
<snip>
Review
Quoted 2 lines
(quoted diff) +1
-0rt2x00lib_remove_dev(rt2x00dev); + usb_kill_anchored_urbs(anchor);At this point killing urb's is too late, because we already free structures that are used by
urb->callback.Below patch should solve the problem and not break shutdown sequence:
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +8
-15@@ -1441,21 +1441,6 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)cancel_work_sync (&rt2x00dev->intf_work);cancel_delayed_work_sync (&rt2x00dev->autowakeup_work);cancel_work_sync (&rt2x00dev->sleep_work); -#if IS_ENABLED (CONFIG_RT2X00_LIB_USB ) -if (rt2x00_is_usb (rt2x00dev)) { -usb_kill_anchored_urbs (rt2x00dev->anchor); -hrtimer_cancel (&rt2x00dev->txstatus_timer); -cancel_work_sync (&rt2x00dev->rxdone_work); -cancel_work_sync (&rt2x00dev->txdone_work); - } -#endif -if (rt2x00dev->workqueue) -destroy_workqueue (rt2x00dev->workqueue); - -/* -* Free the tx status fifo. -*/ -kfifo_free (&rt2x00dev->txstatus_fifo);/* * Kill the tx status tasklet. @@ -1471,6 +1456,14 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)*/ rt2x00lib_uninitialize (rt2x00dev); +if (rt2x00dev->workqueue) +destroy_workqueue (rt2x00dev->workqueue); + +/* +* Free the tx status fifo. +*/ +kfifo_free (&rt2x00dev->txstatus_fifo); +/* * Free extra components */ drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +0
-0
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev) · line 751
Quoted 8 lines
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +5
-0@@ -744,6 +744,11 @@ void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev) {struct data_queue *queue; +usb_kill_anchored_urbs (rt2x00dev->anchor); +hrtimer_cancel (&rt2x00dev->txstatus_timer); +cancel_work_sync (&rt2x00dev->rxdone_work); +cancel_work_sync (&rt2x00dev->txdone_work); +
Looks good to me, please submit that.
- Felix