summaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-01-30 12:36:17 +0100
committerTakashi Iwai <tiwai@suse.de>2015-02-06 10:09:23 +0100
commit02fc76f6a7dbc6cdc3613957f5f1ed435eab5959 (patch)
tree7cbdd4d5f63f7229c0ba8ed227638caa02134fbe /sound/usb
parentALSA: Add a helper to add a new attribute group to card (diff)
downloadlinux-02fc76f6a7dbc6cdc3613957f5f1ed435eab5959.tar.xz
linux-02fc76f6a7dbc6cdc3613957f5f1ed435eab5959.zip
ALSA: line6: Create sysfs via snd_card_add_dev_attr()
Use the new helper function to create sysfs entries in the card more gracefully without races. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/line6/pod.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c
index 61aadd7d4b7f..69aa3c42d5e8 100644
--- a/sound/usb/line6/pod.c
+++ b/sound/usb/line6/pod.c
@@ -330,6 +330,18 @@ static DEVICE_ATTR_RO(device_id);
static DEVICE_ATTR_RO(firmware_version);
static DEVICE_ATTR_RO(serial_number);
+static struct attribute *pod_dev_attrs[] = {
+ &dev_attr_device_id.attr,
+ &dev_attr_firmware_version.attr,
+ &dev_attr_serial_number.attr,
+ NULL
+};
+
+static const struct attribute_group pod_dev_attr_group = {
+ .name = "pod",
+ .attrs = pod_dev_attrs,
+};
+
/* control info callback */
static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
@@ -387,35 +399,11 @@ static void line6_pod_disconnect(struct usb_line6 *line6)
struct usb_line6_pod *pod = (struct usb_line6_pod *)line6;
struct device *dev = line6->ifcdev;
- /* remove sysfs entries: */
- device_remove_file(dev, &dev_attr_device_id);
- device_remove_file(dev, &dev_attr_firmware_version);
- device_remove_file(dev, &dev_attr_serial_number);
-
del_timer_sync(&pod->startup_timer);
cancel_work_sync(&pod->startup_work);
}
/*
- Create sysfs entries.
-*/
-static int pod_create_files2(struct device *dev)
-{
- int err;
-
- err = device_create_file(dev, &dev_attr_device_id);
- if (err < 0)
- return err;
- err = device_create_file(dev, &dev_attr_firmware_version);
- if (err < 0)
- return err;
- err = device_create_file(dev, &dev_attr_serial_number);
- if (err < 0)
- return err;
- return 0;
-}
-
-/*
Try to init POD device.
*/
static int pod_init(struct usb_line6 *line6,
@@ -431,7 +419,7 @@ static int pod_init(struct usb_line6 *line6,
INIT_WORK(&pod->startup_work, pod_startup4);
/* create sysfs entries: */
- err = pod_create_files2(line6->ifcdev);
+ err = snd_card_add_dev_attr(line6->card, &pod_dev_attr_group);
if (err < 0)
return err;