From patchwork Thu Feb 5 13:48:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 5784731 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 857289F30C for ; Thu, 5 Feb 2015 13:49:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9EFBE202EC for ; Thu, 5 Feb 2015 13:49:28 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 5DB5D202C8 for ; Thu, 5 Feb 2015 13:49:27 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 61434264FDF; Thu, 5 Feb 2015 14:49:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id E9A43264F30; Thu, 5 Feb 2015 14:48:43 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id BD058264EFA; Thu, 5 Feb 2015 14:48:36 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 4FFE9264F10 for ; Thu, 5 Feb 2015 14:48:27 +0100 (CET) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 33F8EACF8 for ; Thu, 5 Feb 2015 13:48:26 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Thu, 5 Feb 2015 14:48:22 +0100 Message-Id: <1423144102-24801-2-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1423144102-24801-1-git-send-email-tiwai@suse.de> References: <1423144102-24801-1-git-send-email-tiwai@suse.de> Subject: [alsa-devel] [PATCH 2/2] ALSA: line6: Create sysfs via snd_card_add_dev_attr() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Use the new helper function to create sysfs entries in the card more gracefully without races. Signed-off-by: Takashi Iwai --- sound/usb/line6/pod.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 61aadd7d4b7f..eb5a23ceac1c 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_attrs); if (err < 0) return err;