[PATCH] extcon: usbc-tusb320: Constify struct tusb320_ops

Christophe JAILLET posted 1 patch 1 month, 2 weeks ago
drivers/extcon/extcon-usbc-tusb320.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] extcon: usbc-tusb320: Constify struct tusb320_ops
Posted by Christophe JAILLET 1 month, 2 weeks ago
'struct tusb320_ops' is not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  19942	   6128	     64	  26134	   6616	drivers/extcon/extcon-usbc-tusb320.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  19949	   6000	     64	  26013	   659d	drivers/extcon/extcon-usbc-tusb320.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
---
 drivers/extcon/extcon-usbc-tusb320.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c
index 920b03421850..49176b166565 100644
--- a/drivers/extcon/extcon-usbc-tusb320.c
+++ b/drivers/extcon/extcon-usbc-tusb320.c
@@ -203,11 +203,11 @@ static int tusb320l_get_revision(struct tusb320_priv *priv, unsigned int *revisi
 	return regmap_read(priv->regmap, TUSB320L_REGA0_REVISION, revision);
 }
 
-static struct tusb320_ops tusb320_ops = {
+static const struct tusb320_ops tusb320_ops = {
 	.set_mode = tusb320_set_mode,
 };
 
-static struct tusb320_ops tusb320l_ops = {
+static const struct tusb320_ops tusb320l_ops = {
 	.set_mode = tusb320l_set_mode,
 	.get_revision = tusb320l_get_revision,
 };
-- 
2.55.0