Skip to contentSkip to conversation

ASoC: Add sysfs entries via static attribute groups

PATCH Applied Takashi Iwai 2 participants 2 messages Jan 30, 2015 – Feb 2, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ASoC: Add sysfs entries via static attribute groups

Instead of calling device_create_file() manually, assign the static attribute group entries at the device registration. This simplifies the error handling and avoids the possible races.

---
v1->v2: Enable attributes conditionally via is_visible callback

 include/sound/soc-dapm.h |  2 +-
 sound/soc/soc-core.c     | 58 ++++++++++++++++++++++++++++--------------------
 sound/soc/soc-dapm.c     | 14 ++++--------
 3 files changed, 39 insertions(+), 35 deletions(-)
include/sound/soc-dapm.h +1 -1
index 89823cfe6f04..e8e0220404d4 100644
@@ -405,7 +405,7 @@ int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm,
 		struct snd_soc_dapm_update *update);
 
 /* dapm sys fs - used by the core */
-int snd_soc_dapm_sys_add(struct device *dev);
+extern struct attribute *soc_dapm_dev_attrs[];
 void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
 				struct dentry *parent);
 
sound/soc/soc-core.c +34 -24

88 lines not on this page · raw message

sound/soc/soc-dapm.c +4 -10
index c5136bb1f982..6c5cf7d1ff54 100644
@@ -2127,15 +2127,10 @@ static ssize_t dapm_widget_show(struct device *dev,
 
 static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
 
-int snd_soc_dapm_sys_add(struct device *dev)
-{
-	return device_create_file(dev, &dev_attr_dapm_widget);
-}
-
-static void snd_soc_dapm_sys_remove(struct device *dev)
-{
-	device_remove_file(dev, &dev_attr_dapm_widget);
-}
+struct attribute *soc_dapm_dev_attrs[] = {
+	&dev_attr_dapm_widget.attr,
+	NULL
+};
 
 static void dapm_free_path(struct snd_soc_dapm_path *path)
 {
@@ -3903,7 +3898,6 @@ void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card)
  */
 void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm)
 {
-	snd_soc_dapm_sys_remove(dapm->dev);
 	dapm_debugfs_cleanup(dapm);
 	dapm_free_widgets(dapm);
 	list_del(&dapm->list);
Signature · 1 line
2.2.2
maintainer Applied
#1 lore raw
Quoted 3 lines · Takashi Iwai

Instead of calling device_create_file() manually, assign the static attribute group entries at the device registration. This simplifies the error handling and avoids the possible races.

Applied, thanks.