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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD02EC433DF for ; Fri, 21 Aug 2020 08:18:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E83820639 for ; Fri, 21 Aug 2020 08:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726946AbgHUISr (ORCPT ); Fri, 21 Aug 2020 04:18:47 -0400 Received: from mga18.intel.com ([134.134.136.126]:61662 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725965AbgHUISp (ORCPT ); Fri, 21 Aug 2020 04:18:45 -0400 IronPort-SDR: RsAgte9kPmHpwDYmB08HGlkgYUQhUofyUNxuGPsQCIHW9vZTZYkMKD92icbqe9fxxulU8SKcfQ kEHxranHCn6w== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="143123071" X-IronPort-AV: E=Sophos;i="5.76,335,1592895600"; d="scan'208";a="143123071" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2020 01:18:44 -0700 IronPort-SDR: DZAu0Bhv0p82AgHROc21YY+qnN/ldKQDm/gj5dXq2i8T457KdSy/io9OmduhKgG2Cy+qf/o6SE YGkMNqe3N4eA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,335,1592895600"; d="scan'208";a="327702796" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 21 Aug 2020 01:18:42 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1k92Fz-00AI7e-Sz; Fri, 21 Aug 2020 11:18:39 +0300 Date: Fri, 21 Aug 2020 11:18:39 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Michal Simek , Greg Kroah-Hartman , Guenter Roeck , linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH v8 1/3] devres: provide devm_krealloc() Message-ID: <20200821081839.GH1891694@smile.fi.intel.com> References: <20200820185110.17828-1-brgl@bgdev.pl> <20200820185110.17828-2-brgl@bgdev.pl> <20200821081555.GG1891694@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200821081555.GG1891694@smile.fi.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 21, 2020 at 11:15:55AM +0300, Andy Shevchenko wrote: > On Thu, Aug 20, 2020 at 08:51:08PM +0200, Bartosz Golaszewski wrote: ... > > +static struct devres *to_devres(void *data) > > +{ > > + return data - ALIGN(sizeof(struct devres), ARCH_KMALLOC_MINALIGN); > > +} > > + > > +static size_t devres_data_size(size_t total_size) > > +{ > > + return total_size - ALIGN(sizeof(struct devres), ARCH_KMALLOC_MINALIGN); > > +} > > I'm fine with above, but here is a side note, perhaps > > offsetof(struct devres, data) > > will be more practical (no duplication of alignment and hence slightly better > maintenance)? (Note, I didn't check if it provides the correct result) And if the result is correct wouldn't be first a simple container_of() after all? > Another side note: do we have existing users of these helpers? -- With Best Regards, Andy Shevchenko