From: Chris Rorvick <chris@rorvick.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Vincenzo Scotti <vinc94@gmail.com>
Cc: Chris Rorvick <chris@rorvick.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>,
Roberta Dobrescu <roberta.dobrescu@gmail.com>,
Sachin Kamat <sachin.kamat@samsung.com>,
Simon Horman <horms+renesas@verge.net.au>,
Ebru Akagunduz <ebru.akagunduz@gmail.com>,
Magnus Damm <damm+renesas@opensource.se>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] staging: emxx_udc: Remove nbu2ss_drv_set_dp_info()
Date: Fri, 30 Jan 2015 17:30:10 -0600 [thread overview]
Message-ID: <1422660610-23622-1-git-send-email-chris@rorvick.com> (raw)
This function is an awkward helper for nbu2ss_drv_ep_init(). Most of
its logic is devoted to determining if the current endpoint is ep0,
something the caller can easily do in a single line. And there is not
a lot going on beyond that.
Move this logic up into nbu2ss_drv_ep_init(). The result is much easier
to understand and the resulting function is still viewable within a
single screen.
Signed-off-by: Chris Rorvick <chris@rorvick.com>
---
drivers/staging/emxx_udc/emxx_udc.c | 52 ++++++++++---------------------------
1 file changed, 14 insertions(+), 38 deletions(-)
diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index eb178fc..46864b0 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -3249,42 +3249,6 @@ static const char *gp_ep_name[NUM_ENDPOINTS] = {
};
/*-------------------------------------------------------------------------*/
-static void __init nbu2ss_drv_set_ep_info(
- struct nbu2ss_udc *udc,
- struct nbu2ss_ep *ep,
- const char *name)
-{
- ep->udc = udc;
- ep->desc = NULL;
-
- ep->ep.driver_data = NULL;
- ep->ep.name = name;
- ep->ep.ops = &nbu2ss_ep_ops;
-
- if (isdigit(name[2])) {
-
- long num;
- int res;
- char tempbuf[2];
-
- tempbuf[0] = name[2];
- tempbuf[1] = '\0';
- res = kstrtol(tempbuf, 16, &num);
-
- if (num == 0)
- ep->ep.maxpacket = EP0_PACKETSIZE;
- else
- ep->ep.maxpacket = EP_PACKETSIZE;
-
- } else {
- ep->ep.maxpacket = EP_PACKETSIZE;
- }
-
- list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list);
- INIT_LIST_HEAD(&ep->queue);
-}
-
-/*-------------------------------------------------------------------------*/
static void __init nbu2ss_drv_ep_init(struct nbu2ss_udc *udc)
{
int i;
@@ -3292,9 +3256,21 @@ static void __init nbu2ss_drv_ep_init(struct nbu2ss_udc *udc)
INIT_LIST_HEAD(&udc->gadget.ep_list);
udc->gadget.ep0 = &udc->ep[0].ep;
+ for (i = 0; i < NUM_ENDPOINTS; i++) {
+ struct nbu2ss_ep *ep = &udc->ep[i];
- for (i = 0; i < NUM_ENDPOINTS; i++)
- nbu2ss_drv_set_ep_info(udc, &udc->ep[i], gp_ep_name[i]);
+ ep->udc = udc;
+ ep->desc = NULL;
+
+ ep->ep.driver_data = NULL;
+ ep->ep.name = gp_ep_name[i];
+ ep->ep.ops = &nbu2ss_ep_ops;
+
+ ep->ep.maxpacket = (i == 0 ? EP0_PACKETSIZE : EP0_PACKETSIZE);
+
+ list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list);
+ INIT_LIST_HEAD(&ep->queue);
+ }
list_del_init(&udc->ep[0].ep.ep_list);
}
--
2.1.0
next reply other threads:[~2015-01-30 23:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-30 23:30 Chris Rorvick [this message]
2015-01-30 23:36 ` Chris Rorvick
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1422660610-23622-1-git-send-email-chris@rorvick.com \
--to=chris@rorvick.com \
--cc=damm+renesas@opensource.se \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=ebru.akagunduz@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=horms+renesas@verge.net.au \
--cc=linux-kernel@vger.kernel.org \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=roberta.dobrescu@gmail.com \
--cc=sachin.kamat@samsung.com \
--cc=vinc94@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®