Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp138301lql; Fri, 12 Apr 2024 06:17:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbIErf4a7Xtpyi+3Z9AswsH+bMgxkUUDe8p+nOjlHrLNXBMhTPgWu01Zc6opXbR1vvXKCa2duRyM+TUlXAvYOY64g4htmjwcHYQOBsbA== X-Google-Smtp-Source: AGHT+IFEvfI8totuJLcQAzDQ4L7+TkTMTRxCRg7F3TTPJw7cogN/nk44HMwveI3sm9dWO6e0MURp X-Received: by 2002:a17:906:37c7:b0:a51:ab81:6062 with SMTP id o7-20020a17090637c700b00a51ab816062mr4408130ejc.30.1712927827404; Fri, 12 Apr 2024 06:17:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712927827; cv=pass; d=google.com; s=arc-20160816; b=uvjuqt0otAMwKFdtt9MCV5k+jVqLtH0hB/DMIsH+UD5wv/Ag+e4F6FcKdIJy/FyU3z PVqEdMWvF4cyXSxc7FTZ8j1RvAC6K21MIXeNvYqZkF54+ezSHBEu6E1B0E1gvNfBN5JU IHDlsl4DDZ11Y6BEo6JscaOf/+RqU4h5ibKPWpM/xR7rSUryzfJkKv+puiMFrHPo0cUK lopZLermXDp57i9Myw6NBySNvfOcVEXO4D6gYZGaKuVG/dCg79lo0LLHEvF5BlPngzNS GrPAZoxl7DlEGvWmmjvGKs4pCSIcWq01c5XN150vY2NTv0VrpuQwuW/yNUC6QpskLgr6 jX1g== 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=eozJEuV9GBzNoH3cyBAAqBjxhXNRBahE5i/Ngjw2aGA=; fh=5E+1vtTFZUZkYg4d6mDBbpgjk4IyaGUF1PBX7Kj3nLE=; b=CD1JWu60qODELa+DwEsJAJX8adIsVvmj97l55uRnOIqK53WyAwdLS87kNCnMVk80Ch 8KtEkVrfZHm54BL2YP8qQ31dRgbjD/UlsrhNx8OX+wpMvnNgkYj0dIQSTsp3B+ZjtRVV fLdquOm8bUWL4G2xuiV+RtgcdoEgJkuG1/iN1OkYIlgEHGd86OcGwbNm4PUtxmMjynOG tLDldFwBSlE2FX8GrmVHxCl/JDARt8RVxwlkrFgQL6o093qwHReUf+LEPQ47qkgW5HUp uZrxWmC4PSTAatafaSJa52p68o5kLFQ45MPbIFS/FcD/cYy0ftjgzUBYXG6HLgBE48OO 2cyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=t+5MkzCM; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-142703-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142703-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z10-20020a170906240a00b00a519c6e6932si1667854eja.288.2024.04.12.06.17.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 06:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142703-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=t+5MkzCM; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-142703-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142703-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 am.mirrors.kernel.org (Postfix) with ESMTPS id F23951F222E7 for ; Fri, 12 Apr 2024 13:17:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88C2A5FDA5; Fri, 12 Apr 2024 13:16:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="t+5MkzCM" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 0DE9C64CD0; Fri, 12 Apr 2024 13:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712927810; cv=none; b=Qvc354iR7pBXvhoplApmlJIZBkkBZWyYB/ve1MunP5LrwH/OebC0iEzWUzi7DUgi/sZGP/sC1vXKWqOJ9yb1RIZU88zxFX/NmomcKm19MQGJGuwLEjV2HGL4y8h8pFMtnRN7MnV+YrK+MjXWJNtTL5xSKcrewgRk04BMngtaRtg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712927810; c=relaxed/simple; bh=MaGSYA2Udrt5OpxI+Noda33oYVm+GYTXXkzp8OxlUIs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bSk2C+H1GaFRUSChJRbg9V7wpOi9Tmi2MjM7NlZswwb/89geS3/YiQEc5tsslyB2SkWWeugO/fmRZMmAO0sm3HsUBR5RILzRvgKRzp+yutUrtRoZJjCrMG63evfRIo5CzPKo1lB/Fa5mcPh3UjVNaSPdroYs2ugo61esMo6kWoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=t+5MkzCM; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from [192.168.1.105] (unknown [103.251.226.65]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1FCA9A12; Fri, 12 Apr 2024 15:16:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712927763; bh=MaGSYA2Udrt5OpxI+Noda33oYVm+GYTXXkzp8OxlUIs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=t+5MkzCMs5CrvGPkUIU44pXddxI4oJasu4maLhApJXGy9DfJZx23YjHrj5c6i+7Jd wQKzb2ad0OH00plsFJGTwsOfdlWaacwk6O0htPjEEZ4uvwBV3HwOxJuw7ErZMxm+zz Grab0Ztl3KHAKzftajg2UzGKwjm5ACvAVbLxPLx0= Message-ID: <3092092b-5989-4a7f-8f3b-4e1bf2aed385@ideasonboard.com> Date: Fri, 12 Apr 2024 18:46:39 +0530 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 v5 2/6] media: imx335: Parse fwnode properties Content-Language: en-US To: Sakari Ailus Cc: linux-media@vger.kernel.org, Alexander Shiyan , Kieran Bingham , open list References: <20240412122842.193713-1-umang.jain@ideasonboard.com> <20240412122842.193713-3-umang.jain@ideasonboard.com> From: Umang Jain In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Sakari, On 12/04/24 6:33 pm, Sakari Ailus wrote: > Hi Umang, > > On Fri, Apr 12, 2024 at 05:58:38PM +0530, Umang Jain wrote: >> From: Kieran Bingham >> >> Call the V4L2 fwnode device parser to handle controls that are >> standardised by the framework. >> >> Signed-off-by: Kieran Bingham >> Signed-off-by: Umang Jain >> --- >> drivers/media/i2c/imx335.c | 16 ++++++++++++---- >> 1 file changed, 12 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c >> index c633ea1380e7..3ea9c0ebe278 100644 >> --- a/drivers/media/i2c/imx335.c >> +++ b/drivers/media/i2c/imx335.c >> @@ -1227,10 +1227,12 @@ static int imx335_init_controls(struct imx335 *imx335) >> { >> struct v4l2_ctrl_handler *ctrl_hdlr = &imx335->ctrl_handler; >> const struct imx335_mode *mode = imx335->cur_mode; >> + struct v4l2_fwnode_device_properties props; >> u32 lpfr; >> int ret; >> >> - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 7); >> + /* v4l2_fwnode_device_properties can add two more controls */ >> + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 9); >> if (ret) >> return ret; >> >> @@ -1295,9 +1297,15 @@ static int imx335_init_controls(struct imx335 *imx335) >> if (imx335->hblank_ctrl) >> imx335->hblank_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; >> >> - if (ctrl_hdlr->error) { >> - dev_err(imx335->dev, "control init failed: %d\n", >> - ctrl_hdlr->error); >> + ret = v4l2_fwnode_device_parse(imx335->dev, &props); >> + if (!ret) { >> + /* Failure sets ctrl_hdlr->error, which we check afterwards anyway */ >> + v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &imx335_ctrl_ops, >> + &props); >> + } >> + >> + if (ctrl_hdlr->error || ret) { >> + dev_err(imx335->dev, "control init failed: %d\n", ctrl_hdlr->error); > Too long line. > >> v4l2_ctrl_handler_free(ctrl_hdlr); >> return ctrl_hdlr->error; > The handler may not be in error state if only v4l2_fwnode_device_parse() > failed. I read some more drivers and it seems v4l2_fwnode_device_parse() can probably be checked at start of init_controls() and return early on non-zero return value. Is that something that should be done here as well ? > > Should that be something that should prevent probing a driver though, or > could it just be ignored? I.e. in that case I'd only check for handler's > error, not ret. So we should probably check for ret and ctrl_hdlr->error separately ? > >> }