Received: by 10.192.165.148 with SMTP id m20csp213444imm; Thu, 3 May 2018 18:26:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZremwEod+eOFvfQUK+c2f6UAinw13fT5GNNs7nZYvCn8Bp4hkmLQnDAsUTNyn/EbsgMH+76 X-Received: by 2002:a17:902:b591:: with SMTP id a17-v6mr25641780pls.211.1525397207869; Thu, 03 May 2018 18:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525397207; cv=none; d=google.com; s=arc-20160816; b=LzX50HqO8iGdBvwR+bSydYjj3iKuIh3vXefcHjgLlPG487mzdhGiFC7ZgwDxVqLAx3 6r9xi58edvrORkH7PeMjnNtuB89M5Ha3vZUz4EZDa7oh2kt3YS49nZj7WYNEDD8Ce71I fOrMXU5dO/yue3i56PJ4TgCtbH0dFReVdmkqvsDUl8N6fyi8EUHoPcV4qUGiPqU6NX/0 tAuZ4iA/a9N/G9LyZcvBHxVB9okUGRDku5JmI47qARWEZFmB9yy2ExFIBhnvSeGmvYZ7 no220jRr+69JTwRpIXtpl3m1e1UobI2qf3Box2cepNElhExfrEOXLqAfofI0h7n1V2cv JKMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=IkAV/g06nKHDES3Kl6nDKkX6xhhNRF4ilUnc9thOxE0=; b=TSoi3Qjuv9/VTveRI15xJtbphr7w/RcI8zYgYKnzf8DfBe3cpA8SO2pKmUCRe6ClOE z+qu1BQq+ic+ajHSaTuJwgWL4MuFw7MnicUJH+f6WNWltHkBfPNpzqROgmXxpoql89yX yZF/bOCV5NHi3z/9k6hQkBG4k4PXYUdcUcCXAaXYvAuz8k7tCy1Pi2USV4ztw3ERJ5KS VjGM2scB4wa/TQ6OAou2wHbEtSawcDB14Lm0PD+q37T0f0BxWqNNzvyi/fcp/aNPVSxe oSIONO5skITnOieqBElgvI8RhrT2GsLubIdELc2mE0jCZJmVRKVxVsAkk3FwJKIkwyYl 8kvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CWq/mofz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e66-v6si14582033plb.499.2018.05.03.18.26.33; Thu, 03 May 2018 18:26:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CWq/mofz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751605AbeEDBZH (ORCPT + 99 others); Thu, 3 May 2018 21:25:07 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:42229 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751477AbeEDBZB (ORCPT ); Thu, 3 May 2018 21:25:01 -0400 Received: by mail-lf0-f65.google.com with SMTP id u21-v6so28646790lfu.9 for ; Thu, 03 May 2018 18:25:00 -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=GaOh5uS8/QhygyaekryFQjNisIKAJuZ36E7Kp2dHNt1/IEd0wDdzepk8E3Rl+cJr00 DcXjTlW3kiIXifLxw1AMDGm6OvCQBliz5iGvGeeMzh+/8z0kYwu/KK8A3kfoPIUiGEto HJ/PMgDGt8giaEZzl18wUxWgYuWl4p2UN0a7gDUPNrnITtYn3MUE7SIzlsZvFNC8DULB kdtTh6w9/qzqp/pvDOC/apxaYC0p1ggMtxjUO51gWf0J4b9pGAF47LCQ2Oo7APpHZAaf 5pxfKwzBxcjpEfiQq11sR/nOWo1Xbq4wnZfSshoTp4mGlcFtjJ/X6aS0GxSoBTVW0H2r gAxA== X-Gm-Message-State: ALQs6tBYqsXsOggwI+jYiDEwq0onhzBimc1HHiEfbQ97CWmpkrlSJb1e /Q8oAXIlP/xZ70Xae5oBLz8= 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 Cc: Jorge , Andrew Chant , Greg Kroah-Hartman , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/7] ALSA: usb: mixer: make string parsing independent of mixer_build state 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 1.9.1