Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp9931200rwr; Fri, 12 May 2023 01:02:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ43P9QkiBW0GWI6JO0EVbRJfpTmJ6w3XqVSPd/0GobRycn7F4kNr6jwIIUUIvzkFRx3rj1e X-Received: by 2002:a17:902:f547:b0:1aa:fbaa:ee01 with SMTP id h7-20020a170902f54700b001aafbaaee01mr29398551plf.48.1683878579191; Fri, 12 May 2023 01:02:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683878579; cv=pass; d=google.com; s=arc-20160816; b=WXa8tQq2UNpb+8pbYgJLThgunWbURG1NWoecp+e9JVwZa0p2XsSX21D4Y+mqkmtR8P avphDREtmh382MzZwxhogDcreLNE0vvlgbseq08h3c4z+8yPm/6FVpWj2EG3IzKc+640 2eY0btAPS8IA2lEUa4LSAd7VbWfVex7w3XyrAJODjApa9Wqw0gVfMQWIKubnsPK7/tze p4Qz4O2M4bx5wIPjZdMlhO6wDg8xzG/0AZibXpTGV8U/m2FOZe7JV/FOIOhjL0xRIeAR kBdgrpTeGsqJvfPiT2xfnZP9C97fHgSgZgU8iLAOaKgpmc6CXy7Y5pgVgRYeGwjQzEua j+Aw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:references:cc:to:from:subject:user-agent:date :message-id:dkim-signature; bh=7TG3JxEARI2CsqsflwkOh/VRCdbCHKPbi5hFThvkKG0=; b=QztxSkTdk5F/mMxFRwih3cK9l5Klfj7WFfzub1ZrvSIaqHZvqGmkJo3mn+9Ytf8hga aUsNIgiBC9/DP6tE/grtIvlIzazRQpuvxzBulBsVEOK+NgP4owDU16S25epT/4J/VRs3 7/3Uw381sKYPBlfx5nAMKcuTxTyar7ISo/Ui7sH/kqC+dC73HB7Sk1giyLv4Ajt4yAN1 cS4FNwU/lfhxc2RpIO89b9Y9dcYjLEgd2fP2MHseaLrmDuR4PP7814VpGp8jbfHHXRBb nSnR3D2mj0Drsw2mycwNzWLFdKU8i8QPX6SazQYbzbxNG7nWd1/AXRYa1D0Tgu+26pBN /jvg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=TDYbQw8X; arc=pass (i=1); 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t12-20020a170902e84c00b001a97bf417cdsi9934946plg.571.2023.05.12.01.02.44; Fri, 12 May 2023 01:02:59 -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=@outlook.com header.s=selector1 header.b=TDYbQw8X; arc=pass (i=1); 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240286AbjELHhi (ORCPT + 99 others); Fri, 12 May 2023 03:37:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240263AbjELHhc (ORCPT ); Fri, 12 May 2023 03:37:32 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01olkn2041.outbound.protection.outlook.com [40.92.52.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1562DC71; Fri, 12 May 2023 00:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M3Sqjm90CDc5zl8oBDEIJLQveT62PawK3smnyqqFjhJzEqiIIGCNj3FTYRJohvOIVQHsjqsGw+pLtieyn6IC/fiLbUNHvDvgZ8h16NMItiyhx/Q/3Xw5Cw+kGT4XW01Bd6VxOrDwy4fE8qgj8abeb0KRCDslDa6OmSL4P0Z8xpHQbEkFqlqSaP9yBxo/5hbN6T0OsKZHMCcNs3R6OXQ3pEgYW7VHDh/otP/8ZvospM3Y3eo+8rIEOm+0Af62RGmMOv2YLeXI+ebJZdPegUcV7t11Oz69sguYhKvlqaMDMwZruWU0G8v50Bm7jc30LLDPhHXyKdmtzfVkc/MHybfudw== 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=7TG3JxEARI2CsqsflwkOh/VRCdbCHKPbi5hFThvkKG0=; b=ma5+4zeXGBQ+eaBc5WMOmaDkpCj61DHisT2yx4tMNWPUjeRyCKthq+Vpma1MvVe8Wn/MLgDXYhMNKGxILSt92N0/oKVXhFSiEy+k5jm7oUbR+OTmk9LuKidG7JcU6hHtv/Xz7pwvIq0NFqicSmg4H0/Jx1TWsc5SZ9oBpiENHum5QBADorl0TipGP5ohOUYYqAliebaUIDZBJnG42V3WQKgaCx2hGAwbxH5mPdO07ZJS5JEQHFLrm5yfxKL6MtFHrTz4zze2OOHPvvFPu5w9vK7kSTmpBil6DdVCllnDvPRrAH80aYJIT7XiE8mcprEXLpewbtCpnBhsZfqpHKBDIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7TG3JxEARI2CsqsflwkOh/VRCdbCHKPbi5hFThvkKG0=; b=TDYbQw8XhJVWAYhJONpAzM3SfJRjd1qj1kNzP6leBgTyPobpZfVWb7grdruD3UqxXbYpCM3IGP4MEy/qCQYED14sJEFg7tbu8QNPIcyJHj1wpzg8glQCSrD2Uq8VR2yYHS839cYIu6nnl+iGYx8BCozBFh6m0UWqMRTwZA9R/eKJ5LiK2NUxPV/gTQbXBCPofev81z0j7LiIr7xxkFPEsGPDa6S3SMoHUOpF1yh9BELX3eOyrTZdzsvtyx35mrlhqd299msiNw9c7ZHwNiyT59zZ6QVhQM71bvRt6fXNi/gkguHJ18xgDo+2FT4kTfmt5Ojzqom+H704xntjWT1Ycg== Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) by PUZPR01MB5261.apcprd01.prod.exchangelabs.com (2603:1096:301:11b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Fri, 12 May 2023 07:37:20 +0000 Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com ([fe80::93cb:1631:4c4c:1821]) by KL1PR01MB5448.apcprd01.prod.exchangelabs.com ([fe80::93cb:1631:4c4c:1821%4]) with mapi id 15.20.6387.018; Fri, 12 May 2023 07:37:20 +0000 Message-ID: Date: Fri, 12 May 2023 15:37:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v2] gpio: gpiolib: clear the array_info's memory space From: Yan Wang To: Andy Shevchenko Cc: linus.walleij@linaro.org, brgl@bgdev.pl, "open list:GPIO SUBSYSTEM" , open list References: <202304232146.7M89pwCz-lkp@intel.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TMN: [/On2VNSdjSAj8zQjQ/l+dJ4x0I73i1ov] X-ClientProxiedBy: TYCP286CA0324.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3b7::12) To KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR01MB5448:EE_|PUZPR01MB5261:EE_ X-MS-Office365-Filtering-Correlation-Id: 02300722-6114-4b4b-ff8c-08db52bbb7d5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pB9E1+ELTVIKYBILEoMaO3OGEIWCyVzuK8tnMThdy6rYj458B3aZqgOHV8ytICRzVqeqeTqVQ2KZGRhSj6V6jL4Svfmn/tC8R4VEXPQvanTIYWvhCx4+vdp4QhsALhLV1N9tCcSNdBjYXFvwBqqzX4zYEzzXSwjfaRPLqn7sjUUJQaN8cKw8cOxsTOug4BqL5xlyA8CYe1r6YM4dYvAi3jf/bqtyfWgD9Aa+bDICfr7xUdPNQ9E+K1VQQIMx/hnjDKnIxf6tuSF1L0ZjBcZeOxJWvkGwwNfAnRPy1jDuRobXSoU727HY5BqUvjTKpRDuAFeXkCs6q4qzuRuRafkyrxUBNA+I56GwIYg8rFxiTLGee5f9u+IFASu6rYwVH3ww3W40OLf7fRGjT/gtb2oNZA32Ejfv6B1PdKRFfqZ+KAw9R/37oihiv/lnmpvsoP8uBuiQjG/iiauqhOPv44zyVl10jZsLkD986vv1Z+OLA75YdH2L0stqdbsxX4KlOwgUAwb3Wb+qzpHxVPmzqSYGV2qBgQ6+3MG72zAomNSIEw3Y6+7UX9D95xufyubhY96IdqeBy7r3K83z0pgTDyWyOmblTBersTord1hkpoxczCU= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UTZmSHBNL2tiK2xuSmQ2eDk5VnlIUlNmc0FRejB1K2I3WWxLZW9vRWtpaj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L1IwTzJEOGVJeHpHSytHSzVGc1g3?= =?utf-8?B?YjhVcUIzL3FXeGYyTVI5blRqOXZZdnR3TTFjTU1lTElhdnByOVNzZ0xQT2Yv?= =?utf-8?B?Zmt3VVM0Rm5JN2JpRENuWkZKekVBM0R4elpTaWhSekxUSC94WUI1RmdGSCtq?= =?utf-8?B?Q3JLU2RLRkVrMk5BMWUzUlBxcE85NERUSEZDK0sxOXlCVW5TcGI2K2s5QzVa?= =?utf-8?B?QmpwYUY3b01VUUNqVTJKQU5xZjB5WTFoRHcrZC9Xa2ljMkU1cFpLNGRRSGtz?= =?utf-8?B?cnVMWkhESmlNUk5oUkVDNmR5Y3lWWWZEL3pENUViZ3BjczB4V3Z6ZEM2cGlC?= =?utf-8?B?UlcrenQvUFlxUFo2LzR3b1RpV3hjUTRmZVFJVzZTREs5NmlRVWhkeS93WWFj?= =?utf-8?B?enpoOTc3ZTRaT29VVXhvQkJLYXlZVjFqUE1PTVF1VStkYXdJVlZLK1Y5RDhC?= =?utf-8?B?ZFBhQTZRZGJONlhlYTRqMU1HNE83Tk1Tak1mRkN4MEhid01vbnhqcFdJSk11?= =?utf-8?B?M0ZPTzRTeVNWSzVIQ1N6dU11Q1BrNTBxOWNBdVI2UHgvRUJlYWRkZnhObnEz?= =?utf-8?B?SG9nTHdJMDhxd2NtbUo5dWcvOEtMNnU2b0F0YWYwdUZ4aXlEaGVCbXZUSURj?= =?utf-8?B?SkowQWc2TXNIQklVQlhEc2tZTXpVMkxSNUU2T3I1TVpiK0Zzdll1VEhiK1Vm?= =?utf-8?B?R0JscGdsV3MrY3ozS3BOcit0K3d0Ync9PQ==?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02300722-6114-4b4b-ff8c-08db52bbb7d5 X-MS-Exchange-CrossTenant-AuthSource: KL1PR01MB5448.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 07:37:20.1437 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR01MB5261 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_MUA_MOZILLA, FREEMAIL_FROM,NICE_REPLY_A,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 Polite ping On 5/4/2023 10:15 PM, Yan Wang wrote: > >> On May 4, 2023, at 19:36, Andy Shevchenko wrote: >> >> On Thu, May 4, 2023 at 12:38 PM Yan Wang wrote: >>> On 4/26/2023 10:42 PM, andy.shevchenko@gmail.com wrote: >>>> Sun, Apr 23, 2023 at 09:59:43PM +0800, Yan Wang kirjoitti: >>>>> if hardware number different to array index,it needs to clear to points >>>>> memory space if the array_info have been assigned a value. >>>> Can you explain a bit more what's going on there? >> ... >> >>> I use gpiod_get_array() to get a gpio array form the node of DTS. >>> >>> the node is as follows: >>> ... >>> gpios = <&gpio1 0 0>, <&gpio1 10 0>; >>> ... >>> >>> First scan pin-0 of gpio1,its index and hardware number are 0, >>> >>> if (descs->ndescs == 0 && gpio_chip_hwgpio(desc) == 0) { >>> ... >>> descs->info = array_info. >>> } >>> >>> Then scan pin-10 , its index is 1 ,but hardware number is 10 . >>> >>> if (gpio_chip_hwgpio(desc) != descs->ndescs) { >>> array_info = NULL; >>> } >>> just set array_info = NULL, Should the array_info point to memory be >>> cleared ? >> This is a good question. The entire algorithm is a bit difficult to >> understand from the first glance. I need some time to check it myself. > Looking forward to your test results. >>> if not cleared ,I use the gpiod_set_array_value_cansleep() to pull up or >>> down pin-10 is invalid. >> I'm not sure I follow. The array operations are against the given >> array of the descriptors. If you ask to have that operation done, the >> all descriptors in the array should be considered. >> >>> I found that the set_mask and get_mask vlaues of descs->info are seted >>> 0x03 in gpiod_get_array(), >> Yes, this mask is for the argument. The 0x03 is the correct one. >> >>> I think 0x401 is their correct value. >> No. You have an array of two elements, and not 11. > Due to hardware number are 10 and 0 , so this mask is 0x401(bit10 and bit0 are 1). > >>>>> if (bitmap_full(array_info->get_mask, descs->ndescs)) { >>>>> + /*clear descs->info*/ >>>>> + memset(array_info, 0, sizeof(struct gpio_array)); >>>>> array_info = NULL; >>>>> } >> >> -- >> With Best Regards, >> Andy Shevchenko