lkml.org 
[lkml]   [2020]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] linux/kernel.h: add container_from()
From
Date
On 27/08/2020 03.36, Allen Pais wrote:
> Introduce container_from() as a generic helper instead of
> sub-systems defining a private from_* API
> (Eg: from_tasklets recently introduced in
> 12cc923f1ccc: Tasklet: Introduce new initialization API)
>
> The helper is similar to container_of() in argument order
> with the difference of naming the containing structure instead
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> of having to specify its type.
>

> +/**
> + * container_from - cast a member of a structure out to the containing structure
> + * @ptr: the pointer to the member.
> + * @container: the type of the container struct.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This seems to have been copy-pasted from container_of? Shouldn't
@container be the (local) value we're storing into? As in foo =
container_from(..., foo, ...)? Or am I misunderstanding the purpose of this?

[And I think it would read nicer if the bikeshed was called
to_container(), but don't care deeply.]

Rasmus

\
 
 \ /
  Last update: 2020-08-27 20:09    [W:0.073 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site