Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp740709pxp; Fri, 11 Mar 2022 13:54:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOku+PZ9Hp5KVnhmpSqu4FJ5qGGH3F2UFdL9/SPKsgwV2KFfFSPDhDKlvhNJnMX+Wny9zg X-Received: by 2002:a63:2c4c:0:b0:37c:4690:d4f1 with SMTP id s73-20020a632c4c000000b0037c4690d4f1mr10291059pgs.40.1647035654549; Fri, 11 Mar 2022 13:54:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647035654; cv=none; d=google.com; s=arc-20160816; b=AvajYcpjxMS4rwrDfmfbU10asrbbfqBBSfQdcolyBmsjvwy8J3NK33BPCuWQ0mYSdc xCUbwite0kB0tCgHwrc5OlRRq4a5gCvrQfxykQMKJozxmgHNEOfZaGJfWpA+muCaQ1KC BX3tKeXHbpJqQZhTwdg6+Jju34U3KLuAKSAzoq1W+0CoqXfgtkPq7KlPY2AWJNmZaeuf Pi8vt+fG8ueFj9cxm3mLMxD7dwr9tXnILoEbFU7/zGKdocQ+zCDR45+iYiETxd8Ij7AY s7PmpT8SF8kyjbUM1IBxQxDqlwZetgFekPToxsaVT8UhnN1sLTw00FZ1fgsqPxLJn9va 3XjQ== 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; bh=rakVj5nKmN3dzQbEyGvHwMe7KP1C98Aj0gcHX84SbjM=; b=lFMR79WyIaDkebY7hFbrzH7VN1lnYyhNppDPF3U+J/cxnoKsaQ32TNU+/YVy8g5E0B fvlcb9oPlwtP5FzKs8ko3z6e15vKfHvY1Y+lhlbOp2cl0X2f2786neaLPoAzUneBiIRP CClWA6lPD6VvZfZ4h13/92lUbyNYk0y/s5uVrH6TMbTK8ohcahlupu5/z5Nsy6ahYISU R4z4K0FWKLVXSjvwAmoTkvGdo07xozu3yClvIoE+qednd5GXKkpBkqJf9ePyZX5usuvi +tIV9d2uX8l+EM4a4AGI7A6Vhh1w7nJN8uu3dUlJlS/pu/GQQYtAXM4JkoIPT9Bo4RO8 JJ1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d16-20020a17090a02d000b001bf8183e587si8912394pjd.157.2022.03.11.13.54.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 13:54:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 AB003291390; Fri, 11 Mar 2022 13:13:10 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345214AbiCKLhU (ORCPT + 99 others); Fri, 11 Mar 2022 06:37:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237792AbiCKLhT (ORCPT ); Fri, 11 Mar 2022 06:37:19 -0500 Received: from mx1.smtp.larsendata.com (mx1.smtp.larsendata.com [91.221.196.215]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 590AD1C0251 for ; Fri, 11 Mar 2022 03:36:15 -0800 (PST) Received: from mail01.mxhotel.dk (mail01.mxhotel.dk [91.221.196.236]) by mx1.smtp.larsendata.com (Halon) with ESMTPS id 75b78978-a12f-11ec-9faa-0050568c148b; Fri, 11 Mar 2022 11:36:15 +0000 (UTC) Received: from ravnborg.org (80-162-45-141-cable.dk.customer.tdc.net [80.162.45.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sam@ravnborg.org) by mail01.mxhotel.dk (Postfix) with ESMTPSA id 6F2BC194B58; Fri, 11 Mar 2022 12:36:13 +0100 (CET) Date: Fri, 11 Mar 2022 12:36:09 +0100 X-Report-Abuse-To: abuse@mxhotel.dk From: Sam Ravnborg To: Xin Ji 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: References: <20220311103525.1431890-1-xji@analogixsemi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220311103525.1431890-1-xji@analogixsemi.com> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Sam