FAILED: patch "[PATCH] usb: atm: ueagle-atm: wait for pre-firmware load in" failed to apply to 7.1-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 7.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.1.y
git checkout FETCH_HEAD
git cherry-pick -x e2674dfbed8a30d57e2bc872c4bfa6c3eec918bf
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026071426-neurosis-lumpish-e192@gregkh' --subject-prefix 'PATCH 7.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From e2674dfbed8a30d57e2bc872c4bfa6c3eec918bf Mon Sep 17 00:00:00 2001
From: Mauricio Faria de Oliveira <[email protected]>
Date: Tue, 26 May 2026 14:09:44 -0300
Subject: [PATCH] usb: atm: ueagle-atm: wait for pre-firmware load in
.disconnect()
ueagle-atm uses the asynchronous request_firmware_nowait() in .probe(), but does not wait for its completion, not even in .disconnect(); so, if the device is unplugged meanwhile, its teardown runs concurrently with that.
Even though this inconsistency is worth addressing on its own, it has also triggered several bug reports in syzbot over the years (some auto-closed) where the firmware sysfs fallback mechanism (CONFIG_FW_LOADER_USER_HELPER) creates a firmware subdirectory in the device directory during its removal, which might hit unexpected conditions in kernfs, apparently, depending at which point the add and remove operations raced. (See links.)
The pattern is:
usb ?-?: Direct firmware load for ueagle-atm/eagle?.fw failed with error -2 usb ?-?: Falling back to sysfs fallback for: ueagle-atm/eagle?.fw <ERROR>
Call trace: ... kernfs_create_dir_ns sysfs_create_dir_ns create_dir kobject_add_internal kobject_add_varg kobject_add class_dir_create_and_add get_device_parent device_add fw_load_sysfs_fallback fw_load_from_user_helper firmware_fallback_sysfs _request_firmware request_firmware_work_func ...
(Some variations are observed, after fw_load_sysfs_fallback(), e.g., [1].)
While the kernfs side is being looked at, the ueagle-atm side can be fixed by waiting for the pre-firmware load in the .disconnect() handler.
This change has a similar approach to previous work by Andrey Tsygunka [2] (wait_for_completion() in .disconnect()), but it is relatively different in design/implementation; using the Originally-by tag for credit assignment.
This has been tested with:
- synthetic reproducer to check the error path;
- USB gadget (virtual device) to check the firmware upload path;
- QEMU device emulator to check the device ID re-enumeration path; (The latter two were written by Claude; no other code/text in this commit.)
Links (year first reported):
2025 https://syzbot.org/bug?extid=ce1e5a1b4e086b43e56d
2025 https://syzbot.org/bug?extid=9af8471255ac36e34fd4
2024 https://syzbot.org/bug?extid=306212936b13e520679d
2023 https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
2022 https://syzbot.org/bug?extid=782984d6f1701b526edb
2021 https://syzbot.org/bug?id=f3f221579f4ef7e9691281f3c6f56c05f83e8490
2021 https://syzbot.org/bug?id=84d86f0d71394829df6fc53daf6642c045983881
2021 https://syzbot.org/bug?id=3302dc1c0e2b9c94f2e8edb404eabc9267bc6f90
[1] https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
[2] https://lore.kernel.org/lkml/[email protected]/
drivers/usb/atm/ueagle-atm.c +31 -5
@@ -594,7 +594,9 @@ static int uea_send_modem_cmd(struct usb_device *usb,static void uea_upload_pre_firmware (const struct firmware *fw_entry,void *context) { -struct usb_device *usb = context; +struct usb_interface *intf = context; +struct usb_device *usb =interface_to_usbdev (intf); +struct completion *fw_done =usb_get_intfdata (intf);const u8 *pfw;u8 value;u32 crc =0 ;
@@ -663,15 +665,17 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry,uea_err (usb,"firmware is corrupted\n" ); err:release_firmware (fw_entry); +complete (fw_done); }/* * uea_load_firmware - Load usb firmware for pre-firmware devices. */ -static int uea_load_firmware (struct usb_device *usb,unsigned int ver) +static int uea_load_firmware (struct usb_interface *intf,unsigned int ver) {int ret;char *fw_name =EAGLE_FIRMWARE ; +struct usb_device *usb =interface_to_usbdev (intf);uea_info (usb,"pre-firmware device, uploading firmware\n" );
@@ -694,7 +698,7 @@ static int uea_load_firmware(struct usb_device *usb, unsigned int ver) } ret =request_firmware_nowait (THIS_MODULE ,1 , fw_name, &usb->dev, -GFP_KERNEL , usb, +GFP_KERNEL , intf, uea_upload_pre_firmware);if (ret)uea_err (usb,"firmware %s is not available\n" , fw_name);
@@ -2555,8 +2559,23 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)usb_reset_device (usb); -if (UEA_IS_PREFIRM (id)) -return uea_load_firmware (usb,UEA_CHIP_VERSION (id)); +if (UEA_IS_PREFIRM (id)) { +struct completion *fw_done; + +/* Wait for the firmware load to be done, in .disconnect() */ + fw_done =kzalloc_obj (*fw_done); +if (!fw_done) +return -ENOMEM ; + +init_completion (fw_done); +usb_set_intfdata (intf, fw_done); + + ret =uea_load_firmware (intf,UEA_CHIP_VERSION (id)); +if (ret) +kfree (fw_done); + +return ret; + } ret =usbatm_usb_probe (intf, id, &uea_usbatm_driver);if (ret ==0 ) {
@@ -2586,6 +2605,13 @@ static void uea_disconnect(struct usb_interface *intf)usbatm_usb_disconnect (intf);mutex_unlock (&uea_mutex);uea_info (usb,"ADSL device removed\n" ); + }else if (usb->config->desc.bNumInterfaces ==1 ) { +struct completion *fw_done =usb_get_intfdata (intf); + +uea_dbg (usb,"pre-firmware device, waiting firmware upload\n" ); +wait_for_completion (fw_done); +uea_dbg (usb,"pre-firmware device, finished waiting\n" ); +kfree (fw_done); } }
Sasha Levin
maintainerPATCH 1/3 usb: atm: ueagle-atm: use dev_dbg() for 'device found' message
From: Mauricio Faria de Oliveira <[email protected]>
[ Upstream commit 05c5075c3115010f97434c53d353d9a0d4b0e64e ]
Convert dev_info() to dev_dbg().
Per 'Documentation/process/coding-style.rst':
13) Printing kernel messages
... When drivers are working properly they are quiet, so prefer to use dev_dbg/pr_debug unless something is wrong.
While in there, correct the verb form and add 'with' for clarity.
Stable-dep-of: e2674dfbed8a ("usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()")
--- drivers/usb/atm/ueagle-atm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/atm/ueagle-atm.c +1 -1
@@ -2590,7 +2590,7 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)int ret;uea_enters (usb); - uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) Rev (%#X): %s\n", + uea_dbg(usb, "ADSL device found with vid (%#X) pid (%#X) Rev (%#X): %s\n", le16_to_cpu(usb->descriptor.idVendor), le16_to_cpu(usb->descriptor.idProduct), le16_to_cpu(usb->descriptor.bcdDevice),
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/3 usb: atm: ueagle-atm: remove function entry/exit debug messages
From: Mauricio Faria de Oliveira <[email protected]>
[ Upstream commit 1414b2242c2e9d670c4d8b83480f13db57627ba9 ]
Remove the driver-internal function entry/exit debug messages in favor of existing kernel-level function tracing mechanisms.
Stable-dep-of: e2674dfbed8a ("usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()")
--- drivers/usb/atm/ueagle-atm.c | 56 ++++-------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-)
drivers/usb/atm/ueagle-atm.c +6 -50
@@ -51,12 +51,6 @@ "[ueagle-atm vdbg] " format, ##args); \ } while (0) -#define uea_enters (usb_dev) \ - uea_vdbg(usb_dev, "entering %s\n" , __func__) - -#define uea_leaves (usb_dev) \ - uea_vdbg(usb_dev, "leaving %s\n" , __func__) - #define uea_err(usb_dev, format, args...) \ dev_err(&(usb_dev)->dev , "[UEAGLE-ATM] " format , ##args)
@@ -606,7 +600,6 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry,u32 crc =0 ;int ret, size; -uea_enters (usb);if (!fw_entry) {uea_err (usb,"firmware is not available\n" ); goto err;
@@ -670,7 +663,6 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry,uea_err (usb,"firmware is corrupted\n" ); err:release_firmware (fw_entry); -uea_leaves (usb); }/*
@@ -681,7 +673,6 @@ static int uea_load_firmware(struct usb_device *usb, unsigned int ver)int ret;char *fw_name =EAGLE_FIRMWARE ; -uea_enters (usb);uea_info (usb,"pre-firmware device, uploading firmware\n" );switch (ver) {
@@ -710,7 +701,6 @@ static int uea_load_firmware(struct usb_device *usb, unsigned int ver)else uea_info (usb,"loading firmware %s\n" , fw_name); -uea_leaves (usb);return ret; }
@@ -1137,7 +1127,6 @@ static int uea_cmv_e1(struct uea_softc *sc,struct cmv_e1 cmv;int ret; -uea_enters (INS_TO_USBDEV (sc)); uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Address : %c%c%c%c, " "offset : 0x%04x, data : 0x%08x\n", E1_FUNCTION_TYPE(function),
@@ -1164,9 +1153,8 @@ static int uea_cmv_e1(struct uea_softc *sc, sizeof(cmv), &cmv);if (ret <0 )return ret; - ret =wait_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc)); -return ret; + +return wait_cmv_ack (sc); } static int uea_cmv_e4(struct uea_softc *sc,
@@ -1175,7 +1163,6 @@ static int uea_cmv_e4(struct uea_softc *sc,struct cmv_e4 cmv;int ret; -uea_enters (INS_TO_USBDEV (sc));memset (&cmv,0 ,sizeof (cmv)); uea_vdbg(INS_TO_USBDEV(sc), "Function : %d-%d, Group : 0x%04x, "
@@ -1199,9 +1186,8 @@ static int uea_cmv_e4(struct uea_softc *sc, sizeof(cmv), &cmv);if (ret <0 )return ret; - ret =wait_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc)); -return ret; + +return wait_cmv_ack (sc); } static inline int uea_read_cmv_e1(struct uea_softc *sc,
@@ -1295,7 +1281,6 @@ static int uea_stat_e1(struct uea_softc *sc)u32 data;int ret; -uea_enters (INS_TO_USBDEV (sc)); data = sc->stats.phy.state; ret =uea_read_cmv_e1 (sc,E1_SA_STAT ,0 , &sc->stats.phy.state);
@@ -1438,7 +1423,6 @@ static int uea_stat_e4(struct uea_softc *sc)u32 tmp_arr[2 ];int ret; -uea_enters (INS_TO_USBDEV (sc)); data = sc->stats.phy.state;/* XXX only need to be done before operationnal... */
@@ -1805,7 +1789,6 @@ static int uea_start_reset(struct uea_softc *sc)u16 zero =0 ;/* ;-) */ int ret; -uea_enters (INS_TO_USBDEV (sc));uea_info (INS_TO_USBDEV (sc),"(re)booting started\n" );/* mask interrupt */
@@ -1873,7 +1856,6 @@ static int uea_start_reset(struct uea_softc *sc)return ret; sc->reset =0 ; -uea_leaves (INS_TO_USBDEV (sc));return ret; }
@@ -1889,7 +1871,6 @@ static int uea_kthread(void *data)int ret = -EAGAIN ;set_freezable (); -uea_enters (INS_TO_USBDEV (sc));while (!kthread_should_stop ()) {if (ret <0 || sc->reset) ret =uea_start_reset (sc);
@@ -1898,7 +1879,7 @@ static int uea_kthread(void *data)if (ret != -EAGAIN )uea_wait (sc,0 ,msecs_to_jiffies (1000 )); } -uea_leaves (INS_TO_USBDEV (sc)); +return ret; }
@@ -1911,8 +1892,6 @@ static int load_XILINX_firmware(struct uea_softc *sc)u8 value;char *fw_name =FPGA930_FIRMWARE ; -uea_enters (INS_TO_USBDEV (sc)); - ret =request_firmware (&fw_entry, fw_name, &sc->usb_dev->dev);if (ret) { uea_err(INS_TO_USBDEV(sc), "firmware %s is not available\n",
@@ -1956,7 +1935,6 @@ static int load_XILINX_firmware(struct uea_softc *sc) err1:release_firmware (fw_entry); err0: -uea_leaves (INS_TO_USBDEV (sc));return ret; }
@@ -1966,7 +1944,6 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr)struct cmv_dsc_e1 *dsc = &sc->cmv_dsc.e1;struct cmv_e1 *cmv = &intr->u.e1.s2.cmv; -uea_enters (INS_TO_USBDEV (sc));if (le16_to_cpu (cmv->wPreamble) !=E1_PREAMBLE ) goto bad1;
@@ -1990,7 +1967,6 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr)if (cmv->bFunction ==E1_MAKEFUNCTION (E1_ADSLDIRECTIVE ,E1_MODEMREADY )) {wake_up_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc));return ; }
@@ -2004,7 +1980,6 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr) sc->data = sc->data <<16 | sc->data >>16 ;wake_up_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc));return ; bad2:
@@ -2012,14 +1987,12 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr)"Function : %d, Subfunction : %d\n" ,E1_FUNCTION_TYPE (cmv->bFunction), E1_FUNCTION_SUBTYPE(cmv->bFunction)); -uea_leaves (INS_TO_USBDEV (sc));return ; bad1:uea_err (INS_TO_USBDEV (sc),"invalid cmv received, " "wPreamble %d, bDirection %d\n" ,le16_to_cpu (cmv->wPreamble), cmv->bDirection); -uea_leaves (INS_TO_USBDEV (sc)); }/* The modem send us an ack. First with check if it right */
@@ -2028,7 +2001,6 @@ static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr)struct cmv_dsc_e4 *dsc = &sc->cmv_dsc.e4;struct cmv_e4 *cmv = &intr->u.e4.s2.cmv; -uea_enters (INS_TO_USBDEV (sc)); uea_dbg(INS_TO_USBDEV(sc), "cmv %x %x %x %x %x %x\n", be16_to_cpu(cmv->wGroup), be16_to_cpu(cmv->wFunction), be16_to_cpu(cmv->wOffset), be16_to_cpu(cmv->wAddress),
@@ -2040,7 +2012,6 @@ static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr)if (be16_to_cpu (cmv->wFunction) ==E4_MAKEFUNCTION (E4_ADSLDIRECTIVE ,E4_MODEMREADY ,1 )) {wake_up_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc));return ; }
@@ -2053,7 +2024,6 @@ static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr) sc->data =be32_to_cpu (cmv->dwData[0 ]); sc->data1 =be32_to_cpu (cmv->dwData[1 ]);wake_up_cmv_ack (sc); -uea_leaves (INS_TO_USBDEV (sc));return ; bad2:
@@ -2061,7 +2031,6 @@ static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr)"Function : %d, Subfunction : %d\n" ,E4_FUNCTION_TYPE (cmv->wFunction), E4_FUNCTION_SUBTYPE(cmv->wFunction)); -uea_leaves (INS_TO_USBDEV (sc));return ; }
@@ -2089,8 +2058,6 @@ static void uea_intr(struct urb *urb)struct intr_pkt *intr = urb->transfer_buffer;int status = urb->status; -uea_enters (INS_TO_USBDEV (sc)); -if (unlikely (status <0 )) {uea_err (INS_TO_USBDEV (sc),"uea_intr() failed with %d\n" , status);
@@ -2130,8 +2097,6 @@ static int uea_boot(struct uea_softc *sc, struct usb_interface *intf)int ret = -ENOMEM ;int size; -uea_enters (INS_TO_USBDEV (sc)); -if (UEA_CHIP_VERSION (sc) ==EAGLE_IV ) { size =E4_INTR_PKT_SIZE ; sc->dispatch_cmv = uea_dispatch_cmv_e4;
@@ -2188,7 +2153,6 @@ static int uea_boot(struct uea_softc *sc, struct usb_interface *intf) goto err2; } -uea_leaves (INS_TO_USBDEV (sc));return 0 ; err2:
@@ -2198,7 +2162,6 @@ static int uea_boot(struct uea_softc *sc, struct usb_interface *intf) sc->urb_int =NULL ;kfree (intr); err0: -uea_leaves (INS_TO_USBDEV (sc));return ret; }
@@ -2208,7 +2171,7 @@ static int uea_boot(struct uea_softc *sc, struct usb_interface *intf)static void uea_stop (struct uea_softc *sc) {int ret; -uea_enters (INS_TO_USBDEV (sc)); + ret =kthread_stop (sc->kthread);uea_dbg (INS_TO_USBDEV (sc),"kthread finish with status %d\n" , ret);
@@ -2222,7 +2185,6 @@ static void uea_stop(struct uea_softc *sc)flush_work (&sc->task);release_firmware (sc->dsp_firm); -uea_leaves (INS_TO_USBDEV (sc)); }/* syfs interface */
@@ -2495,8 +2457,6 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,int ret, ifnum = intf->altsetting->desc.bInterfaceNumber;unsigned int alt; -uea_enters (usb); -/* interface 0 is for firmware/monitoring */ if (ifnum !=UEA_INTR_IFACE_NO )return -ENODEV ;
@@ -2589,7 +2549,6 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)struct usb_device *usb =interface_to_usbdev (intf);int ret; -uea_enters (usb); uea_dbg(usb, "ADSL device found with vid (%#X) pid (%#X) Rev (%#X): %s\n", le16_to_cpu(usb->descriptor.idVendor), le16_to_cpu(usb->descriptor.idProduct),
@@ -2620,7 +2579,6 @@ static void uea_disconnect(struct usb_interface *intf) {struct usb_device *usb =interface_to_usbdev (intf);int ifnum = intf->altsetting->desc.bInterfaceNumber; -uea_enters (usb);/* ADI930 has 2 interfaces and eagle 3 interfaces. * Pre-firmware device has one interface
@@ -2631,8 +2589,6 @@ static void uea_disconnect(struct usb_interface *intf)mutex_unlock (&uea_mutex);uea_info (usb,"ADSL device removed\n" ); } - -uea_leaves (usb); }/*
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/3 usb: atm: ueagle-atm: wait for pre-firmware load in .disconnect()
In reply to Sasha LevinFrom: Mauricio Faria de Oliveira <[email protected]>
[ Upstream commit e2674dfbed8a30d57e2bc872c4bfa6c3eec918bf ]
ueagle-atm uses the asynchronous request_firmware_nowait() in .probe(), but does not wait for its completion, not even in .disconnect(); so, if the device is unplugged meanwhile, its teardown runs concurrently with that.
Even though this inconsistency is worth addressing on its own, it has also triggered several bug reports in syzbot over the years (some auto-closed) where the firmware sysfs fallback mechanism (CONFIG_FW_LOADER_USER_HELPER) creates a firmware subdirectory in the device directory during its removal, which might hit unexpected conditions in kernfs, apparently, depending at which point the add and remove operations raced. (See links.)
The pattern is:
usb ?-?: Direct firmware load for ueagle-atm/eagle?.fw failed with error -2 usb ?-?: Falling back to sysfs fallback for: ueagle-atm/eagle?.fw <ERROR>
Call trace: ... kernfs_create_dir_ns sysfs_create_dir_ns create_dir kobject_add_internal kobject_add_varg kobject_add class_dir_create_and_add get_device_parent device_add fw_load_sysfs_fallback fw_load_from_user_helper firmware_fallback_sysfs _request_firmware request_firmware_work_func ...
(Some variations are observed, after fw_load_sysfs_fallback(), e.g., [1].)
While the kernfs side is being looked at, the ueagle-atm side can be fixed by waiting for the pre-firmware load in the .disconnect() handler.
This change has a similar approach to previous work by Andrey Tsygunka [2] (wait_for_completion() in .disconnect()), but it is relatively different in design/implementation; using the Originally-by tag for credit assignment.
This has been tested with:
- synthetic reproducer to check the error path;
- USB gadget (virtual device) to check the firmware upload path;
- QEMU device emulator to check the device ID re-enumeration path; (The latter two were written by Claude; no other code/text in this commit.)
Links (year first reported):
2025 https://syzbot.org/bug?extid=ce1e5a1b4e086b43e56d
2025 https://syzbot.org/bug?extid=9af8471255ac36e34fd4
2024 https://syzbot.org/bug?extid=306212936b13e520679d
2023 https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
2022 https://syzbot.org/bug?extid=782984d6f1701b526edb
2021 https://syzbot.org/bug?id=f3f221579f4ef7e9691281f3c6f56c05f83e8490
2021 https://syzbot.org/bug?id=84d86f0d71394829df6fc53daf6642c045983881
2021 https://syzbot.org/bug?id=3302dc1c0e2b9c94f2e8edb404eabc9267bc6f90
[1] https://syzkaller.appspot.com/bug?extid=457452d30bcdda75ead2
[2] https://lore.kernel.org/lkml/[email protected]/
--- drivers/usb/atm/ueagle-atm.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/usb/atm/ueagle-atm.c +31 -5
@@ -594,7 +594,9 @@ static int uea_send_modem_cmd(struct usb_device *usb,static void uea_upload_pre_firmware (const struct firmware *fw_entry,void *context) { -struct usb_device *usb = context; +struct usb_interface *intf = context; +struct usb_device *usb =interface_to_usbdev (intf); +struct completion *fw_done =usb_get_intfdata (intf);const u8 *pfw;u8 value;u32 crc =0 ;
@@ -663,15 +665,17 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry,uea_err (usb,"firmware is corrupted\n" ); err:release_firmware (fw_entry); +complete (fw_done); }/* * uea_load_firmware - Load usb firmware for pre-firmware devices. */ -static int uea_load_firmware (struct usb_device *usb,unsigned int ver) +static int uea_load_firmware (struct usb_interface *intf,unsigned int ver) {int ret;char *fw_name =EAGLE_FIRMWARE ; +struct usb_device *usb =interface_to_usbdev (intf);uea_info (usb,"pre-firmware device, uploading firmware\n" );
@@ -694,7 +698,7 @@ static int uea_load_firmware(struct usb_device *usb, unsigned int ver) } ret =request_firmware_nowait (THIS_MODULE ,1 , fw_name, &usb->dev, -GFP_KERNEL , usb, +GFP_KERNEL , intf, uea_upload_pre_firmware);if (ret)uea_err (usb,"firmware %s is not available\n" , fw_name);
@@ -2557,8 +2561,23 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)usb_reset_device (usb); -if (UEA_IS_PREFIRM (id)) -return uea_load_firmware (usb,UEA_CHIP_VERSION (id)); +if (UEA_IS_PREFIRM (id)) { +struct completion *fw_done; + +/* Wait for the firmware load to be done, in .disconnect() */ + fw_done =kzalloc_obj (*fw_done); +if (!fw_done) +return -ENOMEM ; + +init_completion (fw_done); +usb_set_intfdata (intf, fw_done); + + ret =uea_load_firmware (intf,UEA_CHIP_VERSION (id)); +if (ret) +kfree (fw_done); + +return ret; + } ret =usbatm_usb_probe (intf, id, &uea_usbatm_driver);if (ret ==0 ) {
@@ -2588,6 +2607,13 @@ static void uea_disconnect(struct usb_interface *intf)usbatm_usb_disconnect (intf);mutex_unlock (&uea_mutex);uea_info (usb,"ADSL device removed\n" ); + }else if (usb->config->desc.bNumInterfaces ==1 ) { +struct completion *fw_done =usb_get_intfdata (intf); + +uea_dbg (usb,"pre-firmware device, waiting firmware upload\n" ); +wait_for_completion (fw_done); +uea_dbg (usb,"pre-firmware device, finished waiting\n" ); +kfree (fw_done); } }
Signature · 1 line
2.53.0