Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2013350rdh; Sat, 25 Nov 2023 10:08:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEx03at3BXxlfYR6CblBN5N/GO3u2uARgrpDSqXXnBjQc6vIzwiVGasfStH0cuuxgYEc61g X-Received: by 2002:a05:6a20:729e:b0:18a:f5df:5f88 with SMTP id o30-20020a056a20729e00b0018af5df5f88mr7561569pzk.62.1700935687306; Sat, 25 Nov 2023 10:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700935687; cv=none; d=google.com; s=arc-20160816; b=DQnWNIw2LdTIbrfI5BYy8z4V9FxBclLVSbovzHC+AXyEes0ctfh3Lg9cqPXb7ZTYPc u2TKYY4fbkjP2AzWOtDTILTBN2GBC1P8+JMZSCOLeq197edctsecq1leDG/A3kGNQv7j Qn25MhrPE/A7COCShJxWfPhoocsGgiGK8jCFHo7R4MIWVRTTLV86DaJgDijx6ZusNYGs 52XRT2aDPC4JH8cW5rjOgHSxZ9YOCAcJ88rPPPNAzlLdclmeJWwVny2zrF+mN7AYaL9a na52syFbiZm1lq5alIgRkQs+L53ODChtX1Nw0Txa1DyqhoxWHwUTORv7AKbV01pkP4W1 SYdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=rf1UeNIRXctn3mVzYQjw1tJtVDq96pT0gvt6sq5/Loo=; fh=tBEha94wb8TYo/TSTSJFhkHItRzkFbKn9wwDzTmw53g=; b=lfG510jtlR/8rs5nyTcldoWnRNwzM7EgQIvfMuhBbA8n0k1zqwx9iH6hNl06ckP2hK OIueAxDDLxuU3Onc4UMAxu3MHb2DaxTgvqTj4opTcCoXSwtmKWYOEajQnB+iTIUqZGww 3ShvpaxzEGTF8MpT9KxKYr5lPOg0pP/Eyvv5cCIWmAsPFIzt1yGt+cvLYALmoke24EII gAGSMg+WhR7p4akmzArVt2Pp1liWx7D87IwhrrqVOEs0G8ZsIjxzpbFnwZd+/fyiA7Iu GTqtAObPo9c7q95YKx/NiXLtGN87SMm1V0xN+fg9TawxQpB1Izf+1jOOmW5iI4Y++8Gj aj5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZHWs9XD8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id p6-20020a634206000000b005bddee56e49si6077376pga.72.2023.11.25.10.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 10:08:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZHWs9XD8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A0EDB8022EA4; Sat, 25 Nov 2023 10:08:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbjKYSEW (ORCPT + 99 others); Sat, 25 Nov 2023 13:04:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjKYSEV (ORCPT ); Sat, 25 Nov 2023 13:04:21 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71C71119 for ; Sat, 25 Nov 2023 10:04:28 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BE82C433CB; Sat, 25 Nov 2023 18:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700935468; bh=rf1UeNIRXctn3mVzYQjw1tJtVDq96pT0gvt6sq5/Loo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZHWs9XD836tTt9B0pc1D7TQ12qWVbxRGJQ6ly+ESEvA1jJn87748DqpBdT+qGlXOs co5+1Mc8KqBt06NxwV49RxSsy8GEFxYe+2cTBdmjSWLjx/db7OdgRTAsnxpfTb2Qpp f+4ytmqiPJCfmVgFb2z93hyJ/MVc0ucslxI7UEB3xy/6GTXFKCZm9eGZnb/s7Iuqzp qUeS84Hk5DI6kN7BczcVPPD85keRFfi0601C+w/TXgvpoDAymvTDgGrp7siSbRn9zy CQnrZjnYUtwrqCsrn8NNnxzO7w52BQyRtLX4EF1buLgfUvvm78rpKAjPTOB3MUaD1z v7X3h9FOQk+NQ== Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-1fa20395185so378778fac.3; Sat, 25 Nov 2023 10:04:28 -0800 (PST) X-Gm-Message-State: AOJu0YzS84PLoV8lJZiwe5hvg0Jh6S73iS1CFpwWCWy/yHGvxcFRHcJQ 50jpcouW0YT0CXVY6FJTe1eHIKRct8665GqHsqw= X-Received: by 2002:a05:6870:96a1:b0:1f4:d2df:c53c with SMTP id o33-20020a05687096a100b001f4d2dfc53cmr8467797oaq.24.1700935467337; Sat, 25 Nov 2023 10:04:27 -0800 (PST) MIME-Version: 1.0 References: <20231120222832.4063882-1-masahiroy@kernel.org> <20231120222832.4063882-2-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Sun, 26 Nov 2023 03:03:50 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] pinctrl: pinconf-generic: resize the pin config array directly To: Andy Shevchenko Cc: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Sat, 25 Nov 2023 10:08:04 -0800 (PST) On Fri, Nov 24, 2023 at 8:25=E2=80=AFPM Andy Shevchenko wrote: > > On Fri, Nov 24, 2023 at 11:06:50AM +0100, Linus Walleij wrote: > > On Tue, Nov 21, 2023 at 11:21=E2=80=AFAM Masahiro Yamada wrote: > > > On Tue, Nov 21, 2023 at 7:28=E2=80=AFAM Masahiro Yamada wrote: > > > > > > > > pinconf_generic_parse_dt_config() allocates memory that is large en= ough > > > > to contain all the config parameters. Then, kmemdup() copies the fo= und > > > > configs to the memory with the exact size. > > > > > > > > There is no need to allocate memory twice; you can directly resize = the > > > > initial memory using krealloc_array(). > > > > > > > > I also changed kcalloc() to kmalloc_array() to keep the consistency= with > > > > krealloc_array(). This change has no impact because you do not need= to > > > > zero out the 'cfg' array. > > > > > > > > Signed-off-by: Masahiro Yamada > > > > > > Sorry, I retract this patch set. > > > > > > krealloc() does not save any memory > > > when the new_size is smaller than the current size. > > > > But the first part where you switch to kmalloc_array() is still a nice = change. > > > > The fact that we use kmemdup to be able to also shrink the allocation i= s a > > bit of an oddity I guess, but let's run this patch by Andy Shevchenko, = and > > ask what he thinks about simply introducing kmemdup_array() or if he > > has other ideas for this. > > https://lore.kernel.org/all/20231017052322.2636-2-kkartik@nvidia.com/ Ok, I will come back when kmemdup_array() is upstreamed. > -- > With Best Regards, > Andy Shevchenko > > --=20 Best Regards Masahiro Yamada