Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/connector: Add const qualifier to cb_id

The connector driver never modifies any cb_id passed to it, so add a const
qualifier to those arguments so callers can declare their struct cb_id as a
constant object.

Fixes build warnings like these when passing a constant struct cb_id:

warning: passing argument 1 of ‘cn_add_callback’ discards ‘const’ qualifier from pointer target

Signed-off-by: Geoff Levand <geoff@infradead.org>
Link: https://lore.kernel.org/r/a9e49c9e-67fa-16e7-0a6b-72f6bd30c58a@infradead.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Geoff Levand and committed by
Jakub Kicinski
c18e6869 4375ada0

+12 -12
+1 -1
Documentation/driver-api/connector.rst
··· 25 25 netlink based networking for inter-process communication in a significantly 26 26 easier way:: 27 27 28 - int cn_add_callback(struct cb_id *id, char *name, void (*callback) (struct cn_msg *, struct netlink_skb_parms *)); 28 + int cn_add_callback(const struct cb_id *id, char *name, void (*callback) (struct cn_msg *, struct netlink_skb_parms *)); 29 29 void cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 __group, int gfp_mask); 30 30 void cn_netlink_send(struct cn_msg *msg, u32 portid, u32 __group, int gfp_mask); 31 31
+4 -4
drivers/connector/cn_queue.c
··· 19 19 20 20 static struct cn_callback_entry * 21 21 cn_queue_alloc_callback_entry(struct cn_queue_dev *dev, const char *name, 22 - struct cb_id *id, 22 + const struct cb_id *id, 23 23 void (*callback)(struct cn_msg *, 24 24 struct netlink_skb_parms *)) 25 25 { ··· 51 51 kfree(cbq); 52 52 } 53 53 54 - int cn_cb_equal(struct cb_id *i1, struct cb_id *i2) 54 + int cn_cb_equal(const struct cb_id *i1, const struct cb_id *i2) 55 55 { 56 56 return ((i1->idx == i2->idx) && (i1->val == i2->val)); 57 57 } 58 58 59 59 int cn_queue_add_callback(struct cn_queue_dev *dev, const char *name, 60 - struct cb_id *id, 60 + const struct cb_id *id, 61 61 void (*callback)(struct cn_msg *, 62 62 struct netlink_skb_parms *)) 63 63 { ··· 90 90 return 0; 91 91 } 92 92 93 - void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id) 93 + void cn_queue_del_callback(struct cn_queue_dev *dev, const struct cb_id *id) 94 94 { 95 95 struct cn_callback_entry *cbq, *n; 96 96 int found = 0;
+2 -2
drivers/connector/connector.c
··· 193 193 * 194 194 * May sleep. 195 195 */ 196 - int cn_add_callback(struct cb_id *id, const char *name, 196 + int cn_add_callback(const struct cb_id *id, const char *name, 197 197 void (*callback)(struct cn_msg *, 198 198 struct netlink_skb_parms *)) 199 199 { ··· 214 214 * 215 215 * May sleep while waiting for reference counter to become zero. 216 216 */ 217 - void cn_del_callback(struct cb_id *id) 217 + void cn_del_callback(const struct cb_id *id) 218 218 { 219 219 struct cn_dev *dev = &cdev; 220 220
+5 -5
include/linux/connector.h
··· 64 64 * @callback: connector's callback. 65 65 * parameters are %cn_msg and the sender's credentials 66 66 */ 67 - int cn_add_callback(struct cb_id *id, const char *name, 67 + int cn_add_callback(const struct cb_id *id, const char *name, 68 68 void (*callback)(struct cn_msg *, struct netlink_skb_parms *)); 69 69 /** 70 70 * cn_del_callback() - Unregisters new callback with connector core. 71 71 * 72 72 * @id: unique connector's user identifier. 73 73 */ 74 - void cn_del_callback(struct cb_id *id); 74 + void cn_del_callback(const struct cb_id *id); 75 75 76 76 77 77 /** ··· 122 122 int cn_netlink_send(struct cn_msg *msg, u32 portid, u32 group, gfp_t gfp_mask); 123 123 124 124 int cn_queue_add_callback(struct cn_queue_dev *dev, const char *name, 125 - struct cb_id *id, 125 + const struct cb_id *id, 126 126 void (*callback)(struct cn_msg *, struct netlink_skb_parms *)); 127 - void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id); 127 + void cn_queue_del_callback(struct cn_queue_dev *dev, const struct cb_id *id); 128 128 void cn_queue_release_callback(struct cn_callback_entry *); 129 129 130 130 struct cn_queue_dev *cn_queue_alloc_dev(const char *name, struct sock *); 131 131 void cn_queue_free_dev(struct cn_queue_dev *dev); 132 132 133 - int cn_cb_equal(struct cb_id *, struct cb_id *); 133 + int cn_cb_equal(const struct cb_id *, const struct cb_id *); 134 134 135 135 #endif /* __CONNECTOR_H */