.open = codec_reg_open_file,
.read = codec_reg_read_file,
.write = codec_reg_write_file,
+ .llseek = default_llseek,
};
static void soc_init_codec_debugfs(struct snd_soc_codec *codec)
size_t count, loff_t *ppos)
{
char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- ssize_t ret = 0;
+ ssize_t len, ret = 0;
struct snd_soc_codec *codec;
if (!buf)
return -ENOMEM;
- list_for_each_entry(codec, &codec_list, list)
- ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
- codec->name);
+ list_for_each_entry(codec, &codec_list, list) {
+ len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
+ codec->name);
+ if (len >= 0)
+ ret += len;
+ if (ret > PAGE_SIZE) {
+ ret = PAGE_SIZE;
+ break;
+ }
+ }
if (ret >= 0)
ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
size_t count, loff_t *ppos)
{
char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- ssize_t ret = 0;
+ ssize_t len, ret = 0;
struct snd_soc_dai *dai;
if (!buf)
return -ENOMEM;
- list_for_each_entry(dai, &dai_list, list)
- ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", dai->name);
+ list_for_each_entry(dai, &dai_list, list) {
+ len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", dai->name);
+ if (len >= 0)
+ ret += len;
+ if (ret > PAGE_SIZE) {
+ ret = PAGE_SIZE;
+ break;
+ }
+ }
- if (ret >= 0)
- ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+ ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
kfree(buf);
size_t count, loff_t *ppos)
{
char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- ssize_t ret = 0;
+ ssize_t len, ret = 0;
struct snd_soc_platform *platform;
if (!buf)
return -ENOMEM;
- list_for_each_entry(platform, &platform_list, list)
- ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
- platform->name);
+ list_for_each_entry(platform, &platform_list, list) {
+ len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
+ platform->name);
+ if (len >= 0)
+ ret += len;
+ if (ret > PAGE_SIZE) {
+ ret = PAGE_SIZE;
+ break;
+ }
+ }
- if (ret >= 0)
- ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+ ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
kfree(buf);
char tmp[NAME_SIZE];
/* create unique ID number from I2C addr and bus */
- *id = ((id1 && 0xffff) << 16) + id2;
+ *id = ((id1 & 0xffff) << 16) + id2;
/* sanitize component name for DAI link creation */
snprintf(tmp, NAME_SIZE, "%s.%s", dev->driver->name, name);
}
dai->dev = dev;
- dai->id = i;
dai->driver = &dai_drv[i];
+ if (dai->driver->id)
+ dai->id = dai->driver->id;
+ else
+ dai->id = i;
if (!dai->driver->ops)
dai->driver->ops = &null_dai_ops;
if (codec->reg_cache)
kfree(codec->reg_cache);
+ kfree(codec->name);
kfree(codec);
}
EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);