Skip to contentSkip to conversation

Staging: greybus: uart: constify tty_port_operations structure

PATCH In review Bhumika Goyal 3 participants 4 messages Oct 15, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: greybus: uart: constify tty_port_operations structure

Declare tty_port_operations structure as const as it is only stored in the ops field of a tty_port structure which is a field of a gb_tty structure. The ops field is of type const struct tty_port_operations *, so tty_port_operations structures having this property can be declared as const.
Done using Coccinelle:

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

@ok1@
identifier r1.i;
position p;
struct gb_tty q;
@@
q.port.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 tty_port_operations i={...};

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

File size before:
text data bss dec hex filename
7646 512 56 8214 2016 drivers/staging/greybus/uart.o

File size after:
text data bss dec hex filename
7710 448 56 8214 2016 drivers/staging/greybus/uart.o

---
 drivers/staging/greybus/uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/greybus/uart.c +1 -1
index 5ee7954..8162886 100644
@@ -832,7 +832,7 @@ static void gb_tty_port_shutdown(struct tty_port *port)
 	.tiocmset =		gb_tty_tiocmset,
 };
 
-static struct tty_port_operations gb_port_ops = {
+static const struct tty_port_operations gb_port_ops = {
 	.dtr_rts =		gb_tty_dtr_rts,
 	.activate =		gb_tty_port_activate,
 	.shutdown =		gb_tty_port_shutdown,
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw
Quoted 43 lines · Bhumika Goyal

Declare tty_port_operations structure as const as it is only stored in the ops field of a tty_port structure which is a field of a gb_tty structure. The ops field is of type const struct tty_port_operations *, so tty_port_operations structures having this property can be declared as const.
Done using Coccinelle:

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

@ok1@
identifier r1.i;
position p;
struct gb_tty q;
@@
q.port.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 tty_port_operations i={...};

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

File size before:
text data bss dec hex filename
7646 512 56 8214 2016 drivers/staging/greybus/uart.o

Quoted 5 lines

File size after:
text data bss dec hex filename
7710 448 56 8214 2016 drivers/staging/greybus/uart.o

Quoted 27 lines
---
 drivers/staging/greybus/uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/greybus/uart.c +1 -2
index 5ee7954..8162886 100644
@@ -832,7 +832,7 @@ static void gb_tty_port_shutdown(struct tty_port *port)
 	.tiocmset =		gb_tty_tiocmset,
 };
 
-static struct tty_port_operations gb_port_ops = {
+static const struct tty_port_operations gb_port_ops = {
 	.dtr_rts =		gb_tty_dtr_rts,
 	.activate =		gb_tty_port_activate,
 	.shutdown =		gb_tty_port_shutdown,
--

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/1476514681-10619-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Bhumika Goyal

[ +CC: staging list ]

Quoted 43 lines · Bhumika Goyal

Declare tty_port_operations structure as const as it is only stored in the ops field of a tty_port structure which is a field of a gb_tty structure. The ops field is of type const struct tty_port_operations *, so tty_port_operations structures having this property can be declared as const.
Done using Coccinelle:

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

@ok1@
identifier r1.i;
position p;
struct gb_tty q;
@@
q.port.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 tty_port_operations i={...};

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

File size before:
text data bss dec hex filename
7646 512 56 8214 2016 drivers/staging/greybus/uart.o

Quoted 5 lines

File size after:
text data bss dec hex filename
7710 448 56 8214 2016 drivers/staging/greybus/uart.o

Quoted 17 lines
---
 drivers/staging/greybus/uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/greybus/uart.c +1 -1
index 5ee7954..8162886 100644
@@ -832,7 +832,7 @@ static void gb_tty_port_shutdown(struct tty_port *port)
 	.tiocmset =		gb_tty_tiocmset,
 };
 
-static struct tty_port_operations gb_port_ops = {
+static const struct tty_port_operations gb_port_ops = {
 	.dtr_rts =		gb_tty_dtr_rts,
 	.activate =		gb_tty_port_activate,
 	.shutdown =		gb_tty_port_shutdown,
maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Bhumika Goyal

[ +CC: staging list (for real this time) ]

Quoted 43 lines · Bhumika Goyal

Declare tty_port_operations structure as const as it is only stored in the ops field of a tty_port structure which is a field of a gb_tty structure. The ops field is of type const struct tty_port_operations *, so tty_port_operations structures having this property can be declared as const.
Done using Coccinelle:

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

@ok1@
identifier r1.i;
position p;
struct gb_tty q;
@@
q.port.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 tty_port_operations i={...};

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

File size before:
text data bss dec hex filename
7646 512 56 8214 2016 drivers/staging/greybus/uart.o

Quoted 5 lines

File size after:
text data bss dec hex filename
7710 448 56 8214 2016 drivers/staging/greybus/uart.o

Quoted 17 lines
---
 drivers/staging/greybus/uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/greybus/uart.c +1 -1
index 5ee7954..8162886 100644
@@ -832,7 +832,7 @@ static void gb_tty_port_shutdown(struct tty_port *port)
 	.tiocmset =		gb_tty_tiocmset,
 };
 
-static struct tty_port_operations gb_port_ops = {
+static const struct tty_port_operations gb_port_ops = {
 	.dtr_rts =		gb_tty_dtr_rts,
 	.activate =		gb_tty_port_activate,
 	.shutdown =		gb_tty_port_shutdown,