mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
ASoC: codecs: pm4125: Fix potential conflict when probing two devices
Qualcomm PM4125 codec is always a single device on the board, however
nothing stops board designers to have two of them, thus same device
driver could probe twice.
Device driver is not ready for that case, because it allocates
statically 'struct regmap_irq_chip' as non-const and stores during
component bind in 'irq_drv_data' member a pointer to per-probe state
container ('struct pm4125_priv').
Second component bind would overwrite the 'irq_drv_data' from previous
device probe, so interrupts would be executed in wrong context.
The fix makes use of currently unused 'struct pm4125_priv' member
'pm4125_regmap_irq_chip', but renames it to a shorter name.
Fixes: 8ad5294849 ("ASoC: codecs: add new pm4125 audio codec driver")
Cc: stable@vger.kernel.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20251023-asoc-regmap-irq-chip-v1-1-17ad32680913@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
123cd174a3
commit
fd94857a93
@@ -71,7 +71,7 @@ struct pm4125_priv {
|
||||
struct wcd_mbhc_intr intr_ids;
|
||||
struct wcd_common common;
|
||||
struct irq_domain *virq;
|
||||
const struct regmap_irq_chip *pm4125_regmap_irq_chip;
|
||||
const struct regmap_irq_chip *chip_desc;
|
||||
struct regmap_irq_chip_data *irq_chip;
|
||||
struct snd_soc_jack *jack;
|
||||
unsigned long status_mask;
|
||||
@@ -177,7 +177,7 @@ static const u32 pm4125_config_regs[] = {
|
||||
PM4125_DIG_SWR_INTR_LEVEL_0,
|
||||
};
|
||||
|
||||
static struct regmap_irq_chip pm4125_regmap_irq_chip = {
|
||||
static const struct regmap_irq_chip pm4125_regmap_irq_chip = {
|
||||
.name = "pm4125",
|
||||
.irqs = pm4125_irqs,
|
||||
.num_irqs = ARRAY_SIZE(pm4125_irqs),
|
||||
@@ -1301,10 +1301,8 @@ static int pm4125_irq_init(struct pm4125_priv *pm4125, struct device *dev)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pm4125_regmap_irq_chip.irq_drv_data = pm4125;
|
||||
|
||||
return devm_regmap_add_irq_chip(dev, pm4125->regmap, irq_create_mapping(pm4125->virq, 0),
|
||||
IRQF_ONESHOT, 0, &pm4125_regmap_irq_chip,
|
||||
IRQF_ONESHOT, 0, pm4125->chip_desc,
|
||||
&pm4125->irq_chip);
|
||||
}
|
||||
|
||||
@@ -1647,6 +1645,7 @@ static int pm4125_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct component_match *match = NULL;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct regmap_irq_chip *chip_desc;
|
||||
struct pm4125_priv *pm4125;
|
||||
struct wcd_mbhc_config *cfg;
|
||||
int ret;
|
||||
@@ -1657,6 +1656,14 @@ static int pm4125_probe(struct platform_device *pdev)
|
||||
|
||||
dev_set_drvdata(dev, pm4125);
|
||||
|
||||
chip_desc = devm_kmemdup(dev, &pm4125_regmap_irq_chip,
|
||||
sizeof(pm4125_regmap_irq_chip),
|
||||
GFP_KERNEL);
|
||||
if (!chip_desc)
|
||||
return -ENOMEM;
|
||||
chip_desc->irq_drv_data = pm4125;
|
||||
pm4125->chip_desc = chip_desc;
|
||||
|
||||
ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(pm4125_power_supplies),
|
||||
pm4125_power_supplies);
|
||||
if (ret)
|
||||
|
||||
Reference in New Issue
Block a user