On 7/18/2026 12:51 AM, Dmitry Torokhov wrote:
quoted
+
+static void qcom_haptics_remove(struct platform_device *pdev)
+{
+ struct qcom_haptics *h = platform_get_drvdata(pdev);
+
+ /*
+ * Unregister the input device explicitly at the beginning
+ * to avoid the input device being used after the resources
+ * are freed.
+ */
+ input_unregister_device(h->input);
+ disable_delayed_work_sync(&h->play_work);
+ scoped_guard(mutex, &h->play_lock) {
+ haptics_queue_flush(h);
+ haptics_stop_locked(h, true);
+ }
+
+ haptics_enable_module(h, false);
+
+ scoped_guard(mutex, &h->fifo_lock) {
+ for (int i = 0; i < HAPTICS_MAX_EFFECTS; i++) {
+ kvfree(h->effects[i].fifo_data);
+ h->effects[i].fifo_data = NULL;
+ }
+ }
Most of this is better suited to close() method of input device.
Hi Dmitry,
I tried moving this into the close() function of the input device, but
I’m running into an issue: 'disable_delayed_work_sync(&h->play_work)'
may be called multiple times when the input device is opened and closed,
and the delayed work can sometimes end up being disabled unexpectedly.
That would mean I need another flag to track whether the delayed work is
enabled. Do you see any concerns with that, or should I still keep it in
remove()?
Thanks
Fenglin
quoted
+}