Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3370869rdb; Tue, 6 Feb 2024 16:09:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBMigk+xzW1Zg98G3RGNP5YrGn/uvGyY5NVUW2UstJaY9/5bf9zXE6pbcONJ/zMiqcMWgR X-Received: by 2002:a05:6a00:4b50:b0:6e0:45f5:3ebd with SMTP id kr16-20020a056a004b5000b006e045f53ebdmr1142114pfb.9.1707264586115; Tue, 06 Feb 2024 16:09:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707264586; cv=pass; d=google.com; s=arc-20160816; b=I/Z7Nkm3tZFB4HEcbAAGmARDDmYTVLQoTTDyMg2VRr2wfe74jIWNhgXmTap8Va5MzR rg5QT4oyF9Mp7RB9+XG1R5gI4tLFKVj1HEgVRRG8+19Eekqu9I5sLpS2iK3o2xNbhrx4 bfT94kZ+XkbiFcpa9Awvt/UQK+cyYJvQFdBuH55XP6/Gchtx/bHJGRgSkfti5AHkSXxL ShgfJ1J3v+4I96ZCrSOuN6P+4AcK4f7XFTcXPLtbxC+2Edm7UsSIFRG/+wZk247W+Oth e088yZ+KvfkiUflKIVQc7wxC5hkTdABgZX8L8rqmM9S9o8pb2KHpznBAAP7WydmExy6O MYEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Br0O+jemYZqsYtS1SyNg5WN/92FNWZLdy8IQgi7FiCE=; fh=YAoqlOGIMsO1pH7bE5wAV/6yiZKG4NZP2q5RyLVrVEk=; b=qley57hiKD+3OuB77rXQoSLRVubyYkFMlHjGooDyYvdjU5DOPA6AgY+UffmJ3jXjkF 3stj/K/Yse0spaSUrEx2MU8h1u4CUEoeNc1L+zFRxYIf3LwALa50Uj5Lppxk2cWg6TXd D71fq/HQLH8WvptxfzNohE0iV0KbubZf4ms4lBnzBuz4SntXUu7FYc/v2gpUNhR8snIL eyFjDBtYvQuexW0/5dNoWTABWctSbEQHDGqtGrzF9C2Zs5vQKI9je2zToC1UgoF56wG7 QBe54mX7AAb1IF7X1TOYiMHTwLvElFbdbxM0iGMOO4Jqe1yLXWMZ7Hbwrem12ZKcrPtD sruw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EAVvHDP6; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-55754-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55754-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCW9z2hbJIvVatCXULustXq4oz15xZVithXYJRPZUuuNl7cSlUWeeYr71+kAWMhzSpeJiGS5RBT53bVRGoB8FP35YUVM+OeD32oqDOEj3Q== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e23-20020a656797000000b005d6787271aesi103197pgr.237.2024.02.06.16.09.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 16:09:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55754-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EAVvHDP6; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-55754-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55754-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C10012824CF for ; Wed, 7 Feb 2024 00:09:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EBCF3FEC; Wed, 7 Feb 2024 00:08:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="EAVvHDP6" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 918C3DDA7; Wed, 7 Feb 2024 00:08:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707264536; cv=none; b=Z25bdH2waPyoqu+fxqpNJVgSd03xrt25IiF2rh1g4sj08mKn7mEWaScZJsNdDnd9b7AppPOYlHkpTOQOI7nEqhAe4Z6OyCrUjeWREewQNOfQRWhO1I8J47r0WDfPR6ef/ijgz3yk6LJMUKATp7xX4Y1eGaATxfxQdD78RbyEvJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707264536; c=relaxed/simple; bh=g1wkrCHZJPUJiczeRtLCyl0OxKSBFtJD7ZdL0Innc3A=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=X43a/33vqNiotYWI91xWTgCPLit/JotLVASVeSWWKeYchhp1otLaIl6hRN5E0Frpl0nWdZ8/c1S5dfK/QavQbAty+HPmmQehgmlETlQ2JLF65xGi/stnnmxW0012crQ8q6XFuYP7HbYuYqQx38kEYpHtvloKDsBN51cLJOqP3s8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=EAVvHDP6; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 416N3por015273; Wed, 7 Feb 2024 00:08:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=Br0O+jemYZqsYtS1SyNg5WN/92FNWZLdy8IQgi7FiCE=; b=EA VvHDP67eE8M5AXnA7zoxlhD6DH7oYiEWpyHgK8vgzv6UrRxMbG9AvhWPGCn4ZK3e GxI/p/main661p0/ik89OTPjkAnfXjkOiPrjHS8HdvgTxtaOMp+5x2zTYyI6v1XX RJ7JLmtFfCN8g9lwQ5R3DJZ873X4GW0rYwAlh9m4mVSEhPZHPldo/rTl+cllRI+K kMg6qQangFv4O8m6Enl1SuCQf5v5WrhrPx44BW9f2tpynoJy3b6Iimm7hVEqoUqX Cc8t+seSUb/BtSVfXrl0oN/cwFvUhFTQ+MJWYABWnuOSiZMneenGt+dQCQVWEpQK tIQajXN7MpkBSn4wvlOQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w3hyvhtqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Feb 2024 00:08:38 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41708bRo007736 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 7 Feb 2024 00:08:37 GMT Received: from [10.110.7.251] (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 6 Feb 2024 16:08:36 -0800 Message-ID: <75f8962c-192b-b7a4-1eae-35d8c46a7d74@quicinc.com> Date: Tue, 6 Feb 2024 16:08:36 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v13 32/53] ALSA: usb-audio: Check for support for requested audio format Content-Language: en-US To: Takashi Iwai CC: , , , , , , , , , , , , , , , , , , , , , References: <20240203023645.31105-1-quic_wcheng@quicinc.com> <20240203023645.31105-33-quic_wcheng@quicinc.com> <87wmrhvir7.wl-tiwai@suse.de> From: Wesley Cheng In-Reply-To: <87wmrhvir7.wl-tiwai@suse.de> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: ue4lzn1jeh_HbQIeyoDXs_Vu1MkEVnMz X-Proofpoint-GUID: ue4lzn1jeh_HbQIeyoDXs_Vu1MkEVnMz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-06_15,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 malwarescore=0 bulkscore=0 phishscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402060171 Hi Takashi, On 2/6/2024 5:12 AM, Takashi Iwai wrote: > On Sat, 03 Feb 2024 03:36:24 +0100, > Wesley Cheng wrote: >> >> Allow for checks on a specific USB audio device to see if a requested PCM >> format is supported. This is needed for support when playback is >> initiated by the ASoC USB backend path. >> >> Signed-off-by: Wesley Cheng > > Just cosmetic: > >> +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, >> + struct snd_pcm_hw_params *params, int direction) >> +{ >> + struct snd_usb_audio *chip; >> + struct snd_usb_substream *subs; >> + struct snd_usb_stream *as; >> + const struct audioformat *fmt; >> + >> + /* >> + * Register mutex is held when populating and clearing usb_chip >> + * array. >> + */ >> + mutex_lock(®ister_mutex); >> + chip = usb_chip[card_idx]; >> + if (!chip) { >> + mutex_unlock(®ister_mutex); >> + return NULL; >> + } >> + >> + if (enable[card_idx]) { >> + list_for_each_entry(as, &chip->pcm_list, list) { >> + subs = &as->substream[direction]; >> + fmt = snd_usb_find_substream_format(subs, params); >> + if (fmt) { >> + mutex_unlock(®ister_mutex); >> + return as; >> + } >> + } >> + } >> + mutex_unlock(®ister_mutex); > > I prefer having the single lock/unlock call pair, e.g. > > struct snd_usb_stream *as, *ret; > > ret = NULL; > mutex_lock(®ister_mutex); > chip = usb_chip[card_idx]; > if (chip && enable[card_idx]) { > list_for_each_entry(as, &chip->pcm_list, list) { > subs = &as->substream[direction]; > if (snd_usb_find_substream_format(subs, params)) { > ret = as; > break; > } > } > } > mutex_unlock(®ister_mutex); > return ret; > } > > In this case, we shouldn't reuse "as" for the return value since it > can be non-NULL after the loop end. > > Sure will do, thanks for taking a look. Thanks Wesley Cheng