Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp271806rdh; Sat, 23 Sep 2023 09:38:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjdeo45Z9ca6hZN5iq7ksF9GEkdLVZ7pkLoJ/cJMK9NNb3VzhagGUl8cWKIoLK/l2MLKL3 X-Received: by 2002:a17:90a:4149:b0:273:f887:be17 with SMTP id m9-20020a17090a414900b00273f887be17mr2482716pjg.47.1695487104558; Sat, 23 Sep 2023 09:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695487104; cv=none; d=google.com; s=arc-20160816; b=Y1rH7a2bQztMliXY/2pdTw3rZawtuiVzsJSPjBNYyGP3TBH+YzZT3rhzkQBa0Wmpq4 VjUGQSezKrxQseT77w0G/KdhT8fXih7C7QAzQIzR+XSGPK17tQ9IxrJj1furCuOddpVe ApAiBK33M4RdbKllCmwH6EMUbWIvX9fg/MUcDRcNqURWxJd5flYIYjlqrSncHffkYfN8 YsXNVs7KFZEO7VvL8xQepbrii1KuB6XtXYl3opd6aIOsQpzaTDWppqmeEwu2w8OlxyAU 8UN+zgtACC5osNFrqAKI5+5mJKhywJgcw+PzRm71pyxEpDPrFN/NNuWXtT7gPKmP1HvI mkOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VZDFMOy2yT2TVGzTeS70umsc80OcbM3n0mypk5zCLZU=; fh=8XHVssQkGTmj2o3ixJJcc9X3fkVzFlM7u16K5Pbqh9w=; b=RzV/rgE8ff+l6HYzDATFxEsKhuzzbPggoIxbKy05bhOi//4phoKcF+wb6kqM60k2Nd VojzT7aPHLOvV4vOQhU4h7tT2/icTG2ZcJmBI3CjVxeepPN6nqOw3YJGPOkMSS3AyTUq 1JpOqiG5/BV5UuduZ5KBn+5mpUe0S8VDHwFymSkt8XbAVqAbESakicnY3O3hH97Z0bkJ WZhWHOzUlA/ewiRpMp4yZ5XWiDgpEV1jGtvA8h+lOlN9QhiLV7lEK0YNh91wTdtLoRIg LD5b3+30vU1zz+xXT2Au5tR4sCEkfFg+NtEejgOOME4PsP326DFgoHc4/d7LNvRznrff uJwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bb3-20020a17090b008300b00271bea73dcesi8324733pjb.96.2023.09.23.09.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 09:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D7E9380A07D2; Sat, 23 Sep 2023 09:37:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232018AbjIWQhB (ORCPT + 99 others); Sat, 23 Sep 2023 12:37:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbjIWQg6 (ORCPT ); Sat, 23 Sep 2023 12:36:58 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 99280139; Sat, 23 Sep 2023 09:36:51 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.03,171,1694703600"; d="scan'208";a="180728098" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 24 Sep 2023 01:36:51 +0900 Received: from localhost.localdomain (unknown [10.226.92.12]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 66BA4401DDFD; Sun, 24 Sep 2023 01:36:48 +0900 (JST) From: Biju Das To: Mauro Carvalho Chehab Cc: Biju Das , Hans Verkuil , Jacopo Mondi , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Biju Das , Andy Shevchenko Subject: [PATCH v2 1/3] media: tvp541x: Extend match support for OF tables Date: Sat, 23 Sep 2023 17:36:39 +0100 Message-Id: <20230923163641.31685-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230923163641.31685-1-biju.das.jz@bp.renesas.com> References: <20230923163641.31685-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Sat, 23 Sep 2023 09:37:05 -0700 (PDT) X-Spam-Level: ** 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 tvp514x_reg 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(). 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 Reviewed-by: Jacopo Mondi --- v1->v2: * Added Rb tag from Jacopo. --- drivers/media/i2c/tvp514x.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index aa6d4b67b6d5..4d0ffaa312c5 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -118,7 +118,7 @@ struct tvp514x_decoder { struct media_pad pad; struct v4l2_mbus_framefmt format; - struct tvp514x_reg *int_seq; + const struct tvp514x_reg *int_seq; }; /* TVP514x default register values */ @@ -1024,7 +1024,6 @@ tvp514x_get_pdata(struct i2c_client *client) static int tvp514x_probe(struct i2c_client *client) { - const struct i2c_device_id *id = i2c_client_get_device_id(client); struct tvp514x_platform_data *pdata = tvp514x_get_pdata(client); struct tvp514x_decoder *decoder; struct v4l2_subdev *sd; @@ -1049,7 +1048,7 @@ tvp514x_probe(struct i2c_client *client) memcpy(decoder->tvp514x_regs, tvp514x_reg_list_default, sizeof(tvp514x_reg_list_default)); - decoder->int_seq = (struct tvp514x_reg *)id->driver_data; + decoder->int_seq = i2c_get_match_data(client); /* Copy board specific information here */ decoder->pdata = pdata; @@ -1183,22 +1182,21 @@ static const struct tvp514x_reg tvp514xm_init_reg_seq[] = { * driver_data - Driver data */ static const struct i2c_device_id tvp514x_id[] = { - {"tvp5146", (unsigned long)tvp5146_init_reg_seq}, - {"tvp5146m2", (unsigned long)tvp514xm_init_reg_seq}, - {"tvp5147", (unsigned long)tvp5147_init_reg_seq}, - {"tvp5147m1", (unsigned long)tvp514xm_init_reg_seq}, - {}, + {"tvp5146", (kernel_ulong_t)tvp5146_init_reg_seq }, + {"tvp5146m2", (kernel_ulong_t)tvp514xm_init_reg_seq }, + {"tvp5147", (kernel_ulong_t)tvp5147_init_reg_seq }, + {"tvp5147m1", (kernel_ulong_t)tvp514xm_init_reg_seq }, + { /* sentinel */ } }; - MODULE_DEVICE_TABLE(i2c, tvp514x_id); #if IS_ENABLED(CONFIG_OF) static const struct of_device_id tvp514x_of_match[] = { - { .compatible = "ti,tvp5146", }, - { .compatible = "ti,tvp5146m2", }, - { .compatible = "ti,tvp5147", }, - { .compatible = "ti,tvp5147m1", }, - { /* sentinel */ }, + { .compatible = "ti,tvp5146", .data = tvp5146_init_reg_seq }, + { .compatible = "ti,tvp5146m2", .data = tvp514xm_init_reg_seq }, + { .compatible = "ti,tvp5147", .data = tvp5147_init_reg_seq }, + { .compatible = "ti,tvp5147m1", .data = tvp514xm_init_reg_seq }, + { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, tvp514x_of_match); #endif -- 2.25.1