Skip to content

Commit 0741241

Browse files
vapierdavem330
authored andcommitted
connector: make callback argument type explicit
The connector documentation states that the argument to the callback function is always a pointer to a struct cn_msg, but rather than encode it in the API itself, it uses a void pointer everywhere. This doesn't make much sense to encode the pointer in documentation as it prevents proper C type checking from occurring and can easily allow people to use the wrong pointer type. So convert the argument type to an explicit struct cn_msg pointer. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e36aa25 commit 0741241

8 files changed

Lines changed: 16 additions & 19 deletions

File tree

‎Documentation/connector/cn_test.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ static char cn_test_name[] = "cn_test";
3232
static struct sock *nls;
3333
static struct timer_list cn_test_timer;
3434

35-
void cn_test_callback(void *data)
35+
void cn_test_callback(struct cn_msg *msg)
3636
{
37-
struct cn_msg *msg = (struct cn_msg *)data;
38-
3937
printk("%s: %lu: idx=%x, val=%x, seq=%u, ack=%u, len=%d: %s.\n",
4038
__func__, jiffies, msg->id.idx, msg->id.val,
4139
msg->seq, msg->ack, msg->len, (char *)msg->data);

‎drivers/connector/cn_proc.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,8 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
202202
* cn_proc_mcast_ctl
203203
* @data: message sent from userspace via the connector
204204
*/
205-
static void cn_proc_mcast_ctl(void *data)
205+
static void cn_proc_mcast_ctl(struct cn_msg *msg)
206206
{
207-
struct cn_msg *msg = data;
208207
enum proc_cn_mcast_op *mc_op = NULL;
209208
int err = 0;
210209

‎drivers/connector/cn_queue.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ void cn_queue_wrapper(struct work_struct *work)
8787
kfree(d->free);
8888
}
8989

90-
static struct cn_callback_entry *cn_queue_alloc_callback_entry(char *name, struct cb_id *id, void (*callback)(void *))
90+
static struct cn_callback_entry *
91+
cn_queue_alloc_callback_entry(char *name, struct cb_id *id,
92+
void (*callback)(struct cn_msg *))
9193
{
9294
struct cn_callback_entry *cbq;
9395

@@ -120,7 +122,8 @@ int cn_cb_equal(struct cb_id *i1, struct cb_id *i2)
120122
return ((i1->idx == i2->idx) && (i1->val == i2->val));
121123
}
122124

123-
int cn_queue_add_callback(struct cn_queue_dev *dev, char *name, struct cb_id *id, void (*callback)(void *))
125+
int cn_queue_add_callback(struct cn_queue_dev *dev, char *name, struct cb_id *id,
126+
void (*callback)(struct cn_msg *))
124127
{
125128
struct cn_callback_entry *cbq, *__cbq;
126129
int found = 0;

‎drivers/connector/connector.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ static void cn_notify(struct cb_id *id, u32 notify_event)
269269
*
270270
* May sleep.
271271
*/
272-
int cn_add_callback(struct cb_id *id, char *name, void (*callback)(void *))
272+
int cn_add_callback(struct cb_id *id, char *name,
273+
void (*callback)(struct cn_msg *))
273274
{
274275
int err;
275276
struct cn_dev *dev = &cdev;
@@ -351,9 +352,8 @@ static int cn_ctl_msg_equals(struct cn_ctl_msg *m1, struct cn_ctl_msg *m2)
351352
*
352353
* Used for notification of a request's processing.
353354
*/
354-
static void cn_callback(void *data)
355+
static void cn_callback(struct cn_msg *msg)
355356
{
356-
struct cn_msg *msg = data;
357357
struct cn_ctl_msg *ctl;
358358
struct cn_ctl_entry *ent;
359359
u32 size;

‎drivers/staging/dst/dcore.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,10 +846,9 @@ static dst_command_func dst_commands[] = {
846846
/*
847847
* Configuration parser.
848848
*/
849-
static void cn_dst_callback(void *data)
849+
static void cn_dst_callback(struct cn_msg *msg)
850850
{
851851
struct dst_ctl *ctl;
852-
struct cn_msg *msg = data;
853852
int err;
854853
struct dst_ctl_ack ack;
855854
struct dst_node *n = NULL, *tmp;

‎drivers/video/uvesafb.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ static DEFINE_MUTEX(uvfb_lock);
6767
* find the kernel part of the task struct, copy the registers and
6868
* the buffer contents and then complete the task.
6969
*/
70-
static void uvesafb_cn_callback(void *data)
70+
static void uvesafb_cn_callback(struct cn_msg *msg)
7171
{
72-
struct cn_msg *msg = data;
7372
struct uvesafb_task *utask;
7473
struct uvesafb_ktask *task;
7574

‎drivers/w1/w1_netlink.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,8 @@ static int w1_netlink_send_error(struct cn_msg *rcmsg, struct w1_netlink_msg *rm
306306
return error;
307307
}
308308

309-
static void w1_cn_callback(void *data)
309+
static void w1_cn_callback(struct cn_msg *msg)
310310
{
311-
struct cn_msg *msg = data;
312311
struct w1_netlink_msg *m = (struct w1_netlink_msg *)(msg + 1);
313312
struct w1_netlink_cmd *cmd;
314313
struct w1_slave *sl;

‎include/linux/connector.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct cn_callback_data {
136136
void *ddata;
137137

138138
void *callback_priv;
139-
void (*callback) (void *);
139+
void (*callback) (struct cn_msg *);
140140

141141
void *free;
142142
};
@@ -167,11 +167,11 @@ struct cn_dev {
167167
struct cn_queue_dev *cbdev;
168168
};
169169

170-
int cn_add_callback(struct cb_id *, char *, void (*callback) (void *));
170+
int cn_add_callback(struct cb_id *, char *, void (*callback) (struct cn_msg *));
171171
void cn_del_callback(struct cb_id *);
172172
int cn_netlink_send(struct cn_msg *, u32, gfp_t);
173173

174-
int cn_queue_add_callback(struct cn_queue_dev *dev, char *name, struct cb_id *id, void (*callback)(void *));
174+
int cn_queue_add_callback(struct cn_queue_dev *dev, char *name, struct cb_id *id, void (*callback)(struct cn_msg *));
175175
void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id);
176176

177177
int queue_cn_work(struct cn_callback_entry *cbq, struct work_struct *work);

0 commit comments

Comments
 (0)