Ver código fonte

asoc: codec: Fix wsa884x IRQ deinitialization

Fix wsa884x deinitialization to avoid double
free and use correct kfree function to prevent
crash.

Change-Id: If7e0e3ceb76f9a29fbafee274147f2992e02085f
Signed-off-by: Eric Rosas <[email protected]>
Eric Rosas 2 anos atrás
pai
commit
9b11a9ddae
2 arquivos alterados com 10 adições e 25 exclusões
  1. 2 2
      asoc/codecs/wcd-irq.c
  2. 8 23
      asoc/codecs/wsa884x/wsa884x.c

+ 2 - 2
asoc/codecs/wcd-irq.c

@@ -42,7 +42,7 @@ int wcd_request_irq(struct wcd_irq_info *irq_info, int irq, const char *name,
 	if (irq < 0)
 		return irq;
 
-	return request_threaded_irq(irq, NULL, handler,
+	return devm_request_threaded_irq(irq_info->dev, irq, NULL, handler,
 				    IRQF_ONESHOT | IRQF_TRIGGER_RISING,
 				    name, data);
 }
@@ -65,7 +65,7 @@ void wcd_free_irq(struct wcd_irq_info *irq_info, int irq, void *data)
 	if (irq < 0)
 		return;
 
-	free_irq(irq, data);
+	devm_free_irq(irq_info->dev, irq, data);
 }
 EXPORT_SYMBOL(wcd_free_irq);
 

+ 8 - 23
asoc/codecs/wsa884x/wsa884x.c

@@ -1122,6 +1122,9 @@ static bool wsa884x_validate_dt_configuration_params(struct snd_soc_component *c
 	bool is_invalid_flag = true;
 
 	bat_cfg_reg = snd_soc_component_read(component, WSA884X_VPHX_SYS_EN_STATUS);
+
+	dev_info(component->dev, "VPHX EN Status: %d", bat_cfg_reg);
+
 	if ((ibat_cfg_dts == EXT_1S) || (ibat_cfg_dts == EXT_2S) || (ibat_cfg_dts == EXT_3S))
 		ibat_cfg_dts = EXT_ABOVE_3S;
 	if ((WSA_4_OHMS <= irload && irload < WSA_MAX_OHMS) &&
@@ -2331,26 +2334,19 @@ static int wsa884x_swr_probe(struct swr_device *pdev)
 	return 0;
 
 err_mem:
+	snd_soc_unregister_component(&pdev->dev);
 	if (wsa884x->dai_driver) {
 		kfree(wsa884x->dai_driver->name);
 		kfree(wsa884x->dai_driver->playback.stream_name);
-		kfree(wsa884x->dai_driver);
+		devm_kfree(&pdev->dev, wsa884x->dai_driver);
+		wsa884x->dai_driver = NULL;
 	}
 	if (wsa884x->driver) {
 		kfree(wsa884x->driver->name);
-		kfree(wsa884x->driver);
+		devm_kfree(&pdev->dev, wsa884x->driver);
+		wsa884x->driver = NULL;
 	}
 err_irq:
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_SAF2WAR, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_WAR2SAF, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_DISABLE, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_OCP, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_CLIP, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_PDM_WD, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_CLK_WD, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_INTR_PIN, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_UVLO, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_PA_ON_ERR, NULL);
 	wcd_irq_exit(&wsa884x->irq_info, wsa884x->virq);
 dev_err:
 	if (pin_state_current == false)
@@ -2375,17 +2371,6 @@ static int wsa884x_swr_remove(struct swr_device *pdev)
 		return -EINVAL;
 	}
 
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_SAF2WAR, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_WAR2SAF, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_DISABLE, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_OCP, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_CLIP, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_PDM_WD, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_CLK_WD, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_INTR_PIN, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_UVLO, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_PA_ON_ERR, NULL);
-
 	if (wsa884x->register_notifier)
 		wsa884x->register_notifier(wsa884x->handle,
 				&wsa884x->parent_nblock, false);