extcon: max14577: cancel cable detection work on detach
Subsystems (2)
PATCH 1/1 extcon: max14577: cancel cable detection work on detach
Probe queues wq_detcable, but the delayed work is not cancelled when the platform device is detached. Devres can therefore release info while the work is still pending.
Manage both work items with devres and request the nested IRQs only after the extcon device and work items are ready. Reverse-order release then stops the IRQ producers before cancelling the work and releasing info.
Signed-off-by Hongyan Xu <[email protected]>
--- drivers/extcon/extcon-max14577.c | 58 +++++++++++++++++--------------- 1 file changed, 30 insertions(+), 28 deletions(-)
drivers/extcon/extcon-max14577.c +30 -28
@@ -674,11 +674,6 @@ static int max14577_muic_probe(struct platform_device *pdev)platform_set_drvdata (pdev, info);mutex_init (&info->mutex); - ret =devm_work_autocancel (&pdev->dev, &info->irq_work, - max14577_muic_irq_work); -if (ret) -return ret; -switch (max14577->dev_type) {case MAXIM_DEVICE_TYPE_MAX77836 : info->muic_irqs = max77836_muic_irqs;
@@ -690,28 +685,6 @@ static int max14577_muic_probe(struct platform_device *pdev) info->muic_irqs_num =ARRAY_SIZE (max14577_muic_irqs); } -/* Support irq domain for max14577 MUIC device */ -for (i =0 ; i < info->muic_irqs_num; i++) { -struct max14577_muic_irq *muic_irq = &info->muic_irqs[i]; -int virq =0 ; - - virq =regmap_irq_get_virq (max14577->irq_data, muic_irq->irq); -if (virq <=0 ) -return -EINVAL ; - muic_irq->virq = virq; - - ret =devm_request_threaded_irq (&pdev->dev, virq,NULL , - max14577_muic_irq_handler, -IRQF_NO_SUSPEND , - muic_irq->name, info); -if (ret) { -dev_err (&pdev->dev, -"failed: irq request (IRQ: %d, error :%d)\n" , - muic_irq->irq, ret); -return ret; - } - } -/* Initialize extcon device */ info->edev =devm_extcon_dev_allocate (&pdev->dev, max14577_extcon_cable);
@@ -725,6 +698,14 @@ static int max14577_muic_probe(struct platform_device *pdev)dev_err (&pdev->dev,"failed to register extcon device\n" );return ret; } + ret =devm_work_autocancel (&pdev->dev, &info->irq_work, + max14577_muic_irq_work); +if (ret) +return ret; + ret =devm_delayed_work_autocancel (&pdev->dev, &info->wq_detcable, + max14577_muic_detect_cable_wq); +if (ret) +return ret;/* Default h/w line path */ info->path_usb =CTRL1_SW_USB ;
@@ -755,6 +736,28 @@ static int max14577_muic_probe(struct platform_device *pdev)/* Set ADC debounce time */ max14577_muic_set_debounce_time (info,ADC_DEBOUNCE_TIME_25MS ); +/* Support irq domain for max14577 MUIC device */ +for (i =0 ; i < info->muic_irqs_num; i++) { +struct max14577_muic_irq *muic_irq = &info->muic_irqs[i]; +int virq =0 ; + + virq =regmap_irq_get_virq (max14577->irq_data, muic_irq->irq); +if (virq <=0 ) +return -EINVAL ; + muic_irq->virq = virq; + + ret =devm_request_threaded_irq (&pdev->dev, virq,NULL , + max14577_muic_irq_handler, +IRQF_NO_SUSPEND , + muic_irq->name, info); +if (ret) { +dev_err (&pdev->dev, +"failed: irq request (IRQ: %d, error :%d)\n" , + muic_irq->irq, ret); +return ret; + } + } +/* * Detect accessory after completing the initialization of platform *
@@ -763,7 +766,6 @@ static int max14577_muic_probe(struct platform_device *pdev)* After completing the booting of platform, the extcon provider * driver should notify cable state to upper layer. */ -INIT_DELAYED_WORK (&info->wq_detcable, max14577_muic_detect_cable_wq);queue_delayed_work (system_power_efficient_wq, &info->wq_detcable, delay_jiffies);
Signature · 1 line
2.50.1.windows.1