[PATCH RFC 092/111] staging: etnaviv: convert to_etnaviv_bo() to real function

Russell King - ARM Linux linux at arm.linux.org.uk
Thu Apr 2 09:29:09 PDT 2015


On Thu, Apr 02, 2015 at 05:30:34PM +0200, Lucas Stach wrote:
> This provides a bit more type safety.
> 
> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
> ---
>  drivers/staging/etnaviv/etnaviv_gem.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/etnaviv/etnaviv_gem.h b/drivers/staging/etnaviv/etnaviv_gem.h
> index cfade337d4db..fadd5198b3e8 100644
> --- a/drivers/staging/etnaviv/etnaviv_gem.h
> +++ b/drivers/staging/etnaviv/etnaviv_gem.h
> @@ -75,7 +75,12 @@ struct etnaviv_gem_object {
>  
>  	struct etnaviv_gem_userptr userptr;
>  };
> -#define to_etnaviv_bo(x) container_of(x, struct etnaviv_gem_object, base)
> +
> +static inline
> +struct etnaviv_gem_object *to_etnaviv_bo(struct drm_gem_object *obj)
> +{
> +	return container_of(obj, struct etnaviv_gem_object, base);
> +}

I've always wondered about patches like this, and wondered how they're
supposed to be more type safe.

The only thing which I can see is that the inline function will warn if
you pass it a const or volatile pointer, whereas container_of() will
only warn if it's passed a volatile pointer.  Apart from that, I don't
see any difference between the two.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.


More information about the dri-devel mailing list