Browse Source

asoc: wsa884x: update irq_drv_data per wsa device

regmap_irq_chip->irq_drv_data is shared by all attached wsa
devices and point to last probbed wsa device. This will cause
interrupt handle issue. Update irq_drv_data per wsa deviece to
resolve this issue.

Change-Id: I013f546d7f1ca6077f0b14e875b135a27325f851
Signed-off-by: Meng Wang <[email protected]>
Signed-off-by: Prasad Kumpatla <[email protected]>
Prasad Kumpatla 3 years ago
parent
commit
2dacb122a3
1 changed files with 12 additions and 3 deletions
  1. 12 3
      asoc/codecs/wsa884x/wsa884x.c

+ 12 - 3
asoc/codecs/wsa884x/wsa884x.c

@@ -1871,12 +1871,20 @@ static int wsa884x_swr_probe(struct swr_device *pdev)
 	struct snd_soc_component *component;
 	char buffer[MAX_NAME_LEN];
 	int dev_index = 0;
+	struct regmap_irq_chip *wsa884x_sub_regmap_irq_chip = NULL;
 
 	wsa884x = devm_kzalloc(&pdev->dev, sizeof(struct wsa884x_priv),
 			    GFP_KERNEL);
 	if (!wsa884x)
 		return -ENOMEM;
 
+	wsa884x_sub_regmap_irq_chip = devm_kzalloc(&pdev->dev, sizeof(struct regmap_irq_chip),
+				 GFP_KERNEL);
+	if (!wsa884x_sub_regmap_irq_chip)
+		return -ENOMEM;
+	memcpy(wsa884x_sub_regmap_irq_chip, &wsa884x_regmap_irq_chip,
+			sizeof(struct regmap_irq_chip));
+
 	ret = wsa884x_enable_supplies(&pdev->dev, wsa884x);
 	if (ret) {
 		ret = -EPROBE_DEFER;
@@ -1891,6 +1899,7 @@ static int wsa884x_swr_probe(struct swr_device *pdev)
 	}
 	swr_set_dev_data(pdev, wsa884x);
 	wsa884x->swr_slave = pdev;
+	wsa884x->dev = &pdev->dev;
 	pin_state_current = msm_cdc_pinctrl_get_state(wsa884x->wsa_rst_np);
 	wsa884x_gpio_ctrl(wsa884x, true);
 	/*
@@ -1921,11 +1930,11 @@ static int wsa884x_swr_probe(struct swr_device *pdev)
 	devm_regmap_qti_debugfs_register(&pdev->dev, wsa884x->regmap);
 
 	/* Set all interrupts as edge triggered */
-	for (i = 0; i < wsa884x_regmap_irq_chip.num_regs; i++)
+	for (i = 0; i < wsa884x_sub_regmap_irq_chip->num_regs; i++)
 		regmap_write(wsa884x->regmap, (WSA884X_INTR_LEVEL0 + i), 0);
 
-	wsa884x_regmap_irq_chip.irq_drv_data = wsa884x;
-	wsa884x->irq_info.wcd_regmap_irq_chip = &wsa884x_regmap_irq_chip;
+	wsa884x_sub_regmap_irq_chip->irq_drv_data = wsa884x;
+	wsa884x->irq_info.wcd_regmap_irq_chip = wsa884x_sub_regmap_irq_chip;
 	wsa884x->irq_info.codec_name = "WSA884X";
 	wsa884x->irq_info.regmap = wsa884x->regmap;
 	wsa884x->irq_info.dev = &pdev->dev;