From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D47082343C0; Fri, 21 Nov 2025 13:43:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763732632; cv=none; b=rx7sZ0/4UJlDygt+uMzbmUJlZ1nAynbfkvsuxbDtvYyDVMR56N7MPgL9oN+uaHjeveg94BrT8C7p6h2T0b9d7cggXYjBmv+kAXNGBNAp9Bcji7Qj9+1j3pYRW3bx7n1tBh6bDsbPyHHUdKxPZeS8rV1qcBva7asVY8Eruaeb4AU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763732632; c=relaxed/simple; bh=OlKVUKvVqz8q0f7s/xChWJKoSkqxj0gkMNEnSrXVvl4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xh/MXA2OsWMg/ETSFOLcXAqxeRX8d85+SvFTYhvD/d/byIUZ1EP0R/eULvjUg159b3vu03Ho5y89XDd8oK8fisOUne71xkVK7xrrhgqLkWFI6E2WpFrcAgjdEqQvh/p6Q157TJckGsLa8Boaml/2mtp6FuOhXSKlpDvd2z2bAyY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RFX87/0M; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="RFX87/0M" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 552FFC4CEF1; Fri, 21 Nov 2025 13:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1763732632; bh=OlKVUKvVqz8q0f7s/xChWJKoSkqxj0gkMNEnSrXVvl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RFX87/0MPJAR7TNHb5Vf+IWa116yvorHSRC5dZYZ5/ypxkq0yqR0zNDhCVZpjFUge 8y94MlgPsvlCZSu91iagKANmgsUXvoXahGmUoOqeeVCQAidHpELgasVWNsIYRkWDsF tLRdO5GxlbYzzFIRN6X4fpqpBbvQdPW1VOmpmt6w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Hans Verkuil , Sasha Levin Subject: [PATCH 6.6 189/529] media: adv7180: Only validate format in querystd Date: Fri, 21 Nov 2025 14:08:08 +0100 Message-ID: <20251121130237.742980760@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121130230.985163914@linuxfoundation.org> References: <20251121130230.985163914@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Niklas Söderlund [ Upstream commit 91c5d7c849273d14bc4bae1b92666bdb5409294a ] The .querystd callback should not program the device with the detected standard, it should only report the standard to user-space. User-space may then use .s_std to set the standard, if it wants to use it. All that is required of .querystd is to setup the auto detection of standards and report its findings. While at it add some documentation on why this can't happen while streaming and improve the error handling using a scoped guard. Signed-off-by: Niklas Söderlund Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/i2c/adv7180.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index ef2c769929a97..ecb0e7b1f2a5f 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -356,32 +356,27 @@ static inline struct adv7180_state *to_state(struct v4l2_subdev *sd) static int adv7180_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) { struct adv7180_state *state = to_state(sd); - int err = mutex_lock_interruptible(&state->mutex); - if (err) - return err; - - if (state->streaming) { - err = -EBUSY; - goto unlock; - } + int ret; - err = adv7180_set_video_standard(state, - ADV7180_STD_AD_PAL_BG_NTSC_J_SECAM); - if (err) - goto unlock; + guard(mutex)(&state->mutex); - msleep(100); - __adv7180_status(state, NULL, std); + /* + * We can't sample the standard if the device is streaming as that would + * interfere with the capture session as the VID_SEL reg is touched. + */ + if (state->streaming) + return -EBUSY; - err = v4l2_std_to_adv7180(state->curr_norm); - if (err < 0) - goto unlock; + /* Set the standard to autodetect PAL B/G/H/I/D, NTSC J or SECAM */ + ret = adv7180_set_video_standard(state, + ADV7180_STD_AD_PAL_BG_NTSC_J_SECAM); + if (ret) + return ret; - err = adv7180_set_video_standard(state, err); + /* Allow some time for the autodetection to run. */ + msleep(100); -unlock: - mutex_unlock(&state->mutex); - return err; + return __adv7180_status(state, NULL, std); } static int adv7180_s_routing(struct v4l2_subdev *sd, u32 input, -- 2.51.0