Browse Source

asoc: wsa883x: 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.
(cherry-picked from commit 1852682fbcebfb9f479c3d09a91c075049b90253)

Change-Id: I6ac0520a4074d74dfb28122e06eed6a86374c0ce
Signed-off-by: Phani Kumar Uppalapati <[email protected]>
Phani Kumar Uppalapati 3 years ago
parent
commit
2f03655808
1 changed files with 12 additions and 3 deletions
  1. 12 3
      asoc/codecs/wsa883x/wsa883x.c

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

@@ -1689,12 +1689,20 @@ static int wsa883x_swr_probe(struct swr_device *pdev)
 	struct snd_soc_component *component;
 	char buffer[MAX_NAME_LEN];
 	int dev_index = 0;
+	struct regmap_irq_chip *wsa883x_sub_regmap_irq_chip = NULL;
 
 	wsa883x = devm_kzalloc(&pdev->dev, sizeof(struct wsa883x_priv),
 			    GFP_KERNEL);
 	if (!wsa883x)
 		return -ENOMEM;
 
+	wsa883x_sub_regmap_irq_chip = devm_kzalloc(&pdev->dev, sizeof(struct regmap_irq_chip),
+				GFP_KERNEL);
+	if (!wsa883x_sub_regmap_irq_chip)
+		return -ENOMEM;
+	memcpy(wsa883x_sub_regmap_irq_chip, &wsa883x_regmap_irq_chip,
+		sizeof(struct regmap_irq_chip));
+
 	ret = wsa883x_enable_supplies(&pdev->dev, wsa883x);
 	if (ret) {
 		ret = -EPROBE_DEFER;
@@ -1709,6 +1717,7 @@ static int wsa883x_swr_probe(struct swr_device *pdev)
 	}
 	swr_set_dev_data(pdev, wsa883x);
 	wsa883x->swr_slave = pdev;
+	wsa883x->dev = &pdev->dev;
 	pin_state_current = msm_cdc_pinctrl_get_state(wsa883x->wsa_rst_np);
 	wsa883x_gpio_ctrl(wsa883x, true);
 	/*
@@ -1739,11 +1748,11 @@ static int wsa883x_swr_probe(struct swr_device *pdev)
 	devm_regmap_qti_debugfs_register(&pdev->dev, wsa883x->regmap);
 
 	/* Set all interrupts as edge triggered */
-	for (i = 0; i < wsa883x_regmap_irq_chip.num_regs; i++)
+	for (i = 0; i < wsa883x_sub_regmap_irq_chip->num_regs; i++)
 		regmap_write(wsa883x->regmap, (WSA883X_INTR_LEVEL0 + i), 0);
 
-	wsa883x_regmap_irq_chip.irq_drv_data = wsa883x;
-	wsa883x->irq_info.wcd_regmap_irq_chip = &wsa883x_regmap_irq_chip;
+	wsa883x_sub_regmap_irq_chip->irq_drv_data = wsa883x;
+	wsa883x->irq_info.wcd_regmap_irq_chip = wsa883x_sub_regmap_irq_chip;
 	wsa883x->irq_info.codec_name = "WSA883X";
 	wsa883x->irq_info.regmap = wsa883x->regmap;
 	wsa883x->irq_info.dev = &pdev->dev;