From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CFDDC05027 for ; Fri, 20 Jan 2023 15:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbjATP6n (ORCPT ); Fri, 20 Jan 2023 10:58:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbjATP6n (ORCPT ); Fri, 20 Jan 2023 10:58:43 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 275FF6A31C; Fri, 20 Jan 2023 07:58:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674230322; x=1705766322; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=4Z1ku4uTRLmE2Qthefs6EE2L2camUPt4LfocOJrWd2s=; b=dYt2OO4ORh9En/jpT8+4G2wsjnoHzGqbIc+ODnHa1TM+6eor5qeMv1Sj F5pgl8px8wP69/cBgHEvby6vTdTIR9MHMuYKowk/k/PSOrcsdhbW4kuah CAgJymgQgxZHCRxhidLYubmT6vmXjtVysKmwT+4s9JDUWou0A79omtGg9 PyfGxXBU1xquLGNyyZBFke8pulH9JcKw3muGonWIuhj2wI23EWnvutuKj Zjq0khP5vWseXkeeOqFHBJiOjSOiIf88D197reigEyi2SCDKm0rt8Wb1c +vKXGbCdYAT+nWfeirvR7+iP+80D1i2TfwQQiwqoVRw/AfMXrgb99Ov/W A==; X-IronPort-AV: E=McAfee;i="6500,9779,10596"; a="305280674" X-IronPort-AV: E=Sophos;i="5.97,232,1669104000"; d="scan'208";a="305280674" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2023 07:58:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10596"; a="610515331" X-IronPort-AV: E=Sophos;i="5.97,232,1669104000"; d="scan'208";a="610515331" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga003.jf.intel.com with ESMTP; 20 Jan 2023 07:58:33 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1pItmg-00CIcD-1H; Fri, 20 Jan 2023 17:58:30 +0200 Date: Fri, 20 Jan 2023 17:58:30 +0200 From: Andy Shevchenko To: Tomi Valkeinen Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Wolfram Sang , Luca Ceresoli , Matti Vaittinen , Laurent Pinchart , Mauro Carvalho Chehab , Peter Rosin , Liam Girdwood , Mark Brown , Sakari Ailus , Michael Tretter , Shawn Tu , Hans Verkuil , Mike Pagano , Krzysztof =?utf-8?Q?Ha=C5=82asa?= , Marek Vasut , Luca Ceresoli Subject: Re: [PATCH v7 1/7] i2c: add I2C Address Translator (ATR) support Message-ID: References: <20230118124031.788940-1-tomi.valkeinen@ideasonboard.com> <20230118124031.788940-2-tomi.valkeinen@ideasonboard.com> <31562353-0794-8ad4-d609-3c117dd28d46@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <31562353-0794-8ad4-d609-3c117dd28d46@ideasonboard.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Thu, Jan 19, 2023 at 12:01:33PM +0200, Tomi Valkeinen wrote: > On 18/01/2023 16:23, Andy Shevchenko wrote: > > On Wed, Jan 18, 2023 at 02:40:25PM +0200, Tomi Valkeinen wrote: ... > > > + /* Ensure we have enough room to save the original addresses */ > > > + if (unlikely(chan->orig_addrs_size < num)) { > > > + u16 *new_buf; > > > + > > > + new_buf = kmalloc_array(num, sizeof(*new_buf), GFP_KERNEL); > > > > I remember that I asked why we don't use krealloc_array() here... Perhaps > > that we don't need to copy the old mapping table? Can we put a short comment > > to clarify this in the code? > > Yes, we don't care about the old data, we just require the buffer to be > large enough. > > I'm not sure what kind of comment you want here. Isn't this a common idiom, > where you have a buffer for temporary data, but you might need to resize at > some point if you need a larger one? Then why not krealloc_array()? That's the question I want to see the answer for in the comments: /* We don't care about old data, hence no realloc() */ > > > + if (!new_buf) > > > + return -ENOMEM; > > > + > > > + kfree(chan->orig_addrs); > > > + chan->orig_addrs = new_buf; > > > + chan->orig_addrs_size = num; > > > + } -- With Best Regards, Andy Shevchenko