From a11e0684f338f6cf003eb5dfb562d91da1866cc8 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Mon, 29 Aug 2022 14:42:17 +0200
Subject: [PATCH] initialize struct otg_fsm earlier
The earlier fix bf88fef0b6f1 ("usb: otg-fsm: Fix hrtimer list
corruption") in effect hid an issue with intialization.
In effect it replaces the racy continous reinitialization
of fsm->hnp_polling_work with a delayed one-time
initialization.
This just makes no sense. As a single initialization
is sufficient, the clean solution is just to do it once
and do it early enough.
Fixes: bf88fef0b6f1 ("usb: otg-fsm: Fix hrtimer list corruption")
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/usb/common/usb-otg-fsm.c | 7 +------
drivers/usb/phy/phy-fsl-usb.c | 1 +
include/linux/usb/otg-fsm.h | 1 -
3 files changed, 2 insertions(+), 7 deletions(-)
@@ -117,7 +117,7 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
}
}
-static void otg_hnp_polling_work(struct work_struct *work)
+void otg_hnp_polling_work(struct work_struct *work)
{
struct otg_fsm *fsm = container_of(to_delayed_work(work),
struct otg_fsm, hnp_polling_work);
@@ -193,11 +193,6 @@ static void otg_start_hnp_polling(struct otg_fsm *fsm)
if (!fsm->host_req_flag)
return;
- if (!fsm->hnp_work_inited) {
- INIT_DELAYED_WORK(&fsm->hnp_polling_work, otg_hnp_polling_work);
- fsm->hnp_work_inited = true;
- }
-
schedule_delayed_work(&fsm->hnp_polling_work,
msecs_to_jiffies(T_HOST_REQ_POLL));
}
@@ -844,6 +844,7 @@ int usb_otg_start(struct platform_device *pdev)
/* Initialize the state machine structure with default values */
SET_OTG_STATE(otg_trans, OTG_STATE_UNDEFINED);
+ INIT_DELAYED_WORK(&fsm->hnp_polling_work, otg_hnp_polling_work);
fsm->otg = p_otg->phy.otg;
/* We don't require predefined MEM/IRQ resource index */
@@ -183,7 +183,6 @@ struct otg_fsm {
struct mutex lock;
u8 *host_req_flag;
struct delayed_work hnp_polling_work;
- bool hnp_work_inited;
bool state_changed;
};
--
2.35.3