Skip to contentSkip to conversation

Staging: emxx_udc: constify usb_ep_ops structure

PATCH In review Bhumika Goyal 2 participants 2 messages Oct 9, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: emxx_udc: constify usb_ep_ops structure

Declare the structure usb_ep_ops as constant as it is only stored in the ops field of a usb_ep structure which is a field of a nbu2ss_ep structure. The ops field is of type const struct usb_ep_ops *, so usb_ep_ops structures having this property can be decalared as const. Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct usb_ep_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
struct nbu2ss_ep s;
@@
s.ep.ops=&i@p

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct usb_ep_ops i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct usb_ep_ops i;

File size before:
text data bss dec hex filename
16007 376 3720 20103 4e87
drivers/staging/emxx_udc/emxx_udc.o

File size after:
text data bss dec hex filename
16095 280 3720 20095 4e7f
drivers/staging/emxx_udc/emxx_udc.o

---
 drivers/staging/emxx_udc/emxx_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/emxx_udc/emxx_udc.c +1 -1
index 6391220..6b6d7db 100644
@@ -2933,7 +2933,7 @@ static void  nbu2ss_ep_fifo_flush(struct usb_ep *_ep)
 }
 
 /*-------------------------------------------------------------------------*/
-static struct usb_ep_ops nbu2ss_ep_ops = {
+static const struct usb_ep_ops nbu2ss_ep_ops = {
 	.enable		= nbu2ss_ep_enable,
 	.disable	= nbu2ss_ep_disable,
 
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw
Quoted 43 lines · Bhumika Goyal

Declare the structure usb_ep_ops as constant as it is only stored in the ops field of a usb_ep structure which is a field of a nbu2ss_ep structure. The ops field is of type const struct usb_ep_ops *, so usb_ep_ops structures having this property can be decalared as const. Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct usb_ep_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
struct nbu2ss_ep s;
@@
s.ep.ops=&i@p

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct usb_ep_ops i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct usb_ep_ops i;

File size before:
text data bss dec hex filename
16007 376 3720 20103 4e87
drivers/staging/emxx_udc/emxx_udc.o

Quoted 6 lines

File size after:
text data bss dec hex filename
16095 280 3720 20095 4e7f
drivers/staging/emxx_udc/emxx_udc.o

Quoted 27 lines
---
 drivers/staging/emxx_udc/emxx_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/emxx_udc/emxx_udc.c +1 -2
index 6391220..6b6d7db 100644
@@ -2933,7 +2933,7 @@ static void  nbu2ss_ep_fifo_flush(struct usb_ep *_ep)
 }
 
 /*-------------------------------------------------------------------------*/
-static struct usb_ep_ops nbu2ss_ep_ops = {
+static const struct usb_ep_ops nbu2ss_ep_ops = {
 	.enable		= nbu2ss_ep_enable,
 	.disable	= nbu2ss_ep_disable,
 
--

1.9.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1475999788-12028-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.