Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp963882rdh; Fri, 24 Nov 2023 02:07:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEULUZ0cuLLTnRinqbL9bYidWECkee4R5XhvWrp4k9WBYZYdJfcjsIfAm2j2AZ5DaNsKk+x X-Received: by 2002:a05:6a20:7f83:b0:187:c3db:8999 with SMTP id d3-20020a056a207f8300b00187c3db8999mr2834528pzj.45.1700820437761; Fri, 24 Nov 2023 02:07:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700820437; cv=none; d=google.com; s=arc-20160816; b=aOnbZPJDy/TnPZmjoEAi3iIF4X/kzyQLzjfQky8AhPYdO4HDSpEDIXrGabTDvG8X2t 9ijfsShtiV3so3WOk6OUBeMN6p07Cfsq2h3sBde1NKMfylng/ZWN5QL0j0Law9b+hFxF 8g059USB6Ml/u/Mdz3QzPVvA/G+dS+bTbO94d53bFgm/If8GW1xuJxWG50URkOt40HKl nQ9mxHL2hr0glDDL8V4BALe8f8AFuTaKdzLSJSpkKpfPL8HG3wkM0Obm+ataDQeZvb9t 9nC1wBUeV4IyMIx4b1rVXLY3Uy0AvdoFhhQQJchkBNDS62iKgocS/Z7N2dlVBVkEqort K1aQ== 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=PWcP6gQgrwmdsnOkpH93ij3XRZvKw3Rujab02fsHwiU=; fh=07hlxaoJTWc5bCRlSCz2qwn+f5UzsXbAWszDKqAt3HE=; b=e83xKL0Z85ZGSBeI87uufvh4nB1B+n48N3narEiOdNCW6pMGRE01RTAKchoqUZedDy 8J75zXiC9LmZN45MEUfmm8+CurAfNxwfwNjSFEawY8VaPgi5W5VCDVTRuoGvVaUdzSxF fdT38gpVhPsmwZJzkRUSMZM2POpJs6XCdZb3ZxNXBF4lhewaC+NTxkhZtIvQ2LEoyMiE YDgtMIIHh/8nkOrSXQK3FaTqsF19mnvyezT2miK6GVhjTJTwkT6IxUgico9zSXe6WkMr ja5fDaVFhwNFHE/+z5Xwv3c+B9adRdjvILMYKnxtEjqtHsqwStQt7h51SlKMiK2nJr6E NmFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qxN5ioYE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q16-20020a631f50000000b00578c8ce14edsi3204361pgm.252.2023.11.24.02.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 02:07:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qxN5ioYE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 42A5A8049D66; Fri, 24 Nov 2023 02:07:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345457AbjKXKG7 (ORCPT + 99 others); Fri, 24 Nov 2023 05:06:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345451AbjKXKGz (ORCPT ); Fri, 24 Nov 2023 05:06:55 -0500 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 439C11B6 for ; Fri, 24 Nov 2023 02:07:02 -0800 (PST) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-5cc86fcea4fso14566587b3.3 for ; Fri, 24 Nov 2023 02:07:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700820421; x=1701425221; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PWcP6gQgrwmdsnOkpH93ij3XRZvKw3Rujab02fsHwiU=; b=qxN5ioYEcENuAMn/Jxr8Kcg+5ZM9glWmzc3x2Wi4S+x6rIHteCtrlCsNYbUfjdtyne BOdb9FO72GTlLtiezDwv7z4FSZeDqFsIqJv3K7V9Er47Gp1Kz630X58BdnwoGtrxcEpe 1tvf9tPCzQGzUdh2tt2cnuSUV/TJi8E1wS6stwjJMQBwVvYT8hxvgDAhSopsGd12KbZh QP2nKDWokcgtUjPWANTtF/8dgHgQlYDF6SwKsPZHxvKYIAma9EnC1co9CQ0vtrD4NJrS P1CSCaqZd17kLEjuFbJESHzg++yLR3jYXQ3HozJxQFwMyl1Ep+MNrCZnxXFBGc5LBp/A sSUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700820421; x=1701425221; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PWcP6gQgrwmdsnOkpH93ij3XRZvKw3Rujab02fsHwiU=; b=FgpbKMBguREXER1NwMZQT51ifwgxaTO0tSLiGJItfqcq1wUdvaWDlNH9mLSRRXM7Se Evwnn5YCtDyaQUGdoqS2JCBGlxV6TTtwTdAsle1zNpbJXKm4al9UieahZuBVn2ipoRqd pC0pbWxZamAX6h5629TT2W3GCs3BKGPSYYFEcKwKNTHVPFyz8gKgp3LKwFZWpT2eYIYX w60XFVuYzP8Tf/AwfNAFnldoobLIkkhk7HeMv57VuBtAz69G4cS+qEW63r/z64s4R4OT hy7EaPq/xnUg60rNINzbplKaVNN4iRcZSDPIAot2AmE0e4N4iADblF7sE3qDFRoAsPei F9CA== X-Gm-Message-State: AOJu0YzBx0DCS+u2oaBmdxIEy8crjUr0z8HUoHpIXsv7MPkq525qe8kK TW59nGMo3KntVCnDtjKE6lmcsEyKJYVcnkK/hpNJUQ== X-Received: by 2002:a81:e950:0:b0:59b:c805:de60 with SMTP id e16-20020a81e950000000b0059bc805de60mr2174447ywm.45.1700820421368; Fri, 24 Nov 2023 02:07:01 -0800 (PST) MIME-Version: 1.0 References: <20231120222832.4063882-1-masahiroy@kernel.org> <20231120222832.4063882-2-masahiroy@kernel.org> In-Reply-To: From: Linus Walleij Date: Fri, 24 Nov 2023 11:06:50 +0100 Message-ID: Subject: Re: [PATCH 1/2] pinctrl: pinconf-generic: resize the pin config array directly To: Masahiro Yamada , Andy Shevchenko Cc: 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=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 howler.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 (howler.vger.email [0.0.0.0]); Fri, 24 Nov 2023 02:07:15 -0800 (PST) Hi Masahiro, 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 enough > > to contain all the config parameters. Then, kmemdup() copies the found > > 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 wit= h > > 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 chan= ge. The fact that we use kmemdup to be able to also shrink the allocation is 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. Yours, Linus Walleij