2016-11-07 19:06:23

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH] usb: renesas_usbhs: simplify list handling

The current code is effectively equivalent to list_first_entry_or_null()
so simply switch and simplify the code.

Fixes: 6acb95d4e070 ("usb: renesas_usbhs: modify packet queue control method")
Signed-off-by: Nicholas Mc Guire <[email protected]>
---
Found by simple coccinelle scanner

Compile tested with: multi_v7_defconfig (implies
CONFIG_USB_RENESAS_USBHS=m)

Patch is against 4.9.0-rc2 (localversion-next is next-20161028)

drivers/usb/renesas_usbhs/fifo.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 857e783..d1af831 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -100,10 +100,7 @@ static void __usbhsf_pkt_del(struct usbhs_pkt *pkt)

static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe)
{
- if (list_empty(&pipe->list))
- return NULL;
-
- return list_first_entry(&pipe->list, struct usbhs_pkt, node);
+ return list_first_entry_or_null(&pipe->list, struct usbhs_pkt, node);
}

static void usbhsf_fifo_clear(struct usbhs_pipe *pipe,
--
1.7.10.4


2016-11-08 02:17:32

by Yoshihiro Shimoda

[permalink] [raw]
Subject: RE: [PATCH] usb: renesas_usbhs: simplify list handling

Hi,

> From: Nicholas Mc Guire
> Sent: Tuesday, November 08, 2016 4:07 AM
>
> The current code is effectively equivalent to list_first_entry_or_null()
> so simply switch and simplify the code.
>
> Fixes: 6acb95d4e070 ("usb: renesas_usbhs: modify packet queue control method")
> Signed-off-by: Nicholas Mc Guire <[email protected]>
> ---
> Found by simple coccinelle scanner
>
> Compile tested with: multi_v7_defconfig (implies
> CONFIG_USB_RENESAS_USBHS=m)
>
> Patch is against 4.9.0-rc2 (localversion-next is next-20161028)

Thank you for the patch!
However, such a patch is already merged in the Felipe's usb.git repository unfortunately...
https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/commit/?h=testing/next&id=31faf878bd8c7e2c078a3b75f65efe64f23b0f18
So, the patch will appear in linux-next repository in the future.

Best regards,
Yoshihiro Shimoda


2016-11-08 03:27:04

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] usb: renesas_usbhs: simplify list handling

>> Fixes: 6acb95d4e070 ("usb: renesas_usbhs: modify packet queue control method")


This is not a fix, but a clean-up patch.



>> Signed-off-by: Nicholas Mc Guire <[email protected]>
>> ---
>> Found by simple coccinelle scanner
>>
>> Compile tested with: multi_v7_defconfig (implies
>> CONFIG_USB_RENESAS_USBHS=m)
>>
>> Patch is against 4.9.0-rc2 (localversion-next is next-20161028)
>
> Thank you for the patch!
> However, such a patch is already merged in the Felipe's usb.git repository unfortunately...
> https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/commit/?h=testing/next&id=31faf878bd8c7e2c078a3b75f65efe64f23b0f18
> So, the patch will appear in linux-next repository in the future.


Likewise for
drivers/usb/dwc3/gadget.h
drivers/usb/dwc2/gadget.c


--
Best Regards
Masahiro Yamada

2016-11-08 07:11:06

by Nicholas Mc Guire

[permalink] [raw]
Subject: Re: [PATCH] usb: renesas_usbhs: simplify list handling

On Tue, Nov 08, 2016 at 12:26:45PM +0900, Masahiro Yamada wrote:
> >> Fixes: 6acb95d4e070 ("usb: renesas_usbhs: modify packet queue control method")
>
>
> This is not a fix, but a clean-up patch.

true - I?ve been using it incorrectly to basically just record
the origin of the issue found - but looking at Submitting patches
this seems wrong.
In any case it would be interesting to be able to trace location
of where things go in that then need cleanups - is there an
alternative tag that could be used for that purpose ?

thx!
hofrat