static DEFINE_MUTEX(io_mutex);
static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq);
+#ifdef CONFIG_DEBUG_FS
+static struct dentry *debugfs_root;
+#endif
+
/*
* This is a timeout to do a DAPM powerdown after a stream is closed().
* It can be used to eliminate pops between different playback streams, e.g.
size_t count, loff_t *ppos)
{
ssize_t ret;
- struct snd_soc_device *devdata = file->private_data;
+ struct snd_soc_codec *codec = file->private_data;
+ struct device *card_dev = codec->card->dev;
+ struct snd_soc_device *devdata = card_dev->driver_data;
char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!buf)
return -ENOMEM;
char *start = buf;
unsigned long reg, value;
int step = 1;
- struct snd_soc_device *devdata = file->private_data;
- struct snd_soc_codec *codec = devdata->codec;
+ struct snd_soc_codec *codec = file->private_data;
buf_size = min(count, (sizeof(buf)-1));
if (copy_from_user(buf, user_buf, buf_size))
.write = codec_reg_write_file,
};
-static void soc_init_debugfs(struct snd_soc_device *socdev)
+static void soc_init_codec_debugfs(struct snd_soc_codec *codec)
{
- struct dentry *root, *file;
- struct snd_soc_codec *codec = socdev->codec;
- root = debugfs_create_dir(dev_name(socdev->dev), NULL);
- if (IS_ERR(root) || !root)
- goto exit1;
-
- file = debugfs_create_file("codec_reg", 0644,
- root, socdev, &codec_reg_fops);
- if (!file)
- goto exit2;
-
- file = debugfs_create_u32("dapm_pop_time", 0744,
- root, &codec->pop_time);
- if (!file)
- goto exit2;
- socdev->debugfs_root = root;
- return;
-exit2:
- debugfs_remove_recursive(root);
-exit1:
- dev_err(socdev->dev, "debugfs is not available\n");
+ codec->debugfs_reg = debugfs_create_file("codec_reg", 0644,
+ debugfs_root, codec,
+ &codec_reg_fops);
+ if (!codec->debugfs_reg)
+ printk(KERN_WARNING
+ "ASoC: Failed to create codec register debugfs file\n");
+
+ codec->debugfs_pop_time = debugfs_create_u32("dapm_pop_time", 0744,
+ debugfs_root,
+ &codec->pop_time);
+ if (!codec->debugfs_pop_time)
+ printk(KERN_WARNING
+ "Failed to create pop time debugfs file\n");
}
-static void soc_cleanup_debugfs(struct snd_soc_device *socdev)
+static void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)
{
- debugfs_remove_recursive(socdev->debugfs_root);
- socdev->debugfs_root = NULL;
+ debugfs_remove(codec->debugfs_pop_time);
+ debugfs_remove(codec->debugfs_reg);
}
#else
-static inline void soc_init_debugfs(struct snd_soc_device *socdev)
+static inline void soc_init_codec_debugfs(struct snd_soc_codec *codec)
{
}
-static inline void soc_cleanup_debugfs(struct snd_soc_device *socdev)
+static inline void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)
{
}
#endif
if (err < 0)
printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
- soc_init_debugfs(socdev);
+ soc_init_codec_debugfs(socdev->codec);
mutex_unlock(&codec->mutex);
out:
#endif
mutex_lock(&codec->mutex);
- soc_cleanup_debugfs(socdev);
+ soc_cleanup_codec_debugfs(socdev->codec);
#ifdef CONFIG_SND_SOC_AC97_BUS
for (i = 0; i < codec->num_dai; i++) {
codec_dai = &codec->dai[i];
static int __devinit snd_soc_init(void)
{
+#ifdef CONFIG_DEBUG_FS
+ debugfs_root = debugfs_create_dir("asoc", NULL);
+ if (IS_ERR(debugfs_root) || !debugfs_root) {
+ printk(KERN_WARNING
+ "ASoC: Failed to create debugfs directory\n");
+ debugfs_root = NULL;
+ }
+#endif
+
return platform_driver_register(&soc_driver);
}
static void __exit snd_soc_exit(void)
{
+#ifdef CONFIG_DEBUG_FS
+ debugfs_remove_recursive(debugfs_root);
+#endif
platform_driver_unregister(&soc_driver);
}