Re: [PATCH v5 2/3] of: Make of_fwnode_handle() safer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Sakari,

Thankyou for the patch,

On 22/05/17 09:11, Sakari Ailus wrote:
> On the expense of a little bit more complexity in the of_fwnode_handle()
> macro, make the macro result in NULL in case its argument is NULL while
> still referencing it only once.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
> ---
>  include/linux/of.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 50fcdb5..a7ccf34 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -159,7 +159,13 @@ static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
>  		container_of(fwnode, struct device_node, fwnode) : NULL;
>  }
>  
> -#define of_fwnode_handle(node) (&(node)->fwnode)
> +#define of_fwnode_handle(node)						\
> +	({								\
> +		typeof(node) __of_fwnode_handle_node = node;		\

Should this be '/= node/= (node)/' ?

> +									\
> +		__of_fwnode_handle_node ?				\
> +			&__of_fwnode_handle_node->fwnode : NULL;	\
> +	})
>  
>  static inline bool of_have_populated_dt(void)
>  {
> 

Otherwise,

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@xxxxxxxxxxxxxxxx>

--
Regards

Kieran
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux