diff options
Diffstat (limited to 'sound/atmel/ac97c.c')
| -rw-r--r-- | sound/atmel/ac97c.c | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 66ecbd4d034e..df0a049192de 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -12,13 +12,13 @@ #include <linux/gpio/consumer.h> #include <linux/init.h> #include <linux/interrupt.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/mutex.h> +#include <linux/string.h> #include <linux/types.h> #include <linux/io.h> -#include <linux/of.h> -#include <linux/of_device.h> #include <sound/core.h> #include <sound/initval.h> @@ -88,7 +88,7 @@ static int atmel_ac97c_playback_open(struct snd_pcm_substream *substream) struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; - mutex_lock(&opened_mutex); + guard(mutex)(&opened_mutex); chip->opened++; runtime->hw = atmel_ac97c_hw; if (chip->cur_rate) { @@ -97,7 +97,6 @@ static int atmel_ac97c_playback_open(struct snd_pcm_substream *substream) } if (chip->cur_format) runtime->hw.formats = pcm_format_to_bits(chip->cur_format); - mutex_unlock(&opened_mutex); chip->playback_substream = substream; return 0; } @@ -107,7 +106,7 @@ static int atmel_ac97c_capture_open(struct snd_pcm_substream *substream) struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; - mutex_lock(&opened_mutex); + guard(mutex)(&opened_mutex); chip->opened++; runtime->hw = atmel_ac97c_hw; if (chip->cur_rate) { @@ -116,7 +115,6 @@ static int atmel_ac97c_capture_open(struct snd_pcm_substream *substream) } if (chip->cur_format) runtime->hw.formats = pcm_format_to_bits(chip->cur_format); - mutex_unlock(&opened_mutex); chip->capture_substream = substream; return 0; } @@ -125,13 +123,12 @@ static int atmel_ac97c_playback_close(struct snd_pcm_substream *substream) { struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); - mutex_lock(&opened_mutex); + guard(mutex)(&opened_mutex); chip->opened--; if (!chip->opened) { chip->cur_rate = 0; chip->cur_format = 0; } - mutex_unlock(&opened_mutex); chip->playback_substream = NULL; @@ -142,13 +139,12 @@ static int atmel_ac97c_capture_close(struct snd_pcm_substream *substream) { struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); - mutex_lock(&opened_mutex); + guard(mutex)(&opened_mutex); chip->opened--; if (!chip->opened) { chip->cur_rate = 0; chip->cur_format = 0; } - mutex_unlock(&opened_mutex); chip->capture_substream = NULL; @@ -161,10 +157,9 @@ static int atmel_ac97c_playback_hw_params(struct snd_pcm_substream *substream, struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); /* Set restrictions to params. */ - mutex_lock(&opened_mutex); + guard(mutex)(&opened_mutex); chip->cur_rate = params_rate(hw_params); chip->cur_format = params_format(hw_params); - mutex_unlock(&opened_mutex); return 0; } @@ -175,10 +170,9 @@ static int atmel_ac97c_capture_hw_params(struct snd_pcm_substream *substream, struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); /* Set restrictions to params. */ - mutex_lock(&opened_mutex); + guard(mutex)(&opened_mutex); chip->cur_rate = params_rate(hw_params); chip->cur_format = params_format(hw_params); - mutex_unlock(&opened_mutex); return 0; } @@ -590,7 +584,7 @@ static int atmel_ac97c_pcm_new(struct atmel_ac97c *chip) pcm->private_data = chip; pcm->info_flags = 0; - strcpy(pcm->name, chip->card->shortname); + strscpy(pcm->name, chip->card->shortname); chip->pcm = pcm; return 0; @@ -749,9 +743,9 @@ static int atmel_ac97c_probe(struct platform_device *pdev) spin_lock_init(&chip->lock); - strcpy(card->driver, "Atmel AC97C"); - strcpy(card->shortname, "Atmel AC97C"); - sprintf(card->longname, "Atmel AC97 controller"); + strscpy(card->driver, "Atmel AC97C"); + strscpy(card->shortname, "Atmel AC97C"); + strscpy(card->longname, "Atmel AC97 controller"); chip->card = card; chip->pclk = pclk; @@ -818,7 +812,6 @@ err_prepare_enable: return retval; } -#ifdef CONFIG_PM_SLEEP static int atmel_ac97c_suspend(struct device *pdev) { struct snd_card *card = dev_get_drvdata(pdev); @@ -837,13 +830,9 @@ static int atmel_ac97c_resume(struct device *pdev) return ret; } -static SIMPLE_DEV_PM_OPS(atmel_ac97c_pm, atmel_ac97c_suspend, atmel_ac97c_resume); -#define ATMEL_AC97C_PM_OPS &atmel_ac97c_pm -#else -#define ATMEL_AC97C_PM_OPS NULL -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(atmel_ac97c_pm, atmel_ac97c_suspend, atmel_ac97c_resume); -static int atmel_ac97c_remove(struct platform_device *pdev) +static void atmel_ac97c_remove(struct platform_device *pdev) { struct snd_card *card = platform_get_drvdata(pdev); struct atmel_ac97c *chip = get_chip(card); @@ -858,8 +847,6 @@ static int atmel_ac97c_remove(struct platform_device *pdev) free_irq(chip->irq, chip); snd_card_free(card); - - return 0; } static struct platform_driver atmel_ac97c_driver = { @@ -867,7 +854,7 @@ static struct platform_driver atmel_ac97c_driver = { .remove = atmel_ac97c_remove, .driver = { .name = "atmel_ac97c", - .pm = ATMEL_AC97C_PM_OPS, + .pm = pm_ptr(&atmel_ac97c_pm), .of_match_table = atmel_ac97c_dt_ids, }, }; |
