aboutsummaryrefslogtreecommitdiffstats
path: root/sound/i2c/other/ak4114.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/i2c/other/ak4114.c')
-rw-r--r--sound/i2c/other/ak4114.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index c7f56339415d..b70e6eccbd03 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -66,8 +66,7 @@ static void reg_dump(struct ak4114 *ak4114)
66 66
67static void snd_ak4114_free(struct ak4114 *chip) 67static void snd_ak4114_free(struct ak4114 *chip)
68{ 68{
69 chip->init = 1; /* don't schedule new work */ 69 atomic_inc(&chip->wq_processing); /* don't schedule new work */
70 mb();
71 cancel_delayed_work_sync(&chip->work); 70 cancel_delayed_work_sync(&chip->work);
72 kfree(chip); 71 kfree(chip);
73} 72}
@@ -100,6 +99,7 @@ int snd_ak4114_create(struct snd_card *card,
100 chip->write = write; 99 chip->write = write;
101 chip->private_data = private_data; 100 chip->private_data = private_data;
102 INIT_DELAYED_WORK(&chip->work, ak4114_stats); 101 INIT_DELAYED_WORK(&chip->work, ak4114_stats);
102 atomic_set(&chip->wq_processing, 0);
103 103
104 for (reg = 0; reg < 6; reg++) 104 for (reg = 0; reg < 6; reg++)
105 chip->regmap[reg] = pgm[reg]; 105 chip->regmap[reg] = pgm[reg];
@@ -152,13 +152,11 @@ static void ak4114_init_regs(struct ak4114 *chip)
152 152
153void snd_ak4114_reinit(struct ak4114 *chip) 153void snd_ak4114_reinit(struct ak4114 *chip)
154{ 154{
155 chip->init = 1; 155 if (atomic_inc_return(&chip->wq_processing) == 1)
156 mb(); 156 cancel_delayed_work_sync(&chip->work);
157 flush_delayed_work(&chip->work);
158 ak4114_init_regs(chip); 157 ak4114_init_regs(chip);
159 /* bring up statistics / event queing */ 158 /* bring up statistics / event queing */
160 chip->init = 0; 159 if (atomic_dec_and_test(&chip->wq_processing))
161 if (chip->kctls[0])
162 schedule_delayed_work(&chip->work, HZ / 10); 160 schedule_delayed_work(&chip->work, HZ / 10);
163} 161}
164 162
@@ -612,10 +610,10 @@ static void ak4114_stats(struct work_struct *work)
612{ 610{
613 struct ak4114 *chip = container_of(work, struct ak4114, work.work); 611 struct ak4114 *chip = container_of(work, struct ak4114, work.work);
614 612
615 if (!chip->init) 613 if (atomic_inc_return(&chip->wq_processing) == 1)
616 snd_ak4114_check_rate_and_errors(chip, chip->check_flags); 614 snd_ak4114_check_rate_and_errors(chip, chip->check_flags);
617 615 if (atomic_dec_and_test(&chip->wq_processing))
618 schedule_delayed_work(&chip->work, HZ / 10); 616 schedule_delayed_work(&chip->work, HZ / 10);
619} 617}
620 618
621EXPORT_SYMBOL(snd_ak4114_create); 619EXPORT_SYMBOL(snd_ak4114_create);