Re: [PATCH] drm/tinydrm: Replace list_for_each with list_for_each_entry

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

 



On Sun, Oct 15, 2017 at 01:58:23AM +0530, Harsha Sharma wrote:
> Replace use of list_for_each with list_for_each_entry to simplify the
> code and remove variables that are used only in list_for_each.
> Done with following coccinelle patch:
> 
> @r@
> identifier fn,i,f,p;
> expression e;
> iterator name list_for_each, list_for_each_entry;
> type T;
> @@
> 
> fn(...) {
> ++ T *i;
>   <+...
> - list_for_each(p,e)
> + list_for_each_entry(i,e,f)
>   {
>               ...
> -   T *i = list_entry(p,T,f);
>                   ...
>    }
>    ...+>
> }
> 
> @@
> identifier r.fn,r.p;
> @@
> 
> fn(...) {
>   ...
> - struct list_head *p;
>   ... when != p
> }
> 
> @@
> identifier r.fn,r.i,r.f;
> expression r.e;
> statement S;
> @@
> 
> fn(...) {
>   <...
>   list_for_each_entry(i,e,f)
> - {
>   S
> - }
>   ...>
> }
> 
> @s@
> identifier i,f,p;
> expression e;
> type T;
> @@
> 
> - list_for_each(p,e)
> + list_for_each_entry(i,e,f)
>   {
>     ... when != T *i;
> -   i = list_entry(p,T,f);
>     ...
>   }
> 
> @@
> identifier s.p;
> @@
> 
> - struct list_head *p;
>   ... when != p
> 
> @@
> identifier s.i,s.f;
> expression s.e;
> statement S;
> @@
> 
>   list_for_each_entry(i,e,f)
> - {
>   S
> - }
> 
> Signed-off-by: Harsha Sharma <harshasharmaiitr@xxxxxxxxx>

Please use scripts/get_maintainers.pl to generate the list of recipients,
you've missed Noralf as the tinydrm maintainer. I've added him.
-Daniel

> ---
>  drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> index bd6cce093a85..bf96072d1b97 100644
> --- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> @@ -414,11 +414,9 @@ tinydrm_dbg_spi_print(struct spi_device *spi, struct spi_transfer *tr,
>  void _tinydrm_dbg_spi_message(struct spi_device *spi, struct spi_message *m)
>  {
>  	struct spi_transfer *tmp;
> -	struct list_head *pos;
>  	int i = 0;
>  
> -	list_for_each(pos, &m->transfers) {
> -		tmp = list_entry(pos, struct spi_transfer, transfer_list);
> +	list_for_each_entry(tmp, &m->transfers, transfer_list) {
>  
>  		if (tmp->tx_buf)
>  			tinydrm_dbg_spi_print(spi, tmp, tmp->tx_buf, i, true);
> -- 
> 2.11.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux