[PATCH 1/5] cdev: make file operations const

Philipp Zabel p.zabel at pengutronix.de
Tue May 30 07:09:43 PDT 2017


scripts/checkpatch.pl warns that struct file_operations should be const,
but cdev->ops is not const, so without this patch we can choose between
a warning from checkpatch and a warning from the compiler about
discarding the const attribute when assigning the struct file_operations
cdev->ops.

Since there is no reason to modify the contents of cdev->ops after
probing, make it const.

Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
---
 include/driver.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/driver.h b/include/driver.h
index 52e06f7d62..086e44636b 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -440,7 +440,7 @@ struct file_operations {
 #define MAX_PARTUUID_STR	sizeof("00112233-4455-6677-8899-AABBCCDDEEFF")
 
 struct cdev {
-	struct file_operations *ops;
+	const struct file_operations *ops;
 	void *priv;
 	struct device_d *dev;
 	struct device_node *device_node;
-- 
2.11.0




More information about the barebox mailing list