aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-01-30 06:36:17 -0500
committerTakashi Iwai <tiwai@suse.de>2015-02-06 04:09:23 -0500
commit02fc76f6a7dbc6cdc3613957f5f1ed435eab5959 (patch)
tree7cbdd4d5f63f7229c0ba8ed227638caa02134fbe /sound/usb
parent6bbc7fed849597ec35ffdcaf677910dd11d71d08 (diff)
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);
330static DEVICE_ATTR_RO(firmware_version); 330static DEVICE_ATTR_RO(firmware_version);
331static DEVICE_ATTR_RO(serial_number); 331static DEVICE_ATTR_RO(serial_number);
332 332
333static struct attribute *pod_dev_attrs[] = {
334 &dev_attr_device_id.attr,
335 &dev_attr_firmware_version.attr,
336 &dev_attr_serial_number.attr,
337 NULL
338};
339
340static const struct attribute_group pod_dev_attr_group = {
341 .name = "pod",
342 .attrs = pod_dev_attrs,
343};
344
333/* control info callback */ 345/* control info callback */
334static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol, 346static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol,
335 struct snd_ctl_elem_info *uinfo) 347 struct snd_ctl_elem_info *uinfo)
@@ -387,35 +399,11 @@ static void line6_pod_disconnect(struct usb_line6 *line6)
387 struct usb_line6_pod *pod = (struct usb_line6_pod *)line6; 399 struct usb_line6_pod *pod = (struct usb_line6_pod *)line6;
388 struct device *dev = line6->ifcdev; 400 struct device *dev = line6->ifcdev;
389 401
390 /* remove sysfs entries: */
391 device_remove_file(dev, &dev_attr_device_id);
392 device_remove_file(dev, &dev_attr_firmware_version);
393 device_remove_file(dev, &dev_attr_serial_number);
394
395 del_timer_sync(&pod->startup_timer); 402 del_timer_sync(&pod->startup_timer);
396 cancel_work_sync(&pod->startup_work); 403 cancel_work_sync(&pod->startup_work);
397} 404}
398 405
399/* 406/*
400 Create sysfs entries.
401*/
402static int pod_create_files2(struct device *dev)
403{
404 int err;
405
406 err = device_create_file(dev, &dev_attr_device_id);
407 if (err < 0)
408 return err;
409 err = device_create_file(dev, &dev_attr_firmware_version);
410 if (err < 0)
411 return err;
412 err = device_create_file(dev, &dev_attr_serial_number);
413 if (err < 0)
414 return err;
415 return 0;
416}
417
418/*
419 Try to init POD device. 407 Try to init POD device.
420*/ 408*/
421static int pod_init(struct usb_line6 *line6, 409static int pod_init(struct usb_line6 *line6,
@@ -431,7 +419,7 @@ static int pod_init(struct usb_line6 *line6,
431 INIT_WORK(&pod->startup_work, pod_startup4); 419 INIT_WORK(&pod->startup_work, pod_startup4);
432 420
433 /* create sysfs entries: */ 421 /* create sysfs entries: */
434 err = pod_create_files2(line6->ifcdev); 422 err = snd_card_add_dev_attr(line6->card, &pod_dev_attr_group);
435 if (err < 0) 423 if (err < 0)
436 return err; 424 return err;
437 425