All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: misc: mic: constify cosm_hw_ops structures
@ 2016-12-20 12:12 Bhumika Goyal
  0 siblings, 0 replies; only message in thread
From: Bhumika Goyal @ 2016-12-20 12:12 UTC (permalink / raw)
  To: julia.lawall, sudeep.dutt, ashutosh.dixit, linux-kernel; +Cc: Bhumika Goyal

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-12-20 12:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-20 12:12 [PATCH] drivers: misc: mic: constify cosm_hw_ops structures Bhumika Goyal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.