From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 BF4643043A5 for ; Mon, 1 Dec 2025 11:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764587096; cv=none; b=oywuYLCAREfJZ2oaJEWZh9UANy7Cy5/cANfkfctVQekCFemejlRDO3Kf2GEKWZoh/TjtKSCaPsc1lulvjs+90HzIVkLa8fjLc/Btb+7WPD1++MtIAc8+Tzd8XNRWvg4YMuE1pHAxzO6VSqLDaQBKSnWceWavC4yCxbFptikIJqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764587096; c=relaxed/simple; bh=fjKjrLZk7uj5gaFLc+nEjLQA0joiVJDR/iCd9fUsgqg=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=HhXBfCwbsROfyL+gGmnH3KPyyW93e9L/MqYn1lzx7ViCnWp69rbng8uQTccVoHofi3naNMEXfHYkiS/ZwCbBim8GF8gPiV099YBU5RoOrcRVxmBB2Q3cXUsLthLHecdyfLl7qfSzUFmVrQo8pS4RZqRnW6xwtrDOYgYd4GhhENk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=GMSsU2Br; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=SmKIeHBA; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="GMSsU2Br"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="SmKIeHBA" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5B18kCfK2504182 for ; Mon, 1 Dec 2025 11:04:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= PJypT8id1riQxvc+MHEOuWd2vICcL/EIKtNcIwKmsoM=; b=GMSsU2BrV2mhN26h 3+FtV/ogIYdL8StoNrCHbFJhgxHclji4RbD8hfjvHA0oj53h+w12OUVig8UwMVfu 64V6Er8gRJhKbAzKw2wAv58+0bsxnXXQzIVw+a4JKrPXJWby7mUo2AXr4e1UMRuo QZ1qn74bYGCv5ezV+n6QK4o9vD02TtJT0LPI2Z66YpbIB+KJ3us1HvxKW0wOqm2W PUtDy7w1D2qwqsrZmWgjhpEYkiW63y6oOOLudGdRKPgxIstP1YJrKRdbowatj05Y x1iwwifOMV5c5+qdj7uYmPI+ag8cUcoRmEbONblRh+ltGDAPObDxIJPAIyrU5kzq 5KRPSA== Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4aqphfcr3t-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 01 Dec 2025 11:04:52 +0000 (GMT) Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-559ee67b6d2so1868082e0c.1 for ; Mon, 01 Dec 2025 03:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1764587092; x=1765191892; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=PJypT8id1riQxvc+MHEOuWd2vICcL/EIKtNcIwKmsoM=; b=SmKIeHBAwAAK85D3/F3yu1MP1bx6ToqE4RWai/eDOOfPRNRDUWtASbHYBd1RAYIeNA HXKDBuwGbeq7UwJy7WS13Lqv5eBVwFfzUUSpmZxdMiqQezePS1joYvWbs3uV2WgS98sa /jHlaDUEERgj1Wp+wRc97HMXTjMW/achKBX2ltj0w1/Ewh1rH98e+95JXUmPlDfV8e8B F2lJzr85pkY1vKT7icnoIyZIUrfZdr/hpGg+mNj7/XA0yFVpmNK5oMgHsU7E/eyg9Vu8 mENYW73f7BYUCvy3/Bc3n9u6XTsWvotpdgC4MKwH4zf6oJBUhooqxXNFm9cl+VZzlwtB egjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764587092; x=1765191892; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PJypT8id1riQxvc+MHEOuWd2vICcL/EIKtNcIwKmsoM=; b=ZtO1UlvancQX/rV+Pz8M9Un0IO9tio6xymGoieFEkffe0PrFX2nFXAbBVhtWgJ/imR iBjQ3+m7pf+7xwdnc1rFgaala9ZKuzWjDUnvpKpI2Pmx1TWht/N3HQS/lh9AvfcQsU6b Tw2oRUaCAV9HyYHdFw4XBoKt/lKVjMzk66trAMwZ7AyBmox2OX8/m+gMgafalIWd5SS6 62N4xh0kTdWKY2UnvBBlz9e6XANHQVpHAQKhxwapc+jGnWg6UGrjxvsCZnASmEDUmOm2 BulJMnQWSI5SK0X3icRNYEWuJJlmuDRgzK0eVHkKedH0cBIBeeY0iwZiz28G5lVt6nif 5Jow== X-Forwarded-Encrypted: i=1; AJvYcCW7hqV47AFf5NyUliPj/TtZmRqYyxhkLkkjbl7Zaefb9rwyWSWdrZLWtvDozy/rwlkBG12mQ6JVSIMYXuE=@vger.kernel.org X-Gm-Message-State: AOJu0YwQ+88qU3/k+V9pxZAYoli/7eacCVjinZzHfL0ebkNMpzhXnonh 7kppcBZY32id28MUr9Du/mstnvq+K5GNKsYq1iC501K63qX2k6nCm5ksyIwoSRtswjt77exKopM I+tw5yQaJ9+5PDZxbwxGJYPpNbvZpmq3nP7w6uz0GnyPa6n26/mBeBOcoc25aSEg0WMI= X-Gm-Gg: ASbGncsnuErM0TRbvCcOZoC/C5Kui9VAL+mUiRiASM2E2KhuwN2FgUGMnbsGuVQXn3u dqYott7cQNXhY+C3IwC45of3zgCIgKqVUpS7Ezbu8so0HsGsZ39rz70mCoDf9gHk+Xf36tSAnUF YInCrR6fSzF3JFzA5d2N9bnZTSO/1RNzTAWHPLM4AZ6Vg4gsQP1WGpzw/wmQy9n226+Lz7vIrmS a5Vfe7HWPHPwah/uXifTZvFOYH3wNnx0dRrVuyhpXMkuSoj9DnwAUxiZGyiWq9tEl8YKHzeg2kj 695vn1UQLkqeJCW8ts5GAt26leYEi5yQXsCMdfXcF0SAzAhgKMnDeyJDNf0/HVbR/QfYydRt6Ut S/w2Ewjl5wVkrtxa2g22c6Ohv6+LAlf6iUgzF X-Received: by 2002:a05:6122:d16:b0:55b:305b:488d with SMTP id 71dfb90a1353d-55b8f048ef2mr14749610e0c.19.1764587091919; Mon, 01 Dec 2025 03:04:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1fzqTcIhPwBthwPI9sIx98IGlGB3LqwjOOm8jqI/lDrPl0eIFqJ9aVKPC/Rt1exyMotDgGQ== X-Received: by 2002:a05:6122:d16:b0:55b:305b:488d with SMTP id 71dfb90a1353d-55b8f048ef2mr14749560e0c.19.1764587091478; Mon, 01 Dec 2025 03:04:51 -0800 (PST) Received: from [192.168.68.121] ([5.133.47.210]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-42e1ca8e00fsm25783091f8f.34.2025.12.01.03.04.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Dec 2025 03:04:50 -0800 (PST) Message-ID: Date: Mon, 1 Dec 2025 11:04:49 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] soundwire: qcom: Use guard to avoid mixing cleanup and goto To: Krzysztof Kozlowski , Srinivas Kandagatla , Vinod Koul , Bard Liao , Pierre-Louis Bossart , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20251201102627.146182-2-krzysztof.kozlowski@oss.qualcomm.com> Content-Language: en-US From: Srinivas Kandagatla In-Reply-To: <20251201102627.146182-2-krzysztof.kozlowski@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: XRv9hsH5qDNjqOIJhqT-wZw78jBn5xXd X-Authority-Analysis: v=2.4 cv=FvwIPmrq c=1 sm=1 tr=0 ts=692d7655 cx=c_pps a=JIY1xp/sjQ9K5JH4t62bdg==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=lK1EhxQaTO3hfdUELo0A:9 a=QEXdDO2ut3YA:10 a=tNoRWFLymzeba-QzToBc:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAxMDA4OSBTYWx0ZWRfX7BGos3vO0ge+ 7QEbVoACqKm+Q8j9fGadClOsCruas4J9z3SaINNgbsRu5pg4jUepF1xSCAL43RWFpYVkofewPL3 VIELpzGjey2//VqF0an9etmXZgn0HNmMN7S03EUPaobDjfMdWA55OZ4hreMiKCBhbxePCwY7vRT /raErDbhahSwo5X7IlLhR4gX9ymQtRER4x2DV7WaVQeZQ46dzjHkoQqlr2uDiIHM8X/IaowwXBm Tpc8OHK15I/htUlS6AQ6fK3VuTDAiQVSsoGtue7m80u/LSX3b48fxvh8vFjLFsaYgZ+5ZVwOwkA ZKrLrMOw/ZCEYHqX0jtVFLGBq286YFfaNE9CtVYGLMqcIPLDOHMIzQpicbUM3RN2+jXtSq5as4K ozihCxqKJHYJve4dtQq3xhBrQDK6AQ== X-Proofpoint-GUID: XRv9hsH5qDNjqOIJhqT-wZw78jBn5xXd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-28_08,2025-11-27_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 suspectscore=0 malwarescore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512010089 On 12/1/25 10:26 AM, Krzysztof Kozlowski wrote: > qcom_swrm_stream_alloc_ports() already uses cleanup.h but also has goto. > Such combination is error-prone and discouraged: > > "... and that the "goto" statement can jump between scopes, the > expectation is that usage of "goto" and cleanup helpers is never mixed > in the same function." > > Actually simplify the code with a guard which allows to fix the > discouraged style by removing the goto. > > Signed-off-by: Krzysztof Kozlowski > --- Thanks for the patch, LGTM, Reviewed-by: Srinivas Kandagatla --srini> drivers/soundwire/qcom.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c > index 17afc5aa8b44..8102a1b0d516 100644 > --- a/drivers/soundwire/qcom.c > +++ b/drivers/soundwire/qcom.c > @@ -1228,7 +1228,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, > struct sdw_port_runtime *p_rt; > struct sdw_slave *slave; > unsigned long *port_mask; > - int maxport, pn, nports = 0, ret = 0; > + int maxport, pn, nports = 0; > unsigned int m_port; > struct sdw_port_config *pconfig __free(kfree) = kcalloc(ctrl->nports, > sizeof(*pconfig), GFP_KERNEL); > @@ -1246,7 +1246,8 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, > sconfig.type = stream->type; > sconfig.bps = 1; > > - mutex_lock(&ctrl->port_lock); > + guard(mutex)(&ctrl->port_lock); > + > list_for_each_entry(m_rt, &stream->master_list, stream_node) { > /* > * For streams with multiple masters: > @@ -1272,8 +1273,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, > > if (pn > maxport) { > dev_err(ctrl->dev, "All ports busy\n"); > - ret = -EBUSY; > - goto out; > + return -EBUSY; > } > set_bit(pn, port_mask); > pconfig[nports].num = pn; > @@ -1285,10 +1285,8 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, > > sdw_stream_add_master(&ctrl->bus, &sconfig, pconfig, > nports, stream); > -out: > - mutex_unlock(&ctrl->port_lock); > > - return ret; > + return 0; > } > > static int qcom_swrm_hw_params(struct snd_pcm_substream *substream,