Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2544045iof; Wed, 8 Jun 2022 07:11:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4dBwNyYbYsSC//nJmcWDva8JV6dyAFaK9bqEW9Ac06+BY2FjKvBgLzb9FvGdBdPdpUZ/I X-Received: by 2002:a17:90a:8407:b0:1d9:ab62:bd3c with SMTP id j7-20020a17090a840700b001d9ab62bd3cmr38156289pjn.139.1654697494352; Wed, 08 Jun 2022 07:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654697494; cv=none; d=google.com; s=arc-20160816; b=q0J6h3FsvlA3PFDmMxSvWd0s1TZZjzNyzBdQKfnYzpu7ihFWiv/xJyPy1NXbvS3y6/ zGWoT5xEtmJkpHm55Zr9dHnoPeLS0bFXL2azgqFIMPcIiODJaXK8emZSpFD3ix3qhxpN Sf0P85Y5n5Dn5NIR/+qqvrwdzH8gpoUnOIZG+6/xOhUrIDNtWhEOJGvGBV+NbAGVDtRd wZDnAAOwuSH9wA22gZbXWwrpXCDnOrSjttBy3QKSgT20OP8B91uKayZ1xuaZIPAJyJP8 c8l/UE4IT2p6+1+CdRLX3+9W/JwdnP5+iN5lTPWENBGKsQFiAxDxELu6JGWS4bYf0zeD b00A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=uuxLQGHMa0OkB5su2S5WGY7R0m2mr1ZgsRq6JkXP8L4=; b=z3OeOBrYZAZ+XliGbA6pLyVr8pQiuQyQ2pPbQS5rROKdM+eOEyl/ZMpXtZoBGafcKR 1SuIvQ36mpGAD10huLwc9wXJzfqqrOnmsyydhHZb3UwpnwnQKv0xArzIDTaqv1w+BnYx 7/stJD9vu5jvo1WWv1sMzKXdxjTdgqeWFvgjZD29zrlYheEW1rFLLrNmFKO5fw4JjTR1 b1t7UmENVtx/uz+dO6fx5VGsc4ll822UGldfGfUcis+ttrPGeC263E+VmqZw+oLx+y/Y bn3Syfvx7Kzt2JEDGub2kUt8AyUkgquSuNmoiwh2NDv0bnGK80OjQzCxPzWX3DB2veET ht1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d15-20020a170903230f00b00163c985bb45si15626521plh.101.2022.06.08.07.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 07:11:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BF7E6271442; Wed, 8 Jun 2022 06:45:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240653AbiFHNox (ORCPT + 99 others); Wed, 8 Jun 2022 09:44:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240596AbiFHNoo (ORCPT ); Wed, 8 Jun 2022 09:44:44 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFCBC5FB1; Wed, 8 Jun 2022 06:44:42 -0700 (PDT) Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id 8D5DD40008; Wed, 8 Jun 2022 13:44:39 +0000 (UTC) From: Quentin Schulz Cc: shawnx.tu@intel.com, mchehab@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, foss+kernel@0leil.net, Quentin Schulz , Jacopo Mondi Subject: [PATCH v7 3/4] media: i2c: ov5675: parse and register V4L2 device tree properties Date: Wed, 8 Jun 2022 15:44:19 +0200 Message-Id: <20220608134420.1750530-3-foss+kernel@0leil.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220608134420.1750530-1-foss+kernel@0leil.net> References: <20220608134420.1750530-1-foss+kernel@0leil.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Quentin Schulz Parse V4L2 device tree properties and register controls for them. Reviewed-by: Jacopo Mondi Signed-off-by: Quentin Schulz --- v3: - reverse-xmas-tree-ordered in ov5675_init_controls, drivers/media/i2c/ov5675.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5675.c b/drivers/media/i2c/ov5675.c index e671fb24ebb4..80840ad7bbb0 100644 --- a/drivers/media/i2c/ov5675.c +++ b/drivers/media/i2c/ov5675.c @@ -779,12 +779,14 @@ static const struct v4l2_ctrl_ops ov5675_ctrl_ops = { static int ov5675_init_controls(struct ov5675 *ov5675) { + struct i2c_client *client = v4l2_get_subdevdata(&ov5675->sd); + struct v4l2_fwnode_device_properties props; struct v4l2_ctrl_handler *ctrl_hdlr; s64 exposure_max, h_blank; int ret; ctrl_hdlr = &ov5675->ctrl_handler; - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10); if (ret) return ret; @@ -838,9 +840,23 @@ static int ov5675_init_controls(struct ov5675 *ov5675) if (ctrl_hdlr->error) return ctrl_hdlr->error; + ret = v4l2_fwnode_device_parse(&client->dev, &props); + if (ret) + goto error; + + ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov5675_ctrl_ops, + &props); + if (ret) + goto error; + ov5675->sd.ctrl_handler = ctrl_hdlr; return 0; + +error: + v4l2_ctrl_handler_free(ctrl_hdlr); + + return ret; } static void ov5675_update_pad_format(const struct ov5675_mode *mode, -- 2.36.1