From: Bartosz Golaszewski <brgl@bgdev.pl> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Jonathan Cameron <jic23@kernel.org>, Hartmut Knaack <knaack.h@gmx.de>, Lars-Peter Clausen <lars@metafoo.de>, Peter Meerwald-Stadler <pmeerw@pmeerw.net>, Michal Simek <michal.simek@xilinx.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Guenter Roeck <linux@roeck-us.net>, linux-iio <linux-iio@vger.kernel.org>, Linux ARM <linux-arm-kernel@lists.infradead.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, Bartosz Golaszewski <bgolaszewski@baylibre.com> Subject: Re: [PATCH v8 1/3] devres: provide devm_krealloc() Date: Fri, 21 Aug 2020 10:59:19 +0200 [thread overview] Message-ID: <CAMRc=Me=D1cOsaRqK-BwHT7f-_=3=eciduA=G95FfE2e_XUWfg@mail.gmail.com> (raw) In-Reply-To: <20200821081555.GG1891694@smile.fi.intel.com> On Fri, Aug 21, 2020 at 10:35 AM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > On Thu, Aug 20, 2020 at 08:51:08PM +0200, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com> > > > > Implement the managed variant of krealloc(). This function works with > > all memory allocated by devm_kmalloc() (or devres functions using it > > implicitly like devm_kmemdup(), devm_kstrdup() etc.). > > > > Managed realloc'ed chunks can be manually released with devm_kfree(). > > > > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > ... > > > +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) > Hi Andy, The data pointer in struct devres is defined as: u8 __aligned(ARCH_KMALLOC_MINALIGN) data[]; And this value (assigned the value of ARCH_DMA_MINALIGN) varies from one arch to another. I wasn't really sure if offsetof() would work for every case so I went with something very explicit. > Another side note: do we have existing users of these helpers? > Which ones? Because I assume you're not referring to the ones I'm adding in this patch. :) Bart
WARNING: multiple messages have this Message-ID (diff)
From: Bartosz Golaszewski <brgl@bgdev.pl> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Linux ARM <linux-arm-kernel@lists.infradead.org>, Lars-Peter Clausen <lars@metafoo.de>, linux-iio <linux-iio@vger.kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Michal Simek <michal.simek@xilinx.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, Bartosz Golaszewski <bgolaszewski@baylibre.com>, Guenter Roeck <linux@roeck-us.net>, Peter Meerwald-Stadler <pmeerw@pmeerw.net>, Hartmut Knaack <knaack.h@gmx.de>, Jonathan Cameron <jic23@kernel.org> Subject: Re: [PATCH v8 1/3] devres: provide devm_krealloc() Date: Fri, 21 Aug 2020 10:59:19 +0200 [thread overview] Message-ID: <CAMRc=Me=D1cOsaRqK-BwHT7f-_=3=eciduA=G95FfE2e_XUWfg@mail.gmail.com> (raw) In-Reply-To: <20200821081555.GG1891694@smile.fi.intel.com> On Fri, Aug 21, 2020 at 10:35 AM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > On Thu, Aug 20, 2020 at 08:51:08PM +0200, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com> > > > > Implement the managed variant of krealloc(). This function works with > > all memory allocated by devm_kmalloc() (or devres functions using it > > implicitly like devm_kmemdup(), devm_kstrdup() etc.). > > > > Managed realloc'ed chunks can be manually released with devm_kfree(). > > > > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > ... > > > +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) > Hi Andy, The data pointer in struct devres is defined as: u8 __aligned(ARCH_KMALLOC_MINALIGN) data[]; And this value (assigned the value of ARCH_DMA_MINALIGN) varies from one arch to another. I wasn't really sure if offsetof() would work for every case so I went with something very explicit. > Another side note: do we have existing users of these helpers? > Which ones? Because I assume you're not referring to the ones I'm adding in this patch. :) Bart _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-08-21 8:59 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-20 18:51 [PATCH v8 0/3] devres: provide and use devm_krealloc() Bartosz Golaszewski 2020-08-20 18:51 ` Bartosz Golaszewski 2020-08-20 18:51 ` [PATCH v8 1/3] devres: provide devm_krealloc() Bartosz Golaszewski 2020-08-20 18:51 ` Bartosz Golaszewski 2020-08-21 8:15 ` Andy Shevchenko 2020-08-21 8:15 ` Andy Shevchenko 2020-08-21 8:18 ` Andy Shevchenko 2020-08-21 8:18 ` Andy Shevchenko 2020-08-21 8:59 ` Bartosz Golaszewski [this message] 2020-08-21 8:59 ` Bartosz Golaszewski 2020-08-21 10:51 ` Andy Shevchenko 2020-08-21 10:51 ` Andy Shevchenko 2020-08-21 11:04 ` Andy Shevchenko 2020-08-21 11:04 ` Andy Shevchenko 2020-08-21 16:00 ` Bartosz Golaszewski 2020-08-21 16:00 ` Bartosz Golaszewski 2020-08-20 18:51 ` [PATCH v8 2/3] hwmon: pmbus: use more devres helpers Bartosz Golaszewski 2020-08-20 18:51 ` Bartosz Golaszewski 2020-08-20 18:51 ` [PATCH v8 3/3] iio: adc: xilinx-xadc: use devm_krealloc() Bartosz Golaszewski 2020-08-20 18:51 ` Bartosz Golaszewski
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAMRc=Me=D1cOsaRqK-BwHT7f-_=3=eciduA=G95FfE2e_XUWfg@mail.gmail.com' \ --to=brgl@bgdev.pl \ --cc=andriy.shevchenko@linux.intel.com \ --cc=bgolaszewski@baylibre.com \ --cc=gregkh@linuxfoundation.org \ --cc=jic23@kernel.org \ --cc=knaack.h@gmx.de \ --cc=lars@metafoo.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-iio@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@roeck-us.net \ --cc=michal.simek@xilinx.com \ --cc=pmeerw@pmeerw.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.