未验证 提交 5982b5a8 编写于 作者: R Richard Fitzgerald 提交者: Mark Brown

ASoC: cs42l42: Change jack_detect_mutex to a lock of all IRQ handling

Rename jack_detect_mutex to irq_lock and make it lock the entire IRQ
handling.

The jack_detect_mutex was introduced to synchronize registering an
ALSA jack handler, via cs42l42_set_jack(), with the jack state
processing in the IRQ handler, and was taken only around the
relevant part of the IRQ handling code.

System suspend will need to synchronize with the IRQ handler thread
so will need a similar mutex that surrounds all of the IRQ handling.
Repurposing the existing jack_detect_mutex is the simplest option.
It does no harm for a call to cs42l42_set_jack() to additionally
block the first few lines of IRQ handling, and the only interrupts
used by the driver are all for jack handling.
Signed-off-by: NRichard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220121120412.672284-3-rf@opensource.cirrus.comSigned-off-by: NMark Brown <broonie@kernel.org>
上级 8d06f797
...@@ -550,7 +550,7 @@ static int cs42l42_set_jack(struct snd_soc_component *component, struct snd_soc_ ...@@ -550,7 +550,7 @@ static int cs42l42_set_jack(struct snd_soc_component *component, struct snd_soc_
struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component);
/* Prevent race with interrupt handler */ /* Prevent race with interrupt handler */
mutex_lock(&cs42l42->jack_detect_mutex); mutex_lock(&cs42l42->irq_lock);
cs42l42->jack = jk; cs42l42->jack = jk;
if (jk) { if (jk) {
...@@ -566,7 +566,7 @@ static int cs42l42_set_jack(struct snd_soc_component *component, struct snd_soc_ ...@@ -566,7 +566,7 @@ static int cs42l42_set_jack(struct snd_soc_component *component, struct snd_soc_
break; break;
} }
} }
mutex_unlock(&cs42l42->jack_detect_mutex); mutex_unlock(&cs42l42->irq_lock);
return 0; return 0;
} }
...@@ -1613,6 +1613,7 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) ...@@ -1613,6 +1613,7 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data)
unsigned int i; unsigned int i;
int report = 0; int report = 0;
mutex_lock(&cs42l42->irq_lock);
/* Read sticky registers to clear interurpt */ /* Read sticky registers to clear interurpt */
for (i = 0; i < ARRAY_SIZE(stickies); i++) { for (i = 0; i < ARRAY_SIZE(stickies); i++) {
...@@ -1635,8 +1636,6 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) ...@@ -1635,8 +1636,6 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data)
CS42L42_M_DETECT_FT_MASK | CS42L42_M_DETECT_FT_MASK |
CS42L42_M_HSBIAS_HIZ_MASK); CS42L42_M_HSBIAS_HIZ_MASK);
mutex_lock(&cs42l42->jack_detect_mutex);
/* /*
* Check auto-detect status. Don't assume a previous unplug event has * Check auto-detect status. Don't assume a previous unplug event has
* cleared the flags. If the jack is unplugged and plugged during * cleared the flags. If the jack is unplugged and plugged during
...@@ -1713,7 +1712,7 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) ...@@ -1713,7 +1712,7 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data)
} }
} }
mutex_unlock(&cs42l42->jack_detect_mutex); mutex_unlock(&cs42l42->irq_lock);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -2062,7 +2061,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client, ...@@ -2062,7 +2061,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,
cs42l42->dev = &i2c_client->dev; cs42l42->dev = &i2c_client->dev;
i2c_set_clientdata(i2c_client, cs42l42); i2c_set_clientdata(i2c_client, cs42l42);
mutex_init(&cs42l42->jack_detect_mutex); mutex_init(&cs42l42->irq_lock);
cs42l42->regmap = devm_regmap_init_i2c(i2c_client, &cs42l42_regmap); cs42l42->regmap = devm_regmap_init_i2c(i2c_client, &cs42l42_regmap);
if (IS_ERR(cs42l42->regmap)) { if (IS_ERR(cs42l42->regmap)) {
......
...@@ -842,7 +842,7 @@ struct cs42l42_private { ...@@ -842,7 +842,7 @@ struct cs42l42_private {
struct gpio_desc *reset_gpio; struct gpio_desc *reset_gpio;
struct completion pdn_done; struct completion pdn_done;
struct snd_soc_jack *jack; struct snd_soc_jack *jack;
struct mutex jack_detect_mutex; struct mutex irq_lock;
int pll_config; int pll_config;
int bclk; int bclk;
u32 sclk; u32 sclk;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册