From patchwork Fri May 4 01:24:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruslan Bilovol X-Patchwork-Id: 10379619 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 081D360327 for ; Fri, 4 May 2018 01:32:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA7F6292E3 for ; Fri, 4 May 2018 01:32:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF4E6292E6; Fri, 4 May 2018 01:32:35 +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=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable 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 3BB4B292E5 for ; Fri, 4 May 2018 01:32:32 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5627D267634; Fri, 4 May 2018 03:25:16 +0200 (CEST) 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 152E326760F; Fri, 4 May 2018 03:25:03 +0200 (CEST) Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by alsa0.perex.cz (Postfix) with ESMTP id 119702675DF for ; Fri, 4 May 2018 03:24:59 +0200 (CEST) Received: by mail-lf0-f67.google.com with SMTP id y72-v6so14901756lfd.2 for ; Thu, 03 May 2018 18:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IkAV/g06nKHDES3Kl6nDKkX6xhhNRF4ilUnc9thOxE0=; b=CWq/mofzNH6E/fea9CurpzPQDbQO7bAdSBuY9IZ7UkpQixrS8nM/pIpIjdioQlLLgI dI9LmwKpkjbnDZnkQN+wi8c+lK0dLMmKkn2xdbbKaMBw3oYy1XlM9yXCiEzV76W5Fld3 3qge9SvmZ+VVRTBYur5uhk2hv5rcNsy5PFTbdi6srONykAXDQ9Ndmb7cXu4aZDkYkzLY A13rvj92xn+hiiKWwvdSz321u+KlnQWjjwTnnBSF//Qa4p204ePQr3DkWyH9FIhJ8xXa bmZXwYE/VODPS57bZ+XzHgDJHP+8by4hfLB85ZUrev2PMGX/jAXxhzh2vf3mvZzthdn1 dGng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IkAV/g06nKHDES3Kl6nDKkX6xhhNRF4ilUnc9thOxE0=; b=e6NEVf1Usn7nvITi2rqbgV/UhflwgOSrIgZB+xg8/JIcckWev2NRJFqSUqOs4uVItP inzu2/A2qqv81xYA0TnbcFv7HYjpViGcY+58b5pO/uAf5SxqBjwXd4qlBf7P7gcnFTUp Qyl7lzikUuNSoHMoSWha5kUUiq3iEGEI22BXVpinPxllBEhpFd9t9Ockr1/yq7WWnrIM U71AXV5NgRSUxzoUlVkzMwCSAinMQXauGMcnyuf8ko2caNcWvOSuz4l4Eq57I1SscUSj xgD3RAhiJ9zDh9mONHQSDBStp27R11gkEtzgpepUIIAqPVUPsrFgJm3mEkpPnvK0rRa2 w9kA== X-Gm-Message-State: ALQs6tCsUVZmNTijcugF7KO1bcJ8JvdoGGeYxABbaY+4ekcowWLJFFgQ 29d/SmRo5wwf8RNka6rIZ8E= X-Google-Smtp-Source: AB8JxZqErZNgJNgn3akIVMqmlTeHKmIis45FOqrPqS7IaNG6+sUEUvW2nD+ecvzs2fCsM+AOflE76g== X-Received: by 2002:a19:d491:: with SMTP id l139-v6mr15180846lfg.130.1525397099509; Thu, 03 May 2018 18:24:59 -0700 (PDT) Received: from localhost ([62.216.57.27]) by smtp.gmail.com with ESMTPSA id n76-v6sm3006909lja.31.2018.05.03.18.24.58 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 03 May 2018 18:24:58 -0700 (PDT) From: Ruslan Bilovol To: Takashi Iwai Date: Fri, 4 May 2018 04:24:02 +0300 Message-Id: <1525397044-15080-6-git-send-email-ruslan.bilovol@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525397044-15080-1-git-send-email-ruslan.bilovol@gmail.com> References: <1525397044-15080-1-git-send-email-ruslan.bilovol@gmail.com> Cc: Jorge , alsa-devel@alsa-project.org, Andrew Chant , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [alsa-devel] [PATCH v2 5/7] ALSA: usb: mixer: make string parsing independent of mixer_build state 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 Functions like snd_usb_copy_string_desc() or get_term_name() don't actually need mixer_build state but can use snd_usb_audio structure instead to get usb device. This patch has no functional change but prepares to future UAC3 BADD profiles support which don't have class-specific descriptors so won't have mixer_build state. Signed-off-by: Ruslan Bilovol --- sound/usb/mixer.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index bb203b3..e280354 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -201,10 +201,10 @@ static void *find_audio_control_unit(struct mixer_build *state, /* * copy a string with the given id */ -static int snd_usb_copy_string_desc(struct mixer_build *state, +static int snd_usb_copy_string_desc(struct snd_usb_audio *chip, int index, char *buf, int maxlen) { - int len = usb_string(state->chip->dev, index, buf, maxlen - 1); + int len = usb_string(chip->dev, index, buf, maxlen - 1); if (len < 0) return 0; @@ -658,14 +658,14 @@ int snd_usb_mixer_add_control(struct usb_mixer_elem_list *list, { 0 }, }; -static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm, +static int get_term_name(struct snd_usb_audio *chip, struct usb_audio_term *iterm, unsigned char *name, int maxlen, int term_only) { struct iterm_name_combo *names; int len; if (iterm->name) { - len = snd_usb_copy_string_desc(state, iterm->name, + len = snd_usb_copy_string_desc(chip, iterm->name, name, maxlen); if (len) return len; @@ -1407,7 +1407,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); mapped_name = len != 0; if (!len && nameid) - len = snd_usb_copy_string_desc(state, nameid, + len = snd_usb_copy_string_desc(state->chip, nameid, kctl->id.name, sizeof(kctl->id.name)); switch (control) { @@ -1422,10 +1422,10 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, * - otherwise, anonymous name. */ if (!len) { - len = get_term_name(state, iterm, kctl->id.name, + len = get_term_name(state->chip, iterm, kctl->id.name, sizeof(kctl->id.name), 1); if (!len) - len = get_term_name(state, &state->oterm, + len = get_term_name(state->chip, &state->oterm, kctl->id.name, sizeof(kctl->id.name), 1); if (!len) @@ -1498,7 +1498,7 @@ static void get_connector_control_name(struct mixer_build *state, struct usb_audio_term *term, bool is_input, char *name, int name_size) { - int name_len = get_term_name(state, term, name, name_size, 0); + int name_len = get_term_name(state->chip, term, name, name_size, 0); if (name_len == 0) strlcpy(name, "Unknown", name_size); @@ -1597,7 +1597,7 @@ static int parse_clock_source_unit(struct mixer_build *state, int unitid, } kctl->private_free = snd_usb_mixer_elem_free; - ret = snd_usb_copy_string_desc(state, hdr->iClockSource, + ret = snd_usb_copy_string_desc(state->chip, hdr->iClockSource, name, sizeof(name)); if (ret > 0) snprintf(kctl->id.name, sizeof(kctl->id.name), @@ -1840,7 +1840,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state, len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); if (!len) - len = get_term_name(state, iterm, kctl->id.name, + len = get_term_name(state->chip, iterm, kctl->id.name, sizeof(kctl->id.name), 0); if (!len) len = sprintf(kctl->id.name, "Mixer Source %d", in_ch + 1); @@ -2154,7 +2154,8 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, nameid = uac_processing_unit_iProcessing(desc, state->mixer->protocol); len = 0; if (nameid) - len = snd_usb_copy_string_desc(state, nameid, + len = snd_usb_copy_string_desc(state->chip, + nameid, kctl->id.name, sizeof(kctl->id.name)); if (!len) @@ -2350,7 +2351,8 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, len = check_mapped_selector_name(state, unitid, i, namelist[i], MAX_ITEM_NAME_LEN); if (! len && check_input_term(state, desc->baSourceID[i], &iterm) >= 0) - len = get_term_name(state, &iterm, namelist[i], MAX_ITEM_NAME_LEN, 0); + len = get_term_name(state->chip, &iterm, namelist[i], + MAX_ITEM_NAME_LEN, 0); if (! len) sprintf(namelist[i], "Input %u", i); } @@ -2372,12 +2374,12 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, /* if iSelector is given, use it */ nameid = uac_selector_unit_iSelector(desc); if (nameid) - len = snd_usb_copy_string_desc(state, nameid, + len = snd_usb_copy_string_desc(state->chip, nameid, kctl->id.name, sizeof(kctl->id.name)); /* ... or pick up the terminal name at next */ if (!len) - len = get_term_name(state, &state->oterm, + len = get_term_name(state->chip, &state->oterm, kctl->id.name, sizeof(kctl->id.name), 0); /* ... or use the fixed string "USB" as the last resort */ if (!len)