linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: fotg210-udc: Remove a useless assignment
@ 2022-11-14 20:38 Christophe JAILLET
  2022-11-15 21:42 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2022-11-14 20:38 UTC (permalink / raw)
  To: Linus Walleij, Greg Kroah-Hartman
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-usb

There is no need to use an intermediate array for these memory allocations,
so, axe it.

While at it, turn a '== NULL' into a shorter '!' when testing memory
allocation failure.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/usb/fotg210/fotg210-udc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg210-udc.c
index 3c357ce42d3b..52b1d69843dd 100644
--- a/drivers/usb/fotg210/fotg210-udc.c
+++ b/drivers/usb/fotg210/fotg210-udc.c
@@ -1090,7 +1090,6 @@ int fotg210_udc_probe(struct platform_device *pdev)
 {
 	struct resource *res, *ires;
 	struct fotg210_udc *fotg210 = NULL;
-	struct fotg210_ep *_ep[FOTG210_MAX_NUM_EP];
 	int ret = 0;
 	int i;
 
@@ -1114,10 +1113,9 @@ int fotg210_udc_probe(struct platform_device *pdev)
 		goto err;
 
 	for (i = 0; i < FOTG210_MAX_NUM_EP; i++) {
-		_ep[i] = kzalloc(sizeof(struct fotg210_ep), GFP_KERNEL);
-		if (_ep[i] == NULL)
+		fotg210->ep[i] = kzalloc(sizeof(struct fotg210_ep), GFP_KERNEL);
+		if (!fotg210->ep[i])
 			goto err_alloc;
-		fotg210->ep[i] = _ep[i];
 	}
 
 	fotg210->reg = ioremap(res->start, resource_size(res));
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: fotg210-udc: Remove a useless assignment
  2022-11-14 20:38 [PATCH] usb: fotg210-udc: Remove a useless assignment Christophe JAILLET
@ 2022-11-15 21:42 ` Linus Walleij
  2022-11-22 16:26   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2022-11-15 21:42 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors, linux-usb

On Mon, Nov 14, 2022 at 9:38 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:

> There is no need to use an intermediate array for these memory allocations,
> so, axe it.
>
> While at it, turn a '== NULL' into a shorter '!' when testing memory
> allocation failure.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Fair enough!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

I have sent some other cleanups to this code only
yesterday, so they might collide and they you might have
to rebase.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: fotg210-udc: Remove a useless assignment
  2022-11-15 21:42 ` Linus Walleij
@ 2022-11-22 16:26   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-22 16:26 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Christophe JAILLET, linux-kernel, kernel-janitors, linux-usb

On Tue, Nov 15, 2022 at 10:42:02PM +0100, Linus Walleij wrote:
> On Mon, Nov 14, 2022 at 9:38 PM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
> 
> > There is no need to use an intermediate array for these memory allocations,
> > so, axe it.
> >
> > While at it, turn a '== NULL' into a shorter '!' when testing memory
> > allocation failure.
> >
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> 
> Fair enough!
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> 
> I have sent some other cleanups to this code only
> yesterday, so they might collide and they you might have
> to rebase.

I fixed it up, no need to resend.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-22 16:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-14 20:38 [PATCH] usb: fotg210-udc: Remove a useless assignment Christophe JAILLET
2022-11-15 21:42 ` Linus Walleij
2022-11-22 16:26   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).