[lkml]   [2013]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH RFC] mfd: Stop setting refcounting pointers in original mfd_cell arrays
On Tue, 29 Oct 2013, Geert Uytterhoeven wrote:

> Commit 1e29af62f2b285bd18685da93c3ce8c33ca2d1db ("mfd: Add refcounting
> support to mfd_cells") had to drop the "const" keyword on the "cell"
> parameter of mfd_add_devices(), as it added the refcounting pointers
> to the objects of the passed mfd_cell array itself.
> However, the mfd core code operates on copies of the mfd_cell objects,
> so there's no need to modify the originally passed objects.
> Hence, move the setting of the refcounting pointers from mfd_add_devices()
> to mfd_platform_add_cell(), where the copy of the mfd_cell objects is made.
> mfd_clone_cell() can just pass (a copy of) the original usage_count
> pointer.
> This allows to make the "cell" parameter of mfd_add_devices() "const"
> again, and avoids future race conditions when registering multiple
> instances of the same device in parallel.
> Signed-off-by: Geert Uytterhoeven <>
> ---
> Ever since this "const" keyword was removed, I was wondering what was
> really going on with these reference counts. My main use case involved
> multiple instances of the same device, where the registration of each
> successive instance would overwrite the refcounting pointer of the
> previous one.
> Finally I found some time to dive into it, and create this patch.
> If it is accepted, I'll create a follow-up patch to add
> "const" keywords to the various mfd_cell arrays.
> Note that there's another issue in mfd_add_devices(): if the first call to
> mfd_add_device() fails, the array of atomic_t objects will never be freed,
> as no child devices have been registered to the parent yet, and thus
> mfd_remove_devices() won't find anything to remove nor free.
> drivers/mfd/mfd-core.c | 17 +++++++++--------
> include/linux/mfd/core.h | 2 +-
> 2 files changed, 10 insertions(+), 9 deletions(-)

Hmm... I didn't see my reply to this, but it has been applied for a

Lee Jones
Linaro STMicroelectronics Landing Team Lead │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2013-12-04 10:01    [W:0.033 / U:2.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site