From patchwork Sat Nov 19 12:01:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrej Krutak X-Patchwork-Id: 9438117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 121CA60237 for ; Sat, 19 Nov 2016 12:04:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2E4A279D1 for ; Sat, 19 Nov 2016 12:04:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7F1E29339; Sat, 19 Nov 2016 12:04:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A2DE279D1 for ; Sat, 19 Nov 2016 12:04:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8C479266AD1; Sat, 19 Nov 2016 13:04:22 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8E46726658E; Sat, 19 Nov 2016 13:02:00 +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 32A8A2668A2; Sat, 19 Nov 2016 13:01:51 +0100 (CET) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by alsa0.perex.cz (Postfix) with ESMTP id E5E3A26658E for ; Sat, 19 Nov 2016 13:01:45 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id g23so12688415wme.1 for ; Sat, 19 Nov 2016 04:01:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=u+n4lmViYzJ3THGu7IL3qcOopu0IjZnPBvdlpgHJAjE=; b=Z3vO8kIb1+ybLkXQh4jgWW0yMV//C8rib+bdWsKA7CF9OetdAZLe8UWYEv3PbuM61G IlcVIRyIU8epdyGzSuVRrTcDPOb4X0uLBW6PVcW9sNxa0Vfj8LKxsJJx4xfIbg2NSkt2 3SKWrZhC09opsttWSdWsbNDs+pg4TIS8hGrANkkVY9fSnUuFiaAO2yQJ7sB1waf57M1b XBgzzE7ZjfxQtz1RQR1o00efEIltUvL3ayU4brkn08ejhWqzYIbo53SvKCmq5y9yLRFb jhfZzoT3LQkcEPKlxQCr/IL44TLneHKTtRHDGoeXPfJmOYWn7j1YVuleOoYluj2nfX1w uKkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=u+n4lmViYzJ3THGu7IL3qcOopu0IjZnPBvdlpgHJAjE=; b=YHfgGiZzJiAG3YLeuNRHZQMUCSLre2hrLIM/5/uWTHU03EcSqf8VnYbQKfcaVDFYQg EBrPIcOv71ekiy4pgm6Fcl8MuVAqz/+RRJr+BSWLy7WGCk30WotKf8n3yxHUsgilWXPe aLo2wvW413u4zHJRXhQ2izEG4yNAJedBFJp1VQd1EmtmLXzJv8NYterm1aVXIGA2rD3X fwYE3CzUugKEfzxX2SyDoCDHkiS6qj6ajuNNP+KXlUN0RZ74jTUCv0QlukEgJU1fIlNR RHoIqz9Rqj348g+p05eDkwul1hvKubT3c4vI9iMJpg0V6So+IYCbKpy3ggzXKCjU5a/J WKJg== X-Gm-Message-State: AKaTC00QupprxVkzniChckVOdMhdgOeMfw5azlaBQz9Z9+jNi+RAC3fUDOJ2F2cjhCGPdg== X-Received: by 10.194.222.169 with SMTP id qn9mr2699692wjc.62.1479556904714; Sat, 19 Nov 2016 04:01:44 -0800 (PST) Received: from andree.lan ([217.30.74.231]) by smtp.gmail.com with ESMTPSA id c81sm8382442wmf.22.2016.11.19.04.01.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 19 Nov 2016 04:01:43 -0800 (PST) From: Andrej Krutak To: tiwai@suse.com, perex@perex.cz, stefanha@gmail.com, grabner@icg.tugraz.at, alsa-devel@alsa-project.org Date: Sat, 19 Nov 2016 13:01:29 +0100 Message-Id: <1479556889-17601-1-git-send-email-dev@andree.sk> X-Mailer: git-send-email 1.9.1 Cc: Andrej Krutak Subject: [alsa-devel] [PATCH] ALSA: line6: Claim POD X3 USB data interface 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 Deny userspace from using the interface concurrently. Signed-off-by: Andrej Krutak --- sound/usb/line6/driver.h | 1 + sound/usb/line6/podhd.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index 7e3a3aa..5d18957 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -98,6 +98,7 @@ struct line6_properties { int altsetting; + unsigned ctrl_if; unsigned ep_ctrl_r; unsigned ep_ctrl_w; unsigned ep_audio_r; diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 49cd4a6..6c53b87 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -153,6 +153,7 @@ struct usb_line6_podhd { .rats = &podhd_ratden}, .bytes_per_channel = 3 /* SNDRV_PCM_FMTBIT_S24_3LE */ }; +static struct usb_driver podhd_driver; static void podhd_startup_start_workqueue(unsigned long data); static void podhd_startup_workqueue(struct work_struct *work); @@ -291,8 +292,13 @@ static void podhd_disconnect(struct usb_line6 *line6) struct usb_line6_podhd *pod = (struct usb_line6_podhd *)line6; if (pod->line6.properties->capabilities & LINE6_CAP_CONTROL) { + struct usb_interface *intf; + del_timer_sync(&pod->startup_timer); cancel_work_sync(&pod->startup_work); + + intf = usb_ifnum_to_if(line6->usbdev, pod->line6.properties->ctrl_if); + usb_driver_release_interface(&podhd_driver, intf); } } @@ -304,10 +310,26 @@ static int podhd_init(struct usb_line6 *line6, { int err; struct usb_line6_podhd *pod = (struct usb_line6_podhd *) line6; + struct usb_interface *intf; line6->disconnect = podhd_disconnect; if (pod->line6.properties->capabilities & LINE6_CAP_CONTROL) { + /* claim the data interface */ + intf = usb_ifnum_to_if(line6->usbdev, pod->line6.properties->ctrl_if); + if (!intf) { + dev_err(pod->line6.ifcdev, "interface %d not found\n", + pod->line6.properties->ctrl_if); + return -ENODEV; + } + + err = usb_driver_claim_interface(&podhd_driver, intf, NULL); + if (err != 0) { + dev_err(pod->line6.ifcdev, "can't claim interface %d, error %d\n", + pod->line6.properties->ctrl_if, err); + return err; + } + /* create sysfs entries: */ err = snd_card_add_dev_attr(line6->card, &podhd_dev_attr_group); if (err < 0) @@ -406,6 +428,7 @@ static int podhd_init(struct usb_line6 *line6, .altsetting = 1, .ep_ctrl_r = 0x81, .ep_ctrl_w = 0x01, + .ctrl_if = 1, .ep_audio_r = 0x86, .ep_audio_w = 0x02, }, @@ -417,6 +440,7 @@ static int podhd_init(struct usb_line6 *line6, .altsetting = 1, .ep_ctrl_r = 0x81, .ep_ctrl_w = 0x01, + .ctrl_if = 1, .ep_audio_r = 0x86, .ep_audio_w = 0x02, },