Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3369867rdb; Wed, 13 Sep 2023 09:55:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWckrnO0FQayWH6s4rNGU+88T4jdip3ak1hnlU2ccxc6xnnqBnYabbuv6E69yfO4cXz1V/ X-Received: by 2002:a17:902:f80a:b0:1b8:78e:7c1 with SMTP id ix10-20020a170902f80a00b001b8078e07c1mr2792097plb.51.1694624143390; Wed, 13 Sep 2023 09:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694624143; cv=none; d=google.com; s=arc-20160816; b=nzjKFkVXcXoz/2f2I9B5Wzbx4J4n5pLYQNBpehio6wRENgiJ/nwSTshEGbFgUCwcAv THsUlCx8ozjSiymLOl26TZk2166UBVxlxFQZ9E2tqXjg4lsGzCvYlSVEw9fxBthYq0xc w5EMaAPSn7hjrq5dcPgvcP/lMHi9/6YzpTLjyz5hQpo+BUINgW3J95iv3F09taQ+Gyr+ 59JVf3858YZApUYaAuTrZ/zTdWefrKl9FZzBpYRpqrO/ZKDrtZY41QKQ2sPhIpE85lt2 jZgL9Ua0Tw8jJRv0zWjpkMCIYT2azINuV/ov9+2VC1It9IkpNtUr6eDaz7bfZjItTV5L 4LoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=czlYHcaoUtrqdCzq/bCtwe3gd7pDzgMO50PAl4KAnFY=; fh=V9M+Vymt7gQEpbhgei6D9579ibAhmVJh42DpvRNRVfo=; b=GKNHhrZJ/BZnILk+ZKO+6jRjjp3QEIWxwSnVvWjqTTeBgdbxaqTA5hEVo19rOPB/eN sgCA7v3PlAAeKxfuushXAicchuF0wzSYRt2EOLfnJTvKPjAi9VC6rG0dtXl7XhSpLcJG 6n+e0IRDJ8liYgov2mvUuh/JV8B+kMEXVvhag8ytjfQUN3qKS8tazn3i4ekrlmcl1/xA 30EiaFvabgZcFYXQ8gHLwakplbbkVD3oGheB4cgXOMYflqDgDs5NDJkuIbkACX6mZZX3 ldE3QEtYoAbX4SokCkPARDz/hTh2/H+4CN10YGiATAlUYgl1fuTVthkmG07HMPSn5Dci PRGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=bGNpFzcZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id x1-20020a170902a38100b001b82a4d3ea7si7333115pla.249.2023.09.13.09.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:55:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=bGNpFzcZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 86672809A75E; Wed, 13 Sep 2023 06:45:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241161AbjIMNpS (ORCPT + 99 others); Wed, 13 Sep 2023 09:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241060AbjIMNpQ (ORCPT ); Wed, 13 Sep 2023 09:45:16 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A770419B1; Wed, 13 Sep 2023 06:45:12 -0700 (PDT) Received: from ideasonboard.com (unknown [IPv6:2001:b07:5d2e:52c9:72c3:346:a663:c82d]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 94F0072E; Wed, 13 Sep 2023 15:43:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1694612618; bh=1Utp4+wXedh3YwkwcOGvZuEmlvqMt4KuKWejkPVuL9I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bGNpFzcZluIVT/SGm+cu7SzzCm0XUa1er6ku4n1qpbQGJBkX0tA2Ae9jkV7Gdca4o zt5gAmNqbSWIY/MKzEA3ow5Lnk1d48kIjqynX/Z8C0HRfR8rGM9wm266YWHbOfnDnJ pkOeX4qzXTV+uUOXDUvIWWJGmnNyUNsMscNP2iLY= Date: Wed, 13 Sep 2023 15:45:07 +0200 From: Jacopo Mondi To: Jacopo Mondi Cc: Biju Das , Laurent Pinchart , Sakari Ailus , Mauro Carvalho Chehab , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Biju Das , Andy Shevchenko Subject: Re: [PATCH 1/2] media: mt9p031: Extend match support for OF tables Message-ID: References: <20230910160126.70122-1-biju.das.jz@bp.renesas.com> <20230910160126.70122-2-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 06:45:33 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Hello again On Mon, Sep 11, 2023 at 11:25:03AM +0200, Jacopo Mondi wrote: > Hi Biju > > On Mon, Sep 11, 2023 at 09:14:35AM +0000, Biju Das wrote: > > Hi Jacopo Mondi, > > > > Thanks for the feedback. > > > > > Subject: Re: [PATCH 1/2] media: mt9p031: Extend match support for OF tables > > > > > > Hi Biju > > > > > > On Sun, Sep 10, 2023 at 05:01:25PM +0100, Biju Das wrote: > > > > The driver has an OF match table, still, it uses an ID lookup table > > > > for retrieving match data. Currently, the driver is working on the > > > > assumption that an I2C device registered via OF will always match a > > > > legacy I2C device ID. The correct approach is to have an OF device ID > > > > table using i2c_get_match_data() if the devices are registered via OF/ID. > > > > > > > > Unify the OF/ID table by using MEDIA_BUS_FMT as match data for both > > > > these tables and replace the ID lookup table for the match data by > > > > i2c_get_match_data() and simplifly probe() and mt9p031_init_cfg() > > > > > > > > Drop mt9p031_init_cfg as there is no user. > > > > > > > > While at it, remove the trailing comma in the terminator entry for the > > > > OF table making code robust against (theoretical) misrebases or other > > > > similar things where the new entry goes _after_ the termination > > > > without the compiler noticing. > > > > > > > > Signed-off-by: Biju Das > > > > --- > > > > drivers/media/i2c/mt9p031.c | 33 +++++++++++---------------------- > > > > 1 file changed, 11 insertions(+), 22 deletions(-) > > > > > > > > diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c > > > > index 348f1e1098fb..540cb519915c 100644 > > > > --- a/drivers/media/i2c/mt9p031.c > > > > +++ b/drivers/media/i2c/mt9p031.c > > > > @@ -112,11 +112,6 @@ > > > > #define MT9P031_TEST_PATTERN_RED 0xa2 > > > > #define MT9P031_TEST_PATTERN_BLUE 0xa3 > > > > > > > > -enum mt9p031_model { > > > > - MT9P031_MODEL_COLOR, > > > > - MT9P031_MODEL_MONOCHROME, > > > > -}; > > > > - > > > > struct mt9p031 { > > > > struct v4l2_subdev subdev; > > > > struct media_pad pad; > > > > @@ -129,7 +124,7 @@ struct mt9p031 { > > > > struct clk *clk; > > > > struct regulator_bulk_data regulators[3]; > > > > > > > > - enum mt9p031_model model; > > > > + u32 code; > > > > struct aptina_pll pll; > > > > unsigned int clk_div; > > > > bool use_pll; > > > > @@ -714,12 +709,7 @@ static int mt9p031_init_cfg(struct v4l2_subdev > > > *subdev, > > > > crop->height = MT9P031_WINDOW_HEIGHT_DEF; > > > > > > > > format = __mt9p031_get_pad_format(mt9p031, sd_state, 0, which); > > > > - > > > > - if (mt9p031->model == MT9P031_MODEL_MONOCHROME) > > > > - format->code = MEDIA_BUS_FMT_Y12_1X12; > > > > - else > > > > - format->code = MEDIA_BUS_FMT_SGRBG12_1X12; > > > > - > > > > + format->code = mt9p031->code; > > > > format->width = MT9P031_WINDOW_WIDTH_DEF; > > > > format->height = MT9P031_WINDOW_HEIGHT_DEF; > > > > format->field = V4L2_FIELD_NONE; > > > > @@ -1104,7 +1094,6 @@ mt9p031_get_pdata(struct i2c_client *client) > > > > > > > > static int mt9p031_probe(struct i2c_client *client) { > > > > - const struct i2c_device_id *did = i2c_client_get_device_id(client); > > > > struct mt9p031_platform_data *pdata = mt9p031_get_pdata(client); > > > > struct i2c_adapter *adapter = client->adapter; > > > > struct mt9p031 *mt9p031; > > > > @@ -1129,7 +1118,7 @@ static int mt9p031_probe(struct i2c_client *client) > > > > mt9p031->pdata = pdata; > > > > mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF; > > > > mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC; > > > > - mt9p031->model = did->driver_data; > > > > + mt9p031->code = (uintptr_t)i2c_get_match_data(client); > > > > > > > > mt9p031->regulators[0].supply = "vdd"; > > > > mt9p031->regulators[1].supply = "vdd_io"; > > > > @@ -1226,19 +1215,19 @@ static void mt9p031_remove(struct i2c_client > > > *client) > > > > } > > > > > > > > static const struct i2c_device_id mt9p031_id[] = { > > > > - { "mt9p006", MT9P031_MODEL_COLOR }, > > > > - { "mt9p031", MT9P031_MODEL_COLOR }, > > > > - { "mt9p031m", MT9P031_MODEL_MONOCHROME }, > > > > - { } > > > > + { "mt9p006", MEDIA_BUS_FMT_SGRBG12_1X12 }, > > > > + { "mt9p031", MEDIA_BUS_FMT_SGRBG12_1X12 }, > > > > + { "mt9p031m", MEDIA_BUS_FMT_Y12_1X12 }, > > > > + { /* sentinel */ } > > > > }; > > > > MODULE_DEVICE_TABLE(i2c, mt9p031_id); > > > > > > > > #if IS_ENABLED(CONFIG_OF) > > > > static const struct of_device_id mt9p031_of_match[] = { > > > > - { .compatible = "aptina,mt9p006", }, > > > > - { .compatible = "aptina,mt9p031", }, > > > > - { .compatible = "aptina,mt9p031m", }, > > > > - { /* sentinel */ }, > > > > + { .compatible = "aptina,mt9p006", .data = (void > > > *)MEDIA_BUS_FMT_SGRBG12_1X12 }, > > > > + { .compatible = "aptina,mt9p031", .data = (void > > > *)MEDIA_BUS_FMT_SGRBG12_1X12 }, > > > > + { .compatible = "aptina,mt9p031m", .data = (void > > > *)MEDIA_BUS_FMT_Y12_1X12 }, > > > > + { /* sentinel */ } > > > > > > I know it might sound not necessary, but isn't it better to wrap the > > > format in some sort of per-model structure. It would avoid a few type > > > casts too. Up to you though > > > > The problem with structure is, it will have one > > variable entry. I got some feedback related to similar > > patches not to add a single variable to structure > > and use the value directly instead. > > > > Ok then, a matter of preferences I think. Up to you, really. Seems like I forgot to send a tag after your reply! Reviewed-by: Jacopo Mondi Thanks j > > Cheers > j > > > Cheers, > > Biju > > > > > > > > > }; > > > > MODULE_DEVICE_TABLE(of, mt9p031_of_match); > > > > #endif > > > > -- > > > > 2.25.1 > > > >