--- zzzz-none-000/linux-3.10.107/sound/i2c/other/ak4113.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/i2c/other/ak4113.c 2021-02-04 17:41:59.000000000 +0000 @@ -73,7 +73,7 @@ void *private_data, struct ak4113 **r_ak4113) { struct ak4113 *chip; - int err = 0; + int err; unsigned char reg; static struct snd_device_ops ops = { .dev_free = snd_ak4113_dev_free, @@ -89,6 +89,7 @@ chip->private_data = private_data; INIT_DELAYED_WORK(&chip->work, ak4113_stats); atomic_set(&chip->wq_processing, 0); + mutex_init(&chip->reinit_mutex); for (reg = 0; reg < AK4113_WRITABLE_REGS ; reg++) chip->regmap[reg] = pgm[reg]; @@ -98,7 +99,7 @@ AK4113_CINT | AK4113_STC); chip->rcs1 = reg_read(chip, AK4113_REG_RCS1); chip->rcs2 = reg_read(chip, AK4113_REG_RCS2); - err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); + err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops); if (err < 0) goto __fail; @@ -108,7 +109,7 @@ __fail: snd_ak4113_free(chip); - return err < 0 ? err : -EIO; + return err; } EXPORT_SYMBOL_GPL(snd_ak4113_create); @@ -141,7 +142,9 @@ { if (atomic_inc_return(&chip->wq_processing) == 1) cancel_delayed_work_sync(&chip->work); + mutex_lock(&chip->reinit_mutex); ak4113_init_regs(chip); + mutex_unlock(&chip->reinit_mutex); /* bring up statistics / event queing */ if (atomic_dec_and_test(&chip->wq_processing)) schedule_delayed_work(&chip->work, HZ / 10); @@ -636,3 +639,19 @@ if (atomic_dec_and_test(&chip->wq_processing)) schedule_delayed_work(&chip->work, HZ / 10); } + +#ifdef CONFIG_PM +void snd_ak4113_suspend(struct ak4113 *chip) +{ + atomic_inc(&chip->wq_processing); /* don't schedule new work */ + cancel_delayed_work_sync(&chip->work); +} +EXPORT_SYMBOL(snd_ak4113_suspend); + +void snd_ak4113_resume(struct ak4113 *chip) +{ + atomic_dec(&chip->wq_processing); + snd_ak4113_reinit(chip); +} +EXPORT_SYMBOL(snd_ak4113_resume); +#endif