[alsa-devel] [PATCH] ASoC: Convert DAPM pop time configuration to debugfs
Pop time configuration is a debugging feature which shouldn't be used in normal operation so move it to debugfs where it is clearer. This also simplifies the code since debugfs provides standard facilities for exposing simple integer values to user space.
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com ---
It would be nice to apply this to 2.6.27 since the sysfs file was only added in the 2.6.27 cycle but it's not critical either way.
sound/soc/soc-dapm.c | 53 ++++++++++++++++++------------------------------- 1 files changed, 20 insertions(+), 33 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 7a88f76..c016426 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -38,6 +38,7 @@ #include <linux/bitops.h> #include <linux/platform_device.h> #include <linux/jiffies.h> +#include <linux/debugfs.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -67,7 +68,9 @@ static int dapm_status = 1; module_param(dapm_status, int, 0); MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries");
-static unsigned int pop_time; +static struct dentry *asoc_debugfs; + +static u32 pop_time;
static void pop_wait(void) { @@ -817,51 +820,35 @@ static ssize_t dapm_widget_show(struct device *dev,
static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
-/* pop/click delay times */ -static ssize_t dapm_pop_time_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%d\n", pop_time); -} - -static ssize_t dapm_pop_time_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) - -{ - unsigned long val; - - if (strict_strtoul(buf, 10, &val) >= 0) - pop_time = val; - else - printk(KERN_ERR "Unable to parse pop_time setting\n"); - - return count; -} - -static DEVICE_ATTR(dapm_pop_time, 0744, dapm_pop_time_show, - dapm_pop_time_store); - int snd_soc_dapm_sys_add(struct device *dev) { int ret = 0;
- if (dapm_status) { - ret = device_create_file(dev, &dev_attr_dapm_widget); + if (!dapm_status) + return 0;
- if (ret == 0) - ret = device_create_file(dev, &dev_attr_dapm_pop_time); - } + ret = device_create_file(dev, &dev_attr_dapm_widget); + if (ret != 0) + return ret;
- return ret; + asoc_debugfs = debugfs_create_dir("asoc", NULL); + if (!IS_ERR(asoc_debugfs)) + debugfs_create_u32("dapm_pop_time", 0744, asoc_debugfs, + &pop_time); + else + asoc_debugfs = NULL; + + return 0; }
static void snd_soc_dapm_sys_remove(struct device *dev) { if (dapm_status) { - device_remove_file(dev, &dev_attr_dapm_pop_time); device_remove_file(dev, &dev_attr_dapm_widget); } + + if (asoc_debugfs) + debugfs_remove_recursive(asoc_debugfs); }
/* free all dapm widgets and resources */
At Thu, 28 Aug 2008 12:46:24 +0100, Mark Brown wrote:
Pop time configuration is a debugging feature which shouldn't be used in normal operation so move it to debugfs where it is clearer. This also simplifies the code since debugfs provides standard facilities for exposing simple integer values to user space.
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com
Thanks, applied now.
It would be nice to apply this to 2.6.27 since the sysfs file was only added in the 2.6.27 cycle but it's not critical either way.
I prefer pushing this for 2.6.28 as this is no "bug fix".
Takashi
On Thu, Aug 28, 2008 at 03:07:12PM +0200, Takashi Iwai wrote:
Mark Brown wrote:
It would be nice to apply this to 2.6.27 since the sysfs file was only added in the 2.6.27 cycle but it's not critical either way.
I prefer pushing this for 2.6.28 as this is no "bug fix".
Yeah, it's a bit dubious either way - like you say, it's not a bug fix but if it's not merged for 2.6.27 then we add a new sysfs interface for a single kernel release. But then it's unlikely that anything in user space is going to get upset when it vanishes.
At Thu, 28 Aug 2008 14:14:27 +0100, Mark Brown wrote:
On Thu, Aug 28, 2008 at 03:07:12PM +0200, Takashi Iwai wrote:
Mark Brown wrote:
It would be nice to apply this to 2.6.27 since the sysfs file was only added in the 2.6.27 cycle but it's not critical either way.
I prefer pushing this for 2.6.28 as this is no "bug fix".
Yeah, it's a bit dubious either way - like you say, it's not a bug fix but if it's not merged for 2.6.27 then we add a new sysfs interface for a single kernel release. But then it's unlikely that anything in user space is going to get upset when it vanishes.
Right. If it were a base attribute, we must keep the consistency. But it's a debugging issue after all.
Takashi
participants (3)
-
Mark Brown
-
Mark Brown
-
Takashi Iwai