ALSA: Create sysfs attribute files via groups
Instead of calling each time device_create_file(), create the groups
of sysfs attribute files at once in a normal way. Add a new helper
function, snd_get_device(), to return the associated device object,
so that we can handle the sysfs addition locally.
Since the sysfs file addition is done differently now,
snd_add_device_sysfs_file() helper function is removed.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 8c77865..99f7e85 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -436,6 +436,20 @@
mutex_unlock(®ister_mutex);
return err;
}
+
+ if (hwdep->groups) {
+ struct device *d = snd_get_device(SNDRV_DEVICE_TYPE_HWDEP,
+ hwdep->card, hwdep->device);
+ if (d) {
+ err = sysfs_create_groups(&d->kobj, hwdep->groups);
+ if (err < 0)
+ dev_warn(card->dev,
+ "hwdep %d:%d: cannot create sysfs groups\n",
+ card->number, hwdep->device);
+ put_device(d);
+ }
+ }
+
#ifdef CONFIG_SND_OSSEMUL
hwdep->ossreg = 0;
if (hwdep->oss_type >= 0) {