/*
 * soc-cache.c  --  ASoC register cache helpers
 *
 * Copyright 2009 Wolfson Microelectronics PLC.
 *
 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
 *
 *  This program is free software; you can redistribute  it and/or modify it
 *  under  the terms of  the GNU General  Public License as published by the
 *  Free Software Foundation;  either version 2 of the  License, or (at your
 *  option) any later version.
 */

#include <sound/soc.h>
#include <linux/export.h>
#include <linux/slab.h>

int snd_soc_cache_init(struct snd_soc_codec *codec)
{
	const struct snd_soc_codec_driver *codec_drv = codec->driver;
	size_t reg_size;

	reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;

	if (!reg_size)
		return 0;

	dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n",
				codec->component.name);

	if (codec_drv->reg_cache_default)
		codec->reg_cache = kmemdup(codec_drv->reg_cache_default,
					   reg_size, GFP_KERNEL);
	else
		codec->reg_cache = kzalloc(reg_size, GFP_KERNEL);
	if (!codec->reg_cache)
		return -ENOMEM;

	return 0;
}

/*
 * NOTE: keep in mind that this function might be called
 * multiple times.
 */
int snd_soc_cache_exit(struct snd_soc_codec *codec)
{
	dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n",
			codec->component.name);
	kfree(codec->reg_cache);
	codec->reg_cache = NULL;
	return 0;
}
td></tr>
<tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/linux/net-next.git/?h=nds-private-remove'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?h=nds-private-remove&amp;id=9538132a9f3cb8ed1590bec2b32650f4d30dd688'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/tools/perf/tests/sdt.c?h=nds-private-remove'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/tools/perf/tests/sdt.c?h=nds-private-remove&amp;id=9538132a9f3cb8ed1590bec2b32650f4d30dd688'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/tools/perf/tests/sdt.c?h=nds-private-remove&amp;id=9538132a9f3cb8ed1590bec2b32650f4d30dd688'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/tools/perf/tests/sdt.c?h=nds-private-remove&amp;id=9538132a9f3cb8ed1590bec2b32650f4d30dd688'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/tools/perf/tests/sdt.c'>
<input type='hidden' name='h' value='nds-private-remove'/><input type='hidden' name='id' value='9538132a9f3cb8ed1590bec2b32650f4d30dd688'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?h=nds-private-remove&amp;id=9538132a9f3cb8ed1590bec2b32650f4d30dd688'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools?h=nds-private-remove&amp;id=9538132a9f3cb8ed1590bec2b32650f4d30dd688'>tools</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools/perf?h=nds-private-remove&amp;id=9538132a9f3cb8ed1590bec2b32650f4d30dd688'>perf</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools/perf/tests?h=nds-private-remove&amp;id=9538132a9f3cb8ed1590bec2b32650f4d30dd688'>tests</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools/perf/tests/sdt.c?h=nds-private-remove&amp;id=9538132a9f3cb8ed1590bec2b32650f4d30dd688'>sdt.c</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/tools/perf/tests/sdt.c?h=nds-private-remove&amp;id=9538132a9f3cb8ed1590bec2b32650f4d30dd688&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>