Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1545073

[PATCH] drivers: misc: mic: constify cosm_hw_ops structures

From Bhumika Goyal <bhumirks@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] drivers: misc: mic: constify cosm_hw_ops structures
Date 2016-12-20 13:20 +0100
Message-ID <sQryF-5u7-9@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


The fields of cosm_hw_ops structures are never modified after getting
initialized, so declare these structures as const. Also add const 
annotation to all its uses like pointers, extern declaration and function 
arguments.
Used Coccinelle to find occurences.

File size before:
   text	   data	    bss	    dec	    hex	filename
   4116	    584	      0	   4700	   125c	drivers/misc/mic/host/mic_boot.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   4212	    488	      0	   4700	   125c	drivers/misc/mic/host/mic_boot.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 drivers/misc/mic/bus/cosm_bus.c    | 2 +-
 drivers/misc/mic/bus/cosm_bus.h    | 4 ++--
 drivers/misc/mic/host/mic_boot.c   | 2 +-
 drivers/misc/mic/host/mic_device.h | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/mic/bus/cosm_bus.c b/drivers/misc/mic/bus/cosm_bus.c
index d31d6c6..85f28ca 100644
--- a/drivers/misc/mic/bus/cosm_bus.c
+++ b/drivers/misc/mic/bus/cosm_bus.c
@@ -69,7 +69,7 @@ static inline void cosm_release_dev(struct device *d)
 }
 
 struct cosm_device *
-cosm_register_device(struct device *pdev, struct cosm_hw_ops *hw_ops)
+cosm_register_device(struct device *pdev, const struct cosm_hw_ops *hw_ops)
 {
 	struct cosm_device *cdev;
 	int ret;
diff --git a/drivers/misc/mic/bus/cosm_bus.h b/drivers/misc/mic/bus/cosm_bus.h
index 8b63418..fc0c0905 100644
--- a/drivers/misc/mic/bus/cosm_bus.h
+++ b/drivers/misc/mic/bus/cosm_bus.h
@@ -69,7 +69,7 @@ struct cosm_device {
 	void *log_buf_addr;
 	int *log_buf_len;
 	struct kernfs_node *state_sysfs;
-	struct cosm_hw_ops *hw_ops;
+	const struct cosm_hw_ops *hw_ops;
 	struct device dev;
 	int index;
 	struct dentry *dbg_dir;
@@ -118,7 +118,7 @@ struct cosm_hw_ops {
 };
 
 struct cosm_device *
-cosm_register_device(struct device *pdev, struct cosm_hw_ops *hw_ops);
+cosm_register_device(struct device *pdev, const struct cosm_hw_ops *hw_ops);
 void cosm_unregister_device(struct cosm_device *dev);
 int cosm_register_driver(struct cosm_driver *drv);
 void cosm_unregister_driver(struct cosm_driver *drv);
diff --git a/drivers/misc/mic/host/mic_boot.c b/drivers/misc/mic/host/mic_boot.c
index 9599d73..34534ad 100644
--- a/drivers/misc/mic/host/mic_boot.c
+++ b/drivers/misc/mic/host/mic_boot.c
@@ -586,7 +586,7 @@ static struct mic_mw *_mic_aper(struct cosm_device *cdev)
 	return &mdev->aper;
 }
 
-struct cosm_hw_ops cosm_hw_ops = {
+const struct cosm_hw_ops cosm_hw_ops = {
 	.reset = _mic_reset,
 	.force_reset = _mic_reset,
 	.post_reset = NULL,
diff --git a/drivers/misc/mic/host/mic_device.h b/drivers/misc/mic/host/mic_device.h
index 52b12b2..87a92b7 100644
--- a/drivers/misc/mic/host/mic_device.h
+++ b/drivers/misc/mic/host/mic_device.h
@@ -43,7 +43,7 @@ enum mic_stepping {
 	MIC_C0_STEP = 0x20,
 };
 
-extern struct cosm_hw_ops cosm_hw_ops;
+extern const struct cosm_hw_ops cosm_hw_ops;
 
 /**
  * struct mic_device -  MIC device information for each card.
-- 
1.9.1

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] drivers: misc: mic: constify cosm_hw_ops structures Bhumika Goyal <bhumirks@gmail.com> - 2016-12-20 13:20 +0100

csiph-web