gpio: bcm-kona: fix bcm_kona_gpio_reset() warnings
[linux/fpc-iii.git] / sound / soc / soc-cache.c
blob07f43356f9639c408f025ff37fafdf5f323c06d5
1 /*
2 * soc-cache.c -- ASoC register cache helpers
4 * Copyright 2009 Wolfson Microelectronics PLC.
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
14 #include <sound/soc.h>
15 #include <linux/export.h>
16 #include <linux/slab.h>
18 int snd_soc_cache_init(struct snd_soc_codec *codec)
20 const struct snd_soc_codec_driver *codec_drv = codec->driver;
21 size_t reg_size;
23 reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
25 if (!reg_size)
26 return 0;
28 dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n",
29 codec->component.name);
31 if (codec_drv->reg_cache_default)
32 codec->reg_cache = kmemdup(codec_drv->reg_cache_default,
33 reg_size, GFP_KERNEL);
34 else
35 codec->reg_cache = kzalloc(reg_size, GFP_KERNEL);
36 if (!codec->reg_cache)
37 return -ENOMEM;
39 return 0;
43 * NOTE: keep in mind that this function might be called
44 * multiple times.
46 int snd_soc_cache_exit(struct snd_soc_codec *codec)
48 dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n",
49 codec->component.name);
50 kfree(codec->reg_cache);
51 codec->reg_cache = NULL;
52 return 0;