Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2785893pxp; Mon, 14 Mar 2022 05:05:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz15rFH8Zuzqz+4gSLq9wpTt98lGi2kzZvCZbljvT6pClxLskH642GlfnJe949GarG7DXSC X-Received: by 2002:a17:906:7fc9:b0:6cf:d288:c9ef with SMTP id r9-20020a1709067fc900b006cfd288c9efmr17942916ejs.751.1647259515057; Mon, 14 Mar 2022 05:05:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1647259515; cv=pass; d=google.com; s=arc-20160816; b=cGfBwOJC1jsYwr2dRewfiqw9qVO4nstYN6t1f76ndZUkc/JNbPJ5sTjGU0hriWdmuX IcMJMIq0ZOJhwxB92bMedaXYUjkoK2b468zfcyJWdqWDJbfJiATxFguLNARGcmCh0D9W Sc3OkUnHcaW540UK340egtsF0hnyTz11Yif/f2S3ZnBsynTfMVGgjbeNN4iA0hBJnEUY BR87sx+2t0R7dPmQUNXvaq/nbi6sA45wAosCRN1m3JpdpuhbiekmAEs8SMdLmUY/BToz pUihRsxqqsKV36PhEKwuzxY4hFZ8elGebTj9xRXknHBP1am674SYnukZnBJyGhgIs2dd uFxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/1EWuJCYgkEn7BWZMXXvwk512lxER99LoaJFjH5Vsp0=; b=i1Xuz04yD0AChgnHshyfdN6/tal8rvFotBy4Sr3XsHcRaE4tfJjNMbULKnZhFOiSvN GX+bGbcs1ztE5CgFvEQEeW+/JnHbOgbKugNMIRcoN1X6+flVwTs7CGsjwbQMEKmd3CbY RQw/bsmo1WwtzNkVo9qYFvtjuRXXDxfj79Q8+bKyigcNN0DlL11rtRTBWgnWY5QywGBO s+Rzk/arohwrJAe+lI00hfZ2IjuTFaOZjtUFZ5aN+nddxv0xWxHUZ36C4croXmZI9I2g qqVp6eVIl8Fdz2nbRLkQ6Lg0INa2Crfx7J9yHCbsY9Tog19zk9Sklbhw9qqfEn7wLrv0 vCeg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Analogixsemi.onmicrosoft.com header.s=selector2-Analogixsemi-onmicrosoft-com header.b=F0i4C7mU; arc=pass (i=1 spf=pass spfdomain=analogixsemi.com dkim=pass dkdomain=analogixsemi.com dmarc=pass fromdomain=analogixsemi.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analogixsemi.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h24-20020a170906399800b006d1ad1eea41si8444363eje.423.2022.03.14.05.04.46; Mon, 14 Mar 2022 05:05:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Analogixsemi.onmicrosoft.com header.s=selector2-Analogixsemi-onmicrosoft-com header.b=F0i4C7mU; arc=pass (i=1 spf=pass spfdomain=analogixsemi.com dkim=pass dkdomain=analogixsemi.com dmarc=pass fromdomain=analogixsemi.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analogixsemi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236331AbiCNGFe (ORCPT + 99 others); Mon, 14 Mar 2022 02:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236314AbiCNGFc (ORCPT ); Mon, 14 Mar 2022 02:05:32 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2097.outbound.protection.outlook.com [40.107.92.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74FA711167 for ; Sun, 13 Mar 2022 23:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XFm+2dJRQsLEOf3mjTuusYttKWlBvq+ar3jBpkt8yW9VnY5lXXeSsKh2kfpsl3+DVJICCAEuQ8T7/mWz287wE8pC/8oWyNNAEI/5CzZ6tlnpNskKGh/umXQA8mAqcL+LwxivG4X0QpHQEs5st03kUb54iSm07gb4Xb0fB/twOQU1wEhZX9bA6YmYdgc6XgZYMX1BgnBRRis45z9GwEVMiGRcO3mEw1ew2Om4KaAILroSWI/JW6tGygu+iwvyaPN5aiokxw1ohahR14Q752kU4tHM5OxffzgCtPvDBRDR3YoYbTJE0a/khJOdWsptb8Z5fPn6lshDcCE5cNCtlJ+QWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/1EWuJCYgkEn7BWZMXXvwk512lxER99LoaJFjH5Vsp0=; b=VT7h2QiVI4iFxWzqcJEQFKG4vChK8hlIYQGXo+RvWkPtyyrHC868SNWdDgsZuHuMaX9T9yaZPTEJeFG5/9Ae/4ytz0m1upttFxxk6BQTqOd+VVpLwTUz8RqUQ2rsZR+hEc2g5nyv13jkMgWV4dn/SV0c8Ty9joQH+ubOrPQUg6tmT/+h8+ySQZCXG83TMWIvzd3t41vyW9D0Pn8yOWZJB77SQFL4Y/m/SGsOMK+NZVLiT8/4k4s0i1VbldIm7ED86UXqg3Hy2oV/NSDBXY+EFQBMarxu2csnO+aoXEZyQO52Jzw8CDVUPqWJ3Tm9WtjV5/HW8AOJD+88C38XWAI2Xg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=analogixsemi.com; dmarc=pass action=none header.from=analogixsemi.com; dkim=pass header.d=analogixsemi.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Analogixsemi.onmicrosoft.com; s=selector2-Analogixsemi-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/1EWuJCYgkEn7BWZMXXvwk512lxER99LoaJFjH5Vsp0=; b=F0i4C7mUdKgjvu6+7tDG4OYTLiQ0m7Yk23H3nEM9+DxJu0idzfZqxhnDYBMUTu4BDLroaMC7mxN4CNhvsYWbzibqHjK6CyIqPC918uIDZUkInCWhu1JSJi2m/yJqMEnhO4TfDjv2YWeiFOlGVmfSs9ddYReWlS3+WI3Ruc3dEZo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=analogixsemi.com; Received: from BY5PR04MB6739.namprd04.prod.outlook.com (2603:10b6:a03:229::8) by BN8PR04MB5651.namprd04.prod.outlook.com (2603:10b6:408:73::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.22; Mon, 14 Mar 2022 06:04:19 +0000 Received: from BY5PR04MB6739.namprd04.prod.outlook.com ([fe80::a865:6d10:c4a9:1142]) by BY5PR04MB6739.namprd04.prod.outlook.com ([fe80::a865:6d10:c4a9:1142%9]) with mapi id 15.20.5061.028; Mon, 14 Mar 2022 06:04:19 +0000 Date: Mon, 14 Mar 2022 14:04:11 +0800 From: Xin Ji To: Sam Ravnborg Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , qwen@analogixsemi.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, mliu@analogixsemi.com, hsinyi@chromium.org, bliang@analogixsemi.com Subject: Re: [PATCH v2] drm/bridge: anx7625: Fix not correct get property counts Message-ID: <20220314060411.GA1456403@anxtwsw-Precision-3640-Tower> References: <20220311103525.1431890-1-xji@analogixsemi.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: HK2PR02CA0218.apcprd02.prod.outlook.com (2603:1096:201:20::30) To BY5PR04MB6739.namprd04.prod.outlook.com (2603:10b6:a03:229::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: efa4340b-464d-43be-9e23-08da05807a38 X-MS-TrafficTypeDiagnostic: BN8PR04MB5651:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gni6gJJJDQHK9VnipZLR8t1PUY5a22KnPih1psIuSjFL2PerUCMjUOhNkHhsL7DmihvL3n5Mm2Ujr3h5xvFD2mTSaNA7LZnJxq1OyC+w6ThiwLP3Xwl3UM7JJRoSMQ1yNEmq7zTXg1/7fySy0d8qdL+y33ylwM6I3dE69ECqCVoQSNxhQlsU7USwzVWoEe1Qppqe5D3IwbQQsbf6upu+tjiiorEpI95FZW+wTFGTfYUcDf+ZyDw2NW8z+1SuOp+zHDnZRH9eH4ZwbNTBkq7FrouUd2/0Yf5yKxcYZw7u7fmIdqNhfoJIBV4KF5fxe3Zf6wrzYXUiFRzD1qsUBO666lpc1Al5YDq1vaH8Pwv98YHUNHJv5W8NA+gCxFOJLG8X9Q0JsENoFjwJ9LHNJqN607yHD8OdcI6/WRat4MSphCoEgq52WYNxW2Ll7qWkbeWjEo7sjTv+R7gF8utR1B3g9ZAkNlc5qHTGpyz8m+nvKxP1vMHMJ76NAhEqHbjS7EufSCG4CaOjxyohEGGQZMU8NUKt/fPzOUHswBIWhvyIQUkIhW3+lSH282WFTQXhv9b+SPRC/lyRM5TH8fbW563vKsNWvUdYVyDn9wS45elACAlPmp9+b0KBCOTtCqBbKEQNdGQwg26ov52+Lt4VwbgSz2qIIx8rRkAHqIgMDFEv9MagED2ovgEpMcL4VFX+Ya5P6drZ1ZZ2VKoY7sUPO72oSQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR04MB6739.namprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(7916004)(366004)(26005)(186003)(8676002)(66476007)(66556008)(4326008)(38100700002)(38350700002)(52116002)(55236004)(66946007)(8936002)(6666004)(6486002)(54906003)(1076003)(6916009)(508600001)(6506007)(86362001)(316002)(6512007)(9686003)(5660300002)(7416002)(33716001)(107886003)(33656002)(83380400001)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+dBXQ3uRzmG+QYRdtpBdPeAoGWmelgqwe4twqZD8Yr56kmEIR46mD3TMp2T1?= =?us-ascii?Q?Slx7C7fvdKEFTccRZPXeR01olvWJQtU8fpn6iEfOqZXyPaZuwPFNGWKPVWtr?= =?us-ascii?Q?pk3rKbqlZhtIbUf3hKCD3rgEJnZz1kVoPqti1GSJQgyA+E2dcViRfNclXzvw?= =?us-ascii?Q?Y0ILnINYjQprBfIovwJg5v4YLnzqJY7sQirC7jejfp/VexKOLQyX/YUAZXIQ?= =?us-ascii?Q?B/55nqowFMMuS9CHaFrvCZxecjPTxqYJIkb4qHmQ2pZ/8UD6e5iDhEd/t7JB?= =?us-ascii?Q?2MtP+04SyCXsyrz5qPZq0hTsSzV3XNj4myfd4ESjxK6zNsJfKr+6XlFgs7fL?= =?us-ascii?Q?uw+0EA3/eF3RIeMWlpcnd48qARof0NxEnmwBmACStvU4A/ivdLm/wHIjpsx4?= =?us-ascii?Q?MkSXEhQwkVEDRwMZpMNAlBPPM3a4MndM2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YY2SzvF1cMFiee4tPmTyG3DixampCsKamCSnGiLRQhUyWdkr1eFjCn29rfQ?= =?us-ascii?Q?Xw3KTBeBenEJjc/+DCmfKUIcNTGQlzb1P1XbaqF8WTINGyG2rorOdbjyHtMZ?= =?us-ascii?Q?n61eHM5YZZrJcWFpzqfd8Km2VAgiHIrq?= X-OriginatorOrg: analogixsemi.com X-MS-Exchange-CrossTenant-Network-Message-Id: efa4340b-464d-43be-9e23-08da05807a38 X-MS-Exchange-CrossTenant-AuthSource: BY5PR04MB6739.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2022 06:04:19.3329 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b099b0b4-f26c-4cf5-9a0f-d5be9acab205 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: R4PZSTeDL5sOuUGUIGtJwMmJtzr8cXQBeOn+epnAOVrecMofrvaN8AH3oDpydipOmsn8wNCFmEeyUHmTo5ZJCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR04MB5651 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 11, 2022 at 12:36:09PM +0100, Sam Ravnborg wrote: > Hi Xin. > > On Fri, Mar 11, 2022 at 06:35:25PM +0800, Xin Ji wrote: > > The property length which returns from "of_get_property", it means array > > bytes count if the property has prefix as "/bits/ 8". The driver should > > call function "of_property_read_u8_array" to get correct array value. > > > > Fixes: fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature") > > Signed-off-by: Xin Ji > > > > --- > > V1 -> V2: Fix Sam comment, use of_property_read_u8_array to get array > > value > > --- > > drivers/gpu/drm/bridge/analogix/anx7625.c | 8 ++++---- > > drivers/gpu/drm/bridge/analogix/anx7625.h | 4 ++-- > > 2 files changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c > > index c6a9a02ed762..628cbf769141 100644 > > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c > > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c > > @@ -1598,8 +1598,8 @@ static int anx7625_get_swing_setting(struct device *dev, > > num_regs = DP_TX_SWING_REG_CNT; > > > > pdata->dp_lane0_swing_reg_cnt = num_regs; > > - of_property_read_u32_array(dev->of_node, "analogix,lane0-swing", > > - pdata->lane0_reg_data, num_regs); > > + of_property_read_u8_array(dev->of_node, "analogix,lane0-swing", > > + pdata->lane0_reg_data, num_regs); > > The current implementation do a two step approach. First is find the > number of elements and then read the elements. > The number of elements is only used to limit what is read. > > I suggest to use: > > of_property_read_u8_array(dev->of_node, "analogix,lane0-swing", > pdata->lane0_reg_data, DP_TX_SWING_REG_CNT); > > Then you a guaranteed to read at maximum DP_TX_SWING_REG_CNT entries. > And as the number of elements is not stored anywhere that should be fine. > > This looks simpler and matches what we for example do in > drivers/gpu/drm/arm/malidp_drv.c - the only user in gpu/ of > of_property_read_u8_array(). Hi Sam, the property is variable, so need two steps to approach, first to get the property length, then to read the elements (the property length may between 1 to DP_TX_SWING_REG_CNT). If directly to read the element, I cannot exactly know how many registers need by configred. Thanks, Xin > > > Sam