Re: [PATCH v8 1/3] devres: provide devm_krealloc()
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2020-08-21 08:35:43
Also in:
linux-iio, lkml
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2020-08-21 08:35:43
Also in:
linux-iio, lkml
On Thu, Aug 20, 2020 at 08:51:08PM +0200, Bartosz Golaszewski wrote:
From: Bartosz Golaszewski <redacted> 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 <redacted> 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) Another side note: do we have existing users of these helpers? -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel