Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1012432rdh; Fri, 24 Nov 2023 03:28:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSNK8Li78K4k7Ct0MTQbj1c0RJyA18SO5QgUnTNuvZGcnngW8zvijiI+dMPuUGjmgOWYMr X-Received: by 2002:a17:903:2443:b0:1cf:8b96:da19 with SMTP id l3-20020a170903244300b001cf8b96da19mr3085855pls.56.1700825297555; Fri, 24 Nov 2023 03:28:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700825297; cv=none; d=google.com; s=arc-20160816; b=KrMhx60xYxNqtYYOwufVFumB+sEszPDFU3/g//4gx2R26W1BmiownmNAShUDncRZ41 LslLzIC7puQV+Hx97Cz4HXqkmg0vPnr0l9gxTr2ZtghJX2NwMmV88vV1tolzjxwrlpXv oM2dXJvYLeEb+xGY9/TLCthHxfevYcUBlrbx6dVnhhECTFdQ+Da5z6GKD8yWUXJ8CQ8V KYdLUa+xosm50CjG/ymDli8YxlAohxix3Uy3NNd5/u3HEmV1buk52Uegvbo/Or3l3K4O ggHvWaN1bQIYqcto2LwW97WjSAYVWdX7R29GWgoyFZa39OChBfNWhNOlYHFujaR5JuZl OBVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hvJKM0Lk6jcaK73v0rSQhuz76chbtUS+C5PkTZNO8BU=; fh=yDUqQngnt4RAqjUT1QZs5mkoFFuZdVQOL/yXsR2WObs=; b=H5Ia5KePhiaHv7I+AOPZZjm47ZCvSosWKg/vp+Orse3So7YkwzLmoBoOc8cAFjvv4K oY+P/X9IYgygIcPvUyZLNj0DxPEBBSS6+VNP0RrmCV02O0mbLNh0tnOwIrlBYsPX7iCO IsEUN2Tvi/JFFMmWAcG52nyO2PkRM2944YoHuSpWQE7QuFWChK5bQOt9W+9nKwYNGldh L/d7D0PCoxZwZeAu3FZrjBljFf5q3a3vzI+J3TZFz07CF9zDHLcnj+0H8Uv35IHFzp9o 9DmeH2rhvV6RSdYW3V0sBRj32FWDKdm6yOWmMhMMYE3CPGwr6KHEMdazzrrnb7Rxfks+ /fuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YteXy2ec; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l12-20020a170903120c00b001ca86fa1e1csi3304633plh.484.2023.11.24.03.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 03:28:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YteXy2ec; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9FF0A8042596; Fri, 24 Nov 2023 03:25:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230381AbjKXLZB (ORCPT + 99 others); Fri, 24 Nov 2023 06:25:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbjKXLY6 (ORCPT ); Fri, 24 Nov 2023 06:24:58 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2357E1702; Fri, 24 Nov 2023 03:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700825103; x=1732361103; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=8HBC5nuhSjPqE1UlKy9QKbtcJWfkVzdP3fyBc0MI/qE=; b=YteXy2ec3G6/40XyMoYl2k/QNwhz3sAx+g7lnPbYfz50wZ0NTDqszVlt nT8tP7wK/qmN7bSObip8O//uei9kmH9mmHSF/5nA142C4XSHI+1V+mLoN 24qqSIe+d6bMO6TFd0ePe+3HtqOG6EoltbUX/KOfZ/jIF9tqI/Ln0eYUv yaW+mlIpQNKoYOB1zhP9p/HKxcZVcQTdoX/wpj7b8akfeoRH4nw1UdAYt WX5L2iw08VE8l9WJeXGURcS9ne6JGpTQhVRPVUm3H4XACZO0/5dTNCzx7 HySQTM4dyYm0X6wlW/tmhy41oARvwzKd5B2fsw+aMiI5u0SyPUDIUA1Cv A==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="396314838" X-IronPort-AV: E=Sophos;i="6.04,223,1695711600"; d="scan'208";a="396314838" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2023 03:25:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="911422551" X-IronPort-AV: E=Sophos;i="6.04,223,1695711600"; d="scan'208";a="911422551" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga001.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2023 03:25:01 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1r6UIs-0000000GhQM-2OqW; Fri, 24 Nov 2023 13:24:58 +0200 Date: Fri, 24 Nov 2023 13:24:58 +0200 From: Andy Shevchenko To: Linus Walleij Cc: Masahiro Yamada , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] pinctrl: pinconf-generic: resize the pin config array directly Message-ID: References: <20231120222832.4063882-1-masahiroy@kernel.org> <20231120222832.4063882-2-masahiroy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 24 Nov 2023 03:25:19 -0800 (PST) On Fri, Nov 24, 2023 at 11:06:50AM +0100, Linus Walleij wrote: > On Tue, Nov 21, 2023 at 11:21 AM Masahiro Yamada wrote: > > On Tue, Nov 21, 2023 at 7:28 AM 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 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 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. https://lore.kernel.org/all/20231017052322.2636-2-kkartik@nvidia.com/ -- With Best Regards, Andy Shevchenko