Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp25596lqp; Fri, 12 Apr 2024 09:31:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqXuB7nYxZpjVO3vgWIOak5E+nTAP+doL12r3s6MTfGGpHojwvhpqtHf+8MF9cj8732lGn7ORNL9n5toMsMQZOvMkR5X7JwWaDoSq5MA== X-Google-Smtp-Source: AGHT+IH5/XkG7Odz9xND/SnHBm1LLBDtyNfEi3vj+55nXFNplvGylc5o8RMgU4TD0BqJnN/VH9y2 X-Received: by 2002:a50:9991:0:b0:56b:ed78:f58 with SMTP id m17-20020a509991000000b0056bed780f58mr1964728edb.33.1712939479249; Fri, 12 Apr 2024 09:31:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712939479; cv=pass; d=google.com; s=arc-20160816; b=xlbvSK6fNQZCiJAEp5NGgcdslyY2LXG4+WkZ7QmYMw1fhwXoNKRQFkGmcRDNZVp/aG MkqRVehI9aENP//0P14VWsXqcL5DgQN1Qig6Kog++t5t10GogUPUhonaQs5A1sIQ134h Sb7V8Pu3IjlSybOuu5mF+hQwC+ad8OwIj6Dt94HyRfC7OmShtD7rvIKsWYcAmzVT1AD5 X00lZCyf60IHqUkDsAYEO/zALaisTH5UGBfmZ7z4J/nbaLAz2Bu8Nu9nrk//NptJB85w pAXj8Kr/QkxXQ51cb4yShA5suq7FWT1qiavgdTU4I/HpGnOelE/cqKerTMGa49wiwmuX eoxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=oyumYRZkYeMZAw5Ld2uDkQBx4CgXp5VjS2RTHitWmi0=; fh=VnZ48xvw2RSmFqakPEfVjR0yHLLqqVqTArrzNb3mp18=; b=pa/9YJGjS3j0byDIvBcLaWfXRIqYaoLStFFp0Z5Ew36+ynzt1qlBZVmAFezGMYiwTK yV3pfrwZtFQ9bi5AQdH0EjoSditBaW+HNmxQMzCB2/RmreqfKonBbf5LcQn1mjs+Aui5 CzIMtrZKz18+kd9Hcq0mZUA0wrt7+nWpSQRjsBOqyiS1xQgbnB0SQ5OTqi2Zmz/9htA7 D0fVZKKu3ew+8xNfySOaZ9NKrn1WouUjhdnQieCEEdWK0PL60Do9yOMazcau+TIDRIfI tmESmTK27aa44iXVnnpwJiQppFO9SFJQj8HjrrvbqyspS25mlERxYL2FnJ+aBa77UL0o DtQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=caZylvsN; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-142583-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m27-20020a50999b000000b0056fffb7d15fsi600919edb.18.2024.04.12.09.31.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 09:31:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142583-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=caZylvsN; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-142583-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id D8FB11F22CD7 for ; Fri, 12 Apr 2024 11:31:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0BDD54F89; Fri, 12 Apr 2024 11:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="caZylvsN" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 CB50750A6C; Fri, 12 Apr 2024 11:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712921469; cv=none; b=bTY/tyKAMvXDZDZ5PayP5HDwfuFBrGQTNgaDw3u1TkcXl0fZSQ3GpJc2JTfG2sf/hoJ29xLmo87HsxB7vng799JTl0TRTRWzbdhI1sULy7L9kANVY6FM+xtRbEhiYzjaV4Fm61K3BVk62n+uQNzZSbbZUXvApKK/gLyHAZw0mPk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712921469; c=relaxed/simple; bh=L960/YQ59RzbOd8aJJgKPfZJ+eguGt9hV8xigRjXTME=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BhuxBJZ9KRF2dsivc1CVIv0AqZS7X8txublp0GCNL5H14VHXX0haH1LwWNxnRSatgG7bWV7Io0PhLlIgePGTVN2oSYEVJpFvbUbqPoLiHRTwCKNsAzTTdO6ufVQABtkrX3ufDvrtSi/Ofda/kV+w1VRAz0tP0q38yHjND6gmy9w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=caZylvsN; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712921468; x=1744457468; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=L960/YQ59RzbOd8aJJgKPfZJ+eguGt9hV8xigRjXTME=; b=caZylvsN9zz+dU+ioKn5TP25fa07DShjHnzKP4lLs2iEWbXWEkmj72Nb umtVhkaNcwfjkhOxw2nSfVs5JwpMqL2efcLLzFE8gIiAIQE5j7bEyVF5+ ScqdXCf/bzfp8KX6+nHL3ClpPN5YyXMG/RK9gWyi4Qtk3E9mFUGT8j5VJ 3wg6JfkADdLMIQIewm+4W5VZPZveMLXfmFyIB+Ae3CSxwzXTM9BrZHCUv Vd0x2+P88qyexEVyobG1/qsP0sPAJIwN3Om+7OYj1bZ3zTiAQu/72dVnd eXtI3FfA2OnNBc980HecdgTm0zgHeegp7urOyHpgp4M1oZqe2MXy8uY4K w==; X-CSE-ConnectionGUID: 54COLSCpRAOcSrqKP+Xo6A== X-CSE-MsgGUID: y9glu24hQ9eAAehn+JAnpQ== X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="25827805" X-IronPort-AV: E=Sophos;i="6.07,195,1708416000"; d="scan'208";a="25827805" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2024 04:31:08 -0700 X-CSE-ConnectionGUID: 5KxX8M8xRwqYtvWtVt2zMA== X-CSE-MsgGUID: f6EmvKVfRCe5jt5OCUxFdw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,195,1708416000"; d="scan'208";a="21630403" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2024 04:31:05 -0700 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with SMTP id 7AEBA120359; Fri, 12 Apr 2024 14:31:02 +0300 (EEST) Date: Fri, 12 Apr 2024 11:31:02 +0000 From: Sakari Ailus To: Umang Jain Cc: linux-media@vger.kernel.org, Alexander Shiyan , Kieran Bingham , open list , Dave Stevenson , jacopo.mondi@ideasonboard.com Subject: Re: [PATCH v4 2/6] media: imx335: Parse fwnode properties Message-ID: References: <20240402140924.10009-1-umang.jain@ideasonboard.com> <20240402140924.10009-3-umang.jain@ideasonboard.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240402140924.10009-3-umang.jain@ideasonboard.com> Hi Umang, Kieran, On Tue, Apr 02, 2024 at 07:39:20PM +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 | 24 +++++++++++++++++++----- > 1 file changed, 19 insertions(+), 5 deletions(-) > > diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c > index c633ea1380e7..b8cf85984127 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; > > @@ -1296,15 +1298,27 @@ static int imx335_init_controls(struct imx335 *imx335) > 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); > - v4l2_ctrl_handler_free(ctrl_hdlr); > - return ctrl_hdlr->error; > + ret = ctrl_hdlr->error; > + dev_err(imx335->dev, "control init failed: %d\n", ret); > + goto free_ctrl_hdlr; > } > > + ret = v4l2_fwnode_device_parse(imx335->dev, &props); > + if (ret) > + goto free_ctrl_hdlr; > + > + ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &imx335_ctrl_ops, > + &props); > + if (ret) > + goto free_ctrl_hdlr; This works but it'd be nice if v4l2_ctrl_new_fwnode_properties() behaved as the control framework functions, i.e. bail out if the handler's state has an error. Then you could have a single check for that, dropping the two checks above. Feel free to post a patch. :-) > + > imx335->sd.ctrl_handler = ctrl_hdlr; > > return 0; > + > +free_ctrl_hdlr: > + v4l2_ctrl_handler_free(ctrl_hdlr); > + return ret; > } > > /** -- Regards, Sakari Ailus