Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp231974rdh; Tue, 13 Feb 2024 15:28:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWXGy57cPEQ/NM69+AAyTmXYTzm4+db2/FikyJkzWUe+/FUHNwRAHG25wYR+vqdUlw5ymqOORcxeF/T4RMjGs8z3cB7HD5o2Vl+zfQ6WA== X-Google-Smtp-Source: AGHT+IERJWsD0neFsyTXQMC3XK7GZxY3+T4G8PbcXTqiLeEK5AzAbSXQ3vA7Z81E3bPDCS9lE/6R X-Received: by 2002:a05:6a20:93a5:b0:19e:947c:20cc with SMTP id x37-20020a056a2093a500b0019e947c20ccmr467585pzh.9.1707866934746; Tue, 13 Feb 2024 15:28:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707866934; cv=pass; d=google.com; s=arc-20160816; b=pNL0ge8bz1pFEa4RHD5Cx0oGoAsZvzvBelweJ+101HvzKP4LJnuDWaCoFq727flW4E ctGWKZhLlS25oUqbfVj69oflcl/b9EbxbZMs9kdk1TUj7N2ISdWpyX/ezcZZz/ejvtSu 9L2PsMzfMwQXn4J/9xifWrU4jLBtFsBhV2PJUFp4LPmVbbGAQnKD64xxIbm/rf6JXFwB VLRMjLjYX1vzcdKQXpSeDUmil3QePwk99erLRwnenoQ4RHokfylcJjtEUnh7kC6Wr6Hg gJpD7BSs8pvXMGWrZGf+04EAZeKxCkG3lmVyO3FK1Agt9HKSbC4/kCRWoBdFARE9h4rP 4HUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from; bh=toJipEIkczFD3wqawB6Yxh08HjgMEDvL3BVswzqBOiE=; fh=ZvC074A04SdM7Aw6b3x1ty2m2tVV8omOu5nLzXkWJYg=; b=yNR0ioTm7TtyeFQ7W9NXA+NP7iHKEHN0UGJR/A3/c9uOygPmL7d8pEGVS6pSDDFESm 3lH8M05pRjzh6vu/ePMbCe4cJ2fc6iISKz8n5VJRByz/MxxPxUc/RAs2f3bpr8dDZFEO G3jxBeOYDuZaFJjaPmU6bSkbxT730nRQZLmLuj951wWsTx8fIdVp8ZtPyoqPgXXb6H7t svXdMEX3ZrAocGVCCkSxocmDBrTeMLXWIAct0b/m6BSZKvZs72/9cixYeDKH1zjfwHck JsOxK7zZdTXGZLsyc8vqSZNGoKEWKZdTDbfffwR0gDZ6nkpZPO/sEPHb6lkBDVsJyO7D L3ag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-64539-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64539-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUwOJgiIRsXJUhEbpsn2FH0wXVoO3TBkNFy12yMmqt1JEPQFLOttY2nXD9Rvj6/FIKqUNmf8t2QRmUaDRnQqetHOV+N9cIjOTcMrDfp2Q== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l184-20020a633ec1000000b005dc71c7b944si2823293pga.144.2024.02.13.15.28.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 15:28:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64539-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-64539-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64539-linux.lists.archive=gmail.com@vger.kernel.org" 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 69C7628FD03 for ; Tue, 13 Feb 2024 23:28:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B00B6341B; Tue, 13 Feb 2024 23:28:26 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 EEFD263106 for ; Tue, 13 Feb 2024 23:28:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707866905; cv=none; b=OcpKASm3wg3jIwXRriNeD7OykG2BxEJbUJZuiu2rQk4PnbLY/ABSR/QXMUBTWn73PhgcyBmZ+551j4muzz0HIjKbBs+sNcRDs6NCVOvmwZX2RR+24q+Va0MxiQZCozIO+9BGlpfn+xouRcOEKbL62GeAAyaIkGduElJaHcLhYQ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707866905; c=relaxed/simple; bh=30YYmuToXt0Be5FF1D9822Y6K2GuA90aOezsbaqJW0s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MaV2dA8pIMgXJQ1orxBQmuGLQ24G1DB65lZp/Begp8ZcGbQG/Dw+Yk5lPfJVEB6NWujHRZaQnY26zH6hjKj4hPMC9QkPdJ8Mt36a/9bCOSvdSctP/xAl3aSkHRLvwRo9fjSs1q5HO8fOYB2G5aAIVzKqorHw6dKHA4EkmpRVYeY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ra2CI-0000eR-Ij; Wed, 14 Feb 2024 00:28:18 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ra2CH-000Zcp-Up; Wed, 14 Feb 2024 00:28:17 +0100 Received: from localhost ([::1] helo=dude04.red.stw.pengutronix.de) by dude04.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1ra2CH-002uYW-2t; Wed, 14 Feb 2024 00:28:17 +0100 From: Michael Grzeschik Date: Wed, 14 Feb 2024 00:28:01 +0100 Subject: [PATCH 2/3] usb: gadget: uvc: refactor the check for a valid buffer in the pump worker Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240214-uvc-gadget-cleanup-v1-2-de6d78780459@pengutronix.de> References: <20240214-uvc-gadget-cleanup-v1-0-de6d78780459@pengutronix.de> In-Reply-To: <20240214-uvc-gadget-cleanup-v1-0-de6d78780459@pengutronix.de> To: Laurent Pinchart , Daniel Scally , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Grzeschik X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1153; i=m.grzeschik@pengutronix.de; h=from:subject:message-id; bh=30YYmuToXt0Be5FF1D9822Y6K2GuA90aOezsbaqJW0s=; b=owEBbQKS/ZANAwAKAb9pWET5cfSrAcsmYgBly/sR6vOuNRf8bz1usN1hrU8dGhJSMxHuyafO/ vgaWNxSX/eJAjMEAAEKAB0WIQQV2+2Fpbqd6fvv0Gi/aVhE+XH0qwUCZcv7EQAKCRC/aVhE+XH0 q3pXEACPUYRmu19z11qUsOha/z9QRa+P7klnxF6Mf3Zgi6d8WSPDG3m1wdvDxkGuPcRJ6ksszw6 qBmF8jzi/kPJFD8aOZwdaPExVhPEP2QN9n7k09m2C+hLlEzstCtqMF4oIUseP4P+4ERtJDac0JW qux4XtvYoU2d4OIMKZ0jHTLKT2TDe+QSuvYhFCFse0EUufu1lJvQrY36oaYFbIMGRN4jIqS3/OL LqmIQPuKzluEaypn5dL2EiUMt/e8SWbtBGowp6byn0x2YK7x14x7VaZqzcWRsF1c3W77PS9GFtA kVdq9F2uUQaI/MOGtx/aYZ0c3Z+C4JTV0JJOjoc+3dgsNXRqn+qOE/Wusr3fMgKd+mbg4B970lE pZETUw5p5wv1CwsbcKeEp6MZZGLU4ujE3ortF9rWAAJx4WJzlXiYRoTnBg7TrfFf+41ssu5kdPU ZcXN0G6VQlz7r42JKbezSEIeGbjhUAEFpMv3RDOqxm1DUw0z+Ao9KfAV724kGW407Y8gE8kWfmT D5Xw9BMLebOHgSiEqJPtKzym3/fkI6uc2pMycN7pZzgqhLLiawSLiYqDKiI+bV6Tucy6/mOV2cZ VYTZr5upT5Xy0zxQKbIr9nb968YB9ybO+KD7A75HetLTqQ5un+Daq+T0KJYhJdAlXf2QtGeYwU5 lizaj9dmtWYG1aw== X-Developer-Key: i=m.grzeschik@pengutronix.de; a=openpgp; fpr=957BC452CE953D7EA60CF4FC0BE9E3157A1E2C64 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: m.grzeschik@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org By toggling the condition check for a valid buffer, the else path can be completely avoided. Signed-off-by: Michael Grzeschik --- drivers/usb/gadget/function/uvc_video.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index b17c61c932652..b4f3b3c784218 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -594,10 +594,7 @@ static void uvcg_video_pump(struct work_struct *work) */ spin_lock_irqsave(&queue->irqlock, flags); buf = uvcg_queue_head(queue); - - if (buf != NULL) { - video->encode(req, video, buf); - } else { + if (!buf) { /* * Either the queue has been disconnected or no video buffer * available for bulk transfer. Either way, stop processing @@ -607,6 +604,8 @@ static void uvcg_video_pump(struct work_struct *work) break; } + video->encode(req, video, buf); + spin_unlock_irqrestore(&queue->irqlock, flags); spin_lock_irqsave(&video->req_lock, flags); -- 2.39.2