connector: make callback argument type explicit
Subsystems (6)
PATCH 1/3 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.
--- Documentation/connector/cn_test.c | 4 +--- drivers/connector/cn_proc.c | 3 +-- drivers/connector/cn_queue.c | 7 +++++-- drivers/connector/connector.c | 6 +++--- drivers/staging/dst/dcore.c | 3 +-- drivers/video/uvesafb.c | 3 +-- drivers/w1/w1_netlink.c | 3 +-- include/linux/connector.h | 6 +++--- 8 files changed, 16 insertions(+), 19 deletions(-)
Documentation/connector/cn_test.c +1 -3
@@ -32,10 +32,8 @@ static char cn_test_name[] = "cn_test";static struct sock *nls;static struct timer_list cn_test_timer; -void cn_test_callback (void *data) +void cn_test_callback (struct cn_msg *msg) { -struct cn_msg *msg = (struct cn_msg *)data; -printk ("%s: %lu: idx=%x, val=%x, seq=%u, ack=%u, len=%d: %s.\n" , __func__, jiffies, msg->id.idx, msg->id.val, msg->seq, msg->ack, msg->len, (char *)msg->data);
drivers/connector/cn_proc.c +1 -2
@@ -202,9 +202,8 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)* cn_proc_mcast_ctl * @data: message sent from userspace via the connector */ -static void cn_proc_mcast_ctl (void *data) +static void cn_proc_mcast_ctl (struct cn_msg *msg) { -struct cn_msg *msg = data;enum proc_cn_mcast_op *mc_op =NULL ;int err =0 ;
drivers/connector/cn_queue.c +5 -2
@@ -87,7 +87,9 @@ void cn_queue_wrapper(struct work_struct *work)kfree (d->free); } -static struct cn_callback_entry *cn_queue_alloc_callback_entry (char *name,struct cb_id *id,void (*callback)(void *)) +static struct cn_callback_entry * +cn_queue_alloc_callback_entry (char *name,struct cb_id *id, +void (*callback)(struct cn_msg *)) {struct cn_callback_entry *cbq;
@@ -120,7 +122,8 @@ int cn_cb_equal(struct cb_id *i1, struct cb_id *i2)return ((i1->idx == i2->idx) && (i1->val == i2->val)); } -int cn_queue_add_callback (struct cn_queue_dev *dev,char *name,struct cb_id *id,void (*callback)(void *)) +int cn_queue_add_callback (struct cn_queue_dev *dev,char *name,struct cb_id *id, +void (*callback)(struct cn_msg *)) {struct cn_callback_entry *cbq, *__cbq;int found =0 ;
drivers/connector/connector.c +3 -3
@@ -269,7 +269,8 @@ static void cn_notify(struct cb_id *id, u32 notify_event)* * May sleep. */ -int cn_add_callback (struct cb_id *id,char *name,void (*callback)(void *)) +int cn_add_callback (struct cb_id *id,char *name, +void (*callback)(struct cn_msg *)) {int err;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)* * Used for notification of a request's processing. */ -static void cn_callback (void *data) +static void cn_callback (struct cn_msg *msg) { -struct cn_msg *msg = data;struct cn_ctl_msg *ctl;struct cn_ctl_entry *ent;u32 size;
drivers/staging/dst/dcore.c +1 -2
@@ -846,10 +846,9 @@ static dst_command_func dst_commands[] = {/* * Configuration parser. */ -static void cn_dst_callback (void *data) +static void cn_dst_callback (struct cn_msg *msg) {struct dst_ctl *ctl; -struct cn_msg *msg = data;int err;struct dst_ctl_ack ack;struct dst_node *n =NULL , *tmp;
drivers/video/uvesafb.c +1 -2
@@ -67,9 +67,8 @@ static DEFINE_MUTEX(uvfb_lock);* find the kernel part of the task struct, copy the registers and * the buffer contents and then complete the task. */ -static void uvesafb_cn_callback (void *data) +static void uvesafb_cn_callback (struct cn_msg *msg) { -struct cn_msg *msg = data;struct uvesafb_task *utask;struct uvesafb_ktask *task;
drivers/w1/w1_netlink.c +1 -2
@@ -306,9 +306,8 @@ static int w1_netlink_send_error(struct cn_msg *rcmsg, struct w1_netlink_msg *rmreturn error; } -static void w1_cn_callback (void *data) +static void w1_cn_callback (struct cn_msg *msg) { -struct cn_msg *msg = data;struct w1_netlink_msg *m = (struct w1_netlink_msg *)(msg +1 );struct w1_netlink_cmd *cmd;struct w1_slave *sl;
include/linux/connector.h +3 -3
@@ -136,7 +136,7 @@ struct cn_callback_data {void *ddata;void *callback_priv; -void (*callback) (void *); +void (*callback) (struct cn_msg *);void *free; };
@@ -167,11 +167,11 @@ struct cn_dev {struct cn_queue_dev *cbdev; }; -int cn_add_callback (struct cb_id *,char *,void (*callback) (void *)); +int cn_add_callback (struct cb_id *,char *,void (*callback) (struct cn_msg *));void cn_del_callback (struct cb_id *);int cn_netlink_send (struct cn_msg *,u32 ,gfp_t ); -int cn_queue_add_callback (struct cn_queue_dev *dev,char *name,struct cb_id *id,void (*callback)(void *)); +int cn_queue_add_callback (struct cn_queue_dev *dev,char *name,struct cb_id *id,void (*callback)(struct cn_msg *));void cn_queue_del_callback (struct cn_queue_dev *dev,struct cb_id *id);int queue_cn_work (struct cn_callback_entry *cbq,struct work_struct *work);
Signature · 1 line
1.6.3.3
PATCH 2/3 connector: clean up grammar/style in documentation
The grammar in most of this file is slightly off, and some sections are hard to read due to lack of visual clues breaking up related material.
--- Documentation/connector/connector.txt | 119 +++++++++++++++++---------------- 1 files changed, 61 insertions(+), 58 deletions(-)
Documentation/connector/connector.txt +61 -58
@@ -5,10 +5,10 @@ Kernel Connector. Kernel connector - new netlink based userspace <-> kernel space easy to use communication module. -Connector driver adds possibility to connect various agents using -netlink based network. One must register callback and -identifier. When driver receives special netlink message with -appropriate identifier, appropriate callback will be called. +The Connector driver adds makes it easy to connect various agents using a +netlink based network. One must register a callback and an identifier. +When the driver receives a special netlink message with the appropriate +identifier, the appropriate callback will be called. From the userspace point of view it's quite straightforward:
@@ -17,10 +17,10 @@ From the userspace point of view it's quite straightforward: send(); recv(); -But if kernelspace want to use full power of such connections, driver -writer must create special sockets, must know about struct sk_buff -handling... Connector allows any kernelspace agents to use netlink -based networking for inter-process communication in a significantly +But if kernelspace wants to use the full power of such connections, the +driver writer must create special sockets, must know about struct sk_buff +handling, etc... The Connector driver allows any kernelspace agents to use +netlink based networking for inter-process communication in a significantly easier way: int cn_add_callback(struct cb_id *id, char *name, void (*callback) (void *));
@@ -32,15 +32,15 @@ struct cb_id __u32 val; }; -idx and val are unique identifiers which must be registered in -connector.h for in-kernel usage. void (*callback) (void *) - is a -callback function which will be called when message with above idx.val -will be received by connector core. Argument for that function must +idx and val are unique identifiers which must be registered in the +connector.h header for in-kernel usage. void (*callback) (void *) is a +callback function which will be called when a message with above idx.val +is received by the connector core. The argument for that function must be dereferenced to struct cn_msg *. struct cn_msg { - struct cb_id id; + struct cb_id id; __u32 seq; __u32 ack;
@@ -55,92 +55,95 @@ Connector interfaces. int cn_add_callback(struct cb_id *id, char *name, void (*callback) (void *)); -Registers new callback with connector core. + Registers new callback with connector core. -struct cb_id *id - unique connector's user identifier. - It must be registered in connector.h for legal in-kernel users. -char *name - connector's callback symbolic name. -void (*callback) (void *) - connector's callback. + struct cb_id *id - unique connector's user identifier. + It must be registered in connector.h for legal in-kernel users. + char *name - connector's callback symbolic name. + void (*callback) (void *) - connector's callback. Argument must be dereferenced to struct cn_msg *. + void cn_del_callback(struct cb_id *id); -Unregisters new callback with connector core. + Unregisters new callback with connector core. + + struct cb_id *id - unique connector's user identifier. -struct cb_id *id - unique connector's user identifier. int cn_netlink_send(struct cn_msg *msg, u32 __groups, int gfp_mask); -Sends message to the specified groups. It can be safely called from -softirq context, but may silently fail under strong memory pressure. -If there are no listeners for given group -ESRCH can be returned. + Sends message to the specified groups. It can be safely called from + softirq context, but may silently fail under strong memory pressure. + If there are no listeners for given group -ESRCH can be returned. -struct cn_msg * - message header(with attached data). -u32 __group - destination group. + struct cn_msg * - message header(with attached data). + u32 __group - destination group. If __group is zero, then appropriate group will be searched through all registered connector users, and message will be delivered to the group which was created for user with the same ID as in msg. If __group is not zero, then message will be delivered to the specified group. -int gfp_mask - GFP mask. + int gfp_mask - GFP mask. -Note: When registering new callback user, connector core assigns -netlink group to the user which is equal to it's id.idx. + Note: When registering new callback user, connector core assigns + netlink group to the user which is equal to it's id.idx. /*****************************************/ Protocol description. /*****************************************/ -Current offers transport layer with fixed header. Recommended -protocol which uses such header is following: +The current framework offers a transport layer with fixed headers. The +recommended protocol which uses such a header is as following: msg->seq and msg->ack are used to determine message genealogy. When -someone sends message it puts there locally unique sequence and random -acknowledge numbers. Sequence number may be copied into +someone sends a message, they use a locally unique sequence and random +acknowledge number. The sequence number may be copied into nlmsghdr->nlmsg_seq too. -Sequence number is incremented with each message to be sent. +The sequence number is incremented with each message sent. -If we expect reply to our message, then sequence number in received -message MUST be the same as in original message, and acknowledge -number MUST be the same + 1. +If you expect a reply to the message, then the sequence number in the +received message MUST be the same as in the original message, and the +acknowledge number MUST be the same + 1. -If we receive message and it's sequence number is not equal to one we -are expecting, then it is new message. If we receive message and it's -sequence number is the same as one we are expecting, but it's -acknowledge is not equal acknowledge number in original message + 1, -then it is new message. +If we receive a message and its sequence number is not equal to one we +are expecting, then it is a new message. If we receive a message and +its sequence number is the same as one we are expecting, but its +acknowledge is not equal to the acknowledge number in the original +message + 1, then it is a new message. -Obviously, protocol header contains above id. +Obviously, the protocol header contains the above id. -connector allows event notification in the following form: kernel +The connector allows event notification in the following form: kernel driver or userspace process can ask connector to notify it when -selected id's will be turned on or off(registered or unregistered it's -callback). It is done by sending special command to connector -driver(it also registers itself with id={-1, -1}). +selected ids will be turned on or off (registered or unregistered its +callback). It is done by sending a special command to the connector +driver (it also registers itself with id={-1, -1}). -As example of usage Documentation/connector now contains cn_test.c - -testing module which uses connector to request notification and to -send messages. +As example of this usage can be found in the cn_test.c module which +uses the connector to request notification and to send messages. /*****************************************/ Reliability. /*****************************************/ -Netlink itself is not reliable protocol, that means that messages can +Netlink itself is not a reliable protocol. That means that messages can be lost due to memory pressure or process' receiving queue overflowed, -so caller is warned must be prepared. That is why struct cn_msg [main -connector's message header] contains u32 seq and u32 ack fields. +so caller is warned that it must be prepared. That is why the struct +cn_msg [main connector's message header] contains u32 seq and u32 ack +fields. /*****************************************/ Userspace usage. /*****************************************/ + 2.6.14 has a new netlink socket implementation, which by default does not -allow to send data to netlink groups other than 1. -So, if to use netlink socket (for example using connector) -with different group number userspace application must subscribe to -that group. It can be achieved by following pseudocode: +allow people to send data to netlink groups other than 1. +So, if you wish to use a netlink socket (for example using connector) +with a different group number, the userspace application must subscribe to +that group first. It can be achieved by the following pseudocode: s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
@@ -160,8 +163,8 @@ if (bind(s, (struct sockaddr *)&l_local, sizeof(struct sockaddr_nl)) == -1) { } Where 270 above is SOL_NETLINK, and 1 is a NETLINK_ADD_MEMBERSHIP socket -option. To drop multicast subscription one should call above socket option -with NETLINK_DROP_MEMBERSHIP parameter which is defined as 0. +option. To drop a multicast subscription, one should call the above socket +option with the NETLINK_DROP_MEMBERSHIP parameter which is defined as 0. 2.6.14 netlink code only allows to select a group which is less or equal to the maximum group number, which is used at netlink_kernel_create() time.
Signature · 1 line
1.6.3.3
Re: [PATCH 2/3] connector: clean up grammar/style in documentation
Quoted 16 lines · Mike Frysinger
The grammar in most of this file is slightly off, and some sections are hard to read due to lack of visual clues breaking up related material.
Signed-off-by Mike Frysinger <[email protected]>---
Documentation/connector/connector.txt | 119 +++++++++++++++++----------------1 files changed, 61 insertions(+), 58 deletions(-)Documentation/connector/connector.txt +0
-0@@ -5,10 +5,10 @@ Kernel Connector.Kernel connector - new netlink based userspace <-> kernel space easy to use communication module.
Documentation/connector/connector.txt Kernel Connector. · line 11
Quoted 8 lines
Documentation/connector/connector.txt +4
-4-Connector driver adds possibility to connect various agents using -netlink based network. One must register callback and -identifier. When driver receives special netlink message with -appropriate identifier, appropriate callback will be called. +The Connector driver adds makes it easy to connect various agents using a +netlink based network. One must register a callback and an identifier. +When the driver receives a special netlink message with the appropriate +identifier, the appropriate callback will be called.
The first line of the second paragraph still needs work, "adds" should probably be removed.
PATCH v2 2/3 connector: clean up grammar/style in documentation
The grammar in most of this file is slightly off, and some sections are hard to read due to lack of visual clues breaking up related material.
---
v2
- tweak first change some more as Will Newton pointed out
Documentation/connector/connector.txt | 119 +++++++++++++++++---------------- 1 files changed, 61 insertions(+), 58 deletions(-)
Documentation/connector/connector.txt +61 -58
@@ -5,10 +5,10 @@ Kernel Connector. Kernel connector - new netlink based userspace <-> kernel space easy to use communication module. -Connector driver adds possibility to connect various agents using -netlink based network. One must register callback and -identifier. When driver receives special netlink message with -appropriate identifier, appropriate callback will be called. +The Connector driver makes it easy to connect various agents using a +netlink based network. One must register a callback and an identifier. +When the driver receives a special netlink message with the appropriate +identifier, the appropriate callback will be called. From the userspace point of view it's quite straightforward:
@@ -17,10 +17,10 @@ From the userspace point of view it's quite straightforward: send(); recv(); -But if kernelspace want to use full power of such connections, driver -writer must create special sockets, must know about struct sk_buff -handling... Connector allows any kernelspace agents to use netlink -based networking for inter-process communication in a significantly +But if kernelspace wants to use the full power of such connections, the +driver writer must create special sockets, must know about struct sk_buff +handling, etc... The Connector driver allows any kernelspace agents to use +netlink based networking for inter-process communication in a significantly easier way: int cn_add_callback(struct cb_id *id, char *name, void (*callback) (void *));
@@ -32,15 +32,15 @@ struct cb_id __u32 val; }; -idx and val are unique identifiers which must be registered in -connector.h for in-kernel usage. void (*callback) (void *) - is a -callback function which will be called when message with above idx.val -will be received by connector core. Argument for that function must +idx and val are unique identifiers which must be registered in the +connector.h header for in-kernel usage. void (*callback) (void *) is a +callback function which will be called when a message with above idx.val +is received by the connector core. The argument for that function must be dereferenced to struct cn_msg *. struct cn_msg { - struct cb_id id; + struct cb_id id; __u32 seq; __u32 ack;
@@ -55,92 +55,95 @@ Connector interfaces. int cn_add_callback(struct cb_id *id, char *name, void (*callback) (void *)); -Registers new callback with connector core. + Registers new callback with connector core. -struct cb_id *id - unique connector's user identifier. - It must be registered in connector.h for legal in-kernel users. -char *name - connector's callback symbolic name. -void (*callback) (void *) - connector's callback. + struct cb_id *id - unique connector's user identifier. + It must be registered in connector.h for legal in-kernel users. + char *name - connector's callback symbolic name. + void (*callback) (void *) - connector's callback. Argument must be dereferenced to struct cn_msg *. + void cn_del_callback(struct cb_id *id); -Unregisters new callback with connector core. + Unregisters new callback with connector core. + + struct cb_id *id - unique connector's user identifier. -struct cb_id *id - unique connector's user identifier. int cn_netlink_send(struct cn_msg *msg, u32 __groups, int gfp_mask); -Sends message to the specified groups. It can be safely called from -softirq context, but may silently fail under strong memory pressure. -If there are no listeners for given group -ESRCH can be returned. + Sends message to the specified groups. It can be safely called from + softirq context, but may silently fail under strong memory pressure. + If there are no listeners for given group -ESRCH can be returned. -struct cn_msg * - message header(with attached data). -u32 __group - destination group. + struct cn_msg * - message header(with attached data). + u32 __group - destination group. If __group is zero, then appropriate group will be searched through all registered connector users, and message will be delivered to the group which was created for user with the same ID as in msg. If __group is not zero, then message will be delivered to the specified group. -int gfp_mask - GFP mask. + int gfp_mask - GFP mask. -Note: When registering new callback user, connector core assigns -netlink group to the user which is equal to it's id.idx. + Note: When registering new callback user, connector core assigns + netlink group to the user which is equal to it's id.idx. /*****************************************/ Protocol description. /*****************************************/ -Current offers transport layer with fixed header. Recommended -protocol which uses such header is following: +The current framework offers a transport layer with fixed headers. The +recommended protocol which uses such a header is as following: msg->seq and msg->ack are used to determine message genealogy. When -someone sends message it puts there locally unique sequence and random -acknowledge numbers. Sequence number may be copied into +someone sends a message, they use a locally unique sequence and random +acknowledge number. The sequence number may be copied into nlmsghdr->nlmsg_seq too. -Sequence number is incremented with each message to be sent. +The sequence number is incremented with each message sent. -If we expect reply to our message, then sequence number in received -message MUST be the same as in original message, and acknowledge -number MUST be the same + 1. +If you expect a reply to the message, then the sequence number in the +received message MUST be the same as in the original message, and the +acknowledge number MUST be the same + 1. -If we receive message and it's sequence number is not equal to one we -are expecting, then it is new message. If we receive message and it's -sequence number is the same as one we are expecting, but it's -acknowledge is not equal acknowledge number in original message + 1, -then it is new message. +If we receive a message and its sequence number is not equal to one we +are expecting, then it is a new message. If we receive a message and +its sequence number is the same as one we are expecting, but its +acknowledge is not equal to the acknowledge number in the original +message + 1, then it is a new message. -Obviously, protocol header contains above id. +Obviously, the protocol header contains the above id. -connector allows event notification in the following form: kernel +The connector allows event notification in the following form: kernel driver or userspace process can ask connector to notify it when -selected id's will be turned on or off(registered or unregistered it's -callback). It is done by sending special command to connector -driver(it also registers itself with id={-1, -1}). +selected ids will be turned on or off (registered or unregistered its +callback). It is done by sending a special command to the connector +driver (it also registers itself with id={-1, -1}). -As example of usage Documentation/connector now contains cn_test.c - -testing module which uses connector to request notification and to -send messages. +As example of this usage can be found in the cn_test.c module which +uses the connector to request notification and to send messages. /*****************************************/ Reliability. /*****************************************/ -Netlink itself is not reliable protocol, that means that messages can +Netlink itself is not a reliable protocol. That means that messages can be lost due to memory pressure or process' receiving queue overflowed, -so caller is warned must be prepared. That is why struct cn_msg [main -connector's message header] contains u32 seq and u32 ack fields. +so caller is warned that it must be prepared. That is why the struct +cn_msg [main connector's message header] contains u32 seq and u32 ack +fields. /*****************************************/ Userspace usage. /*****************************************/ + 2.6.14 has a new netlink socket implementation, which by default does not -allow to send data to netlink groups other than 1. -So, if to use netlink socket (for example using connector) -with different group number userspace application must subscribe to -that group. It can be achieved by following pseudocode: +allow people to send data to netlink groups other than 1. +So, if you wish to use a netlink socket (for example using connector) +with a different group number, the userspace application must subscribe to +that group first. It can be achieved by the following pseudocode: s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
@@ -160,8 +163,8 @@ if (bind(s, (struct sockaddr *)&l_local, sizeof(struct sockaddr_nl)) == -1) { } Where 270 above is SOL_NETLINK, and 1 is a NETLINK_ADD_MEMBERSHIP socket -option. To drop multicast subscription one should call above socket option -with NETLINK_DROP_MEMBERSHIP parameter which is defined as 0. +option. To drop a multicast subscription, one should call the above socket +option with the NETLINK_DROP_MEMBERSHIP parameter which is defined as 0. 2.6.14 netlink code only allows to select a group which is less or equal to the maximum group number, which is used at netlink_kernel_create() time.
Signature · 1 line
1.6.3.3
PATCH 3/3 connector: get test code working by default
In reply to Mike FrysingerThe connector test code currently does not work out of the box. This is because it uses a connector id that is above the registered limit. So rather than force people to stumble through undocumented code wondering why it isn't working, have the test code use one of the "private" ids by default. While I'm in here, clean up the code (kernel and user app) so that it's a bit more user friendly and verbose in significant things that it does. Terse test code wastes people time as they simply enumerate it with all the same kind of debug messages to get a better feel of what code is running at any time.
--- Documentation/connector/Makefile | 5 +++ Documentation/connector/cn_test.c | 31 +++++++++++-------- Documentation/connector/ucon.c | 62 +++++++++++++++++++++++++++++++----- 3 files changed, 76 insertions(+), 22 deletions(-)
Documentation/connector/Makefile +5 -0
@@ -9,3 +9,8 @@ hostprogs-y := ucon always := $(hostprogs-y) HOSTCFLAGS_ucon.o += -I$(objtree)/usr/include + +all: modules + +modules clean: + $(MAKE) -C ../.. SUBDIRS=$(PWD) $@
Documentation/connector/cn_test.c +18 -13
@@ -19,6 +19,8 @@* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define pr_fmt (fmt) "cn_test: " fmt +#include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h>
@@ -27,16 +29,17 @@#include <linux/connector.h> -static struct cb_id cn_test_id = {0x123 ,0x456 }; +static struct cb_id cn_test_id = {CN_NETLINK_USERS +3 ,0x456 };static char cn_test_name[] ="cn_test" ;static struct sock *nls;static struct timer_list cn_test_timer; -void cn_test_callback (struct cn_msg *msg) +static void cn_test_callback (struct cn_msg *msg) { -printk ("%s: %lu: idx=%x, val=%x, seq=%u, ack=%u, len=%d: %s.\n" , - __func__, jiffies, msg->id.idx, msg->id.val, - msg->seq, msg->ack, msg->len, (char *)msg->data); +pr_info ("%s: %lu: idx=%x, val=%x, seq=%u, ack=%u, len=%d: %s.\n" , + __func__, jiffies, msg->id.idx, msg->id.val, + msg->seq, msg->ack, msg->len, + msg->len ? (char *)msg->data :"" ); }/*
@@ -61,9 +64,7 @@ static int cn_test_want_notify(void) skb =alloc_skb (size,GFP_ATOMIC );if (!skb) { -printk (KERN_ERR "Failed to allocate new skb with size=%u.\n" , - size); - +pr_err ("failed to allocate new skb with size=%u\n" , size);return -ENOMEM ; }
@@ -112,12 +113,12 @@ static int cn_test_want_notify(void)//netlink_broadcast(nls, skb, 0, ctl->group, GFP_ATOMIC); netlink_unicast (nls, skb,0 ,0 ); -printk (KERN_INFO "Request was sent. Group=0x%x.\n" , ctl->group); +pr_info ("request was sent: group=0x%x\n" , ctl->group);return 0 ; nlmsg_failure: -printk (KERN_ERR "Failed to send %u.%u\n" , msg->seq, msg->ack); +pr_err ("failed to send %u.%u\n" , msg->seq, msg->ack);kfree_skb (skb);return -EINVAL ; }
@@ -129,6 +130,8 @@ static void cn_test_timer_func(unsigned long __data)struct cn_msg *m;char data[32 ]; +pr_debug ("%s: timer fired with data %lu\n" , __func__, __data); + m =kzalloc (sizeof (*m) +sizeof (data),GFP_ATOMIC );if (m) {
@@ -148,7 +151,7 @@ static void cn_test_timer_func(unsigned long __data) cn_test_timer_counter++; -mod_timer (&cn_test_timer, jiffies +HZ ); +mod_timer (&cn_test_timer, jiffies +msecs_to_jiffies (1000 )); }static int cn_test_init (void )
@@ -166,8 +169,10 @@ static int cn_test_init(void) }setup_timer (&cn_test_timer, cn_test_timer_func,0 ); - cn_test_timer.expires = jiffies +HZ ; -add_timer (&cn_test_timer); +mod_timer (&cn_test_timer, jiffies +msecs_to_jiffies (1000 )); + +pr_info ("initialized with id={%u.%u}\n" , + cn_test_id.idx, cn_test_id.val);return 0 ;
Documentation/connector/ucon.c +53 -9
118 lines not on this page · raw message
Signature · 1 line
1.6.3.3
Hi Mike.
Your patches look good, thanks a lot.
David, please apply to the appropriate tree.
Thank you.
Quoted 176 lines · Mike Frysinger
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 structcn_msgpointer.Signed-off-by Mike Frysinger <[email protected]>--- Documentation/connector/cn_test.c | 4 +--- drivers/connector/cn_proc.c | 3 +-- drivers/connector/cn_queue.c | 7 +++++-- drivers/connector/connector.c | 6 +++--- drivers/staging/dst/dcore.c | 3 +-- drivers/video/uvesafb.c | 3 +-- drivers/w1/w1_netlink.c | 3 +-- include/linux/connector.h | 6 +++--- 8 files changed, 16 insertions(+), 19 deletions(-)Documentation/connector/cn_test.c +1
-3@@ -32,10 +32,8 @@ static char cn_test_name[] = "cn_test";static struct sock *nls;static struct timer_list cn_test_timer; -void cn_test_callback (void *data) +void cn_test_callback (struct cn_msg *msg) { -struct cn_msg *msg = (struct cn_msg *)data; -printk ("%s: %lu: idx=%x, val=%x, seq=%u, ack=%u, len=%d: %s.\n" , __func__, jiffies, msg->id.idx, msg->id.val, msg->seq, msg->ack, msg->len, (char *)msg->data);drivers/connector/cn_proc.c +1
-2@@ -202,9 +202,8 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)* cn_proc_mcast_ctl * @data: message sent from userspace via the connector */ -static void cn_proc_mcast_ctl (void *data) +static void cn_proc_mcast_ctl (struct cn_msg *msg) { -struct cn_msg *msg = data;enum proc_cn_mcast_op *mc_op =NULL ;int err =0 ;drivers/connector/cn_queue.c +5
-2@@ -87,7 +87,9 @@ void cn_queue_wrapper(struct work_struct *work)kfree (d->free); } -static struct cn_callback_entry *cn_queue_alloc_callback_entry (char *name,struct cb_id *id,void (*callback)(void *)) +static struct cn_callback_entry * +cn_queue_alloc_callback_entry (char *name,struct cb_id *id, +void (*callback)(struct cn_msg *)) {struct cn_callback_entry *cbq;@@ -120,7 +122,8 @@ int cn_cb_equal(struct cb_id *i1, struct cb_id *i2)return ((i1->idx == i2->idx) && (i1->val == i2->val)); } -int cn_queue_add_callback (struct cn_queue_dev *dev,char *name,struct cb_id *id,void (*callback)(void *)) +int cn_queue_add_callback (struct cn_queue_dev *dev,char *name,struct cb_id *id, +void (*callback)(struct cn_msg *)) {struct cn_callback_entry *cbq, *__cbq;int found =0 ;drivers/connector/connector.c +3
-3@@ -269,7 +269,8 @@ static void cn_notify(struct cb_id *id, u32 notify_event)* * May sleep. */ -int cn_add_callback (struct cb_id *id,char *name,void (*callback)(void *)) +int cn_add_callback (struct cb_id *id,char *name, +void (*callback)(struct cn_msg *)) {int err;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)* * Used for notification of a request's processing. */ -static void cn_callback (void *data) +static void cn_callback (struct cn_msg *msg) { -struct cn_msg *msg = data;struct cn_ctl_msg *ctl;struct cn_ctl_entry *ent;u32 size;drivers/staging/dst/dcore.c +1
-2@@ -846,10 +846,9 @@ static dst_command_func dst_commands[] = {/* * Configuration parser. */ -static void cn_dst_callback (void *data) +static void cn_dst_callback (struct cn_msg *msg) {struct dst_ctl *ctl; -struct cn_msg *msg = data;int err;struct dst_ctl_ack ack;struct dst_node *n =NULL , *tmp;drivers/video/uvesafb.c +1
-2@@ -67,9 +67,8 @@ static DEFINE_MUTEX(uvfb_lock);* find the kernel part of the task struct, copy the registers and * the buffer contents and then complete the task. */ -static void uvesafb_cn_callback (void *data) +static void uvesafb_cn_callback (struct cn_msg *msg) { -struct cn_msg *msg = data;struct uvesafb_task *utask;struct uvesafb_ktask *task;drivers/w1/w1_netlink.c +1
-2@@ -306,9 +306,8 @@ static int w1_netlink_send_error(struct cn_msg *rcmsg, struct w1_netlink_msg *rmreturn error; } -static void w1_cn_callback (void *data) +static void w1_cn_callback (struct cn_msg *msg) { -struct cn_msg *msg = data;struct w1_netlink_msg *m = (struct w1_netlink_msg *)(msg +1 );struct w1_netlink_cmd *cmd;struct w1_slave *sl;include/linux/connector.h +3
-3@@ -136,7 +136,7 @@ struct cn_callback_data {void *ddata;void *callback_priv; -void (*callback) (void *); +void (*callback) (struct cn_msg *);void *free; };@@ -167,11 +167,11 @@ struct cn_dev {struct cn_queue_dev *cbdev; }; -int cn_add_callback (struct cb_id *,char *,void (*callback) (void *)); +int cn_add_callback (struct cb_id *,char *,void (*callback) (struct cn_msg *));void cn_del_callback (struct cb_id *);int cn_netlink_send (struct cn_msg *,u32 ,gfp_t ); -int cn_queue_add_callback (struct cn_queue_dev *dev,char *name,struct cb_id *id,void (*callback)(void *)); +int cn_queue_add_callback (struct cn_queue_dev *dev,char *name,struct cb_id *id,void (*callback)(struct cn_msg *));void cn_queue_del_callback (struct cn_queue_dev *dev,struct cb_id *id);int queue_cn_work (struct cn_callback_entry *cbq,struct work_struct *work);Signature · 1 line
1.6.3.3
Signature · 1 line
Evgeniy Polyakov
From: Evgeniy Polyakov <[email protected]>
Date: Thu, 16 Jul 2009 14:19:57 +0400
Quoted 4 lines
Hi Mike.
Your patches look good, thanks a lot.
David, please apply to the appropriate tree.
Applied to net-next-2.6, but I am being very generous.
In the future please make sure [email protected] receives all networking patch postings so that they properly get tracked at:
http://patchwork.ozlabs.org/project/netdev/list/
Otherwise they risk getting lost.
Quoted 5 lines · David Miller
From: Evgeniy Polyakov <[email protected]>
Quoted 3 lines
Your patches look good, thanks a lot.
David, please apply to the appropriate tree.
Quoted 8 lines
Applied to net-next-2.6, but I am being very generous.
In the future please make sure [email protected] receives all networking patch postings so that they properly get tracked at:
http://patchwork.ozlabs.org/project/netdev/list/
Otherwise they risk getting lost.
the fact that the connector code is maintained in the net tree is not mentioned anywhere that i can see. it isnt in net/, it isnt in drivers/net/, and it isnt in MAINTAINERS. that means anyone who wishes to submit patches has to basically guess where to send them. going by the default rules, that means the author (Evgeniy) and LKML. expecting people to magically divine net ownership with this driver is ridiculous.
-mike
Quoted 15 lines · On Fri, 17 Jul 2009 23:45:35 -0400 Mike Frysinger <[email protected]> wrote:
Quoted 5 lines · David Miller
From: Evgeniy Polyakov <[email protected]>
Quoted 3 lines
Your patches look good, thanks a lot.
David, please apply to the appropriate tree.Quoted 8 lines
Applied to net-next-2.6, but I am being very generous.
In the future please make sure [email protected] receives all networking patch postings so that they properly get tracked at:
__ __ __ __http://patchwork.ozlabs.org/project/netdev/list/
Otherwise they risk getting lost.
Quoted 7 lines
the fact that the connector code is maintained in the net tree is not mentioned anywhere that i can see. it isnt in
net/, it isnt indrivers/net/, and it isnt inMAINTAINERS. that means anyone who wishes to submit patches has to basically guess where to send them. going by the default rules, that means the author (Evgeniy) and LKML. expecting people to magically divine net ownership with this driver is ridiculous.
y:/usr/src/git26> perl scripts/get_maintainer.pl -f drivers/connector/*.c James Morris <[email protected]>
Serge Hallyn <[email protected]>
David Howells <[email protected]>
Marc Dionne <[email protected]>
Frederic Weisbecker <[email protected]>
Evgeniy Polyakov <[email protected]>
David S. Miller <[email protected]> [email protected]
Major fail!
A MAINTAINERS record should fix that up.
PATCH 1/1 connector maintainer/mail update.
Please apply.
Documentation/connector/cn_test.c +2 -2
@@ -1,7 +1,7 @@/* * cn_test.c * -* 2004-2005 Copyright (c) Evgeniy Polyakov <[email protected]> +* 2004+ Copyright (c) Evgeniy Polyakov <[email protected]> * All rights reserved. * * This program is free software; you can redistribute it and/or modify
@@ -187,5 +187,5 @@ module_init(cn_test_init);module_exit (cn_test_fini);MODULE_LICENSE ("GPL" ); -MODULE_AUTHOR ("Evgeniy Polyakov <[email protected]>" ); +MODULE_AUTHOR ("Evgeniy Polyakov <[email protected]>" );MODULE_DESCRIPTION ("Connector's test module" );
Documentation/connector/ucon.c +1 -1
@@ -1,7 +1,7 @@/* * ucon.c * -* Copyright (c) 2004+ Evgeniy Polyakov <[email protected]> +* Copyright (c) 2004+ Evgeniy Polyakov <[email protected]> * * * This program is free software; you can redistribute it and/or modify
MAINTAINERS +7 -0
@@ -1518,6 +1518,13 @@ S: Supported F: fs/configfs/ F: include/linux/configfs.h +CONNECTOR +P: Evgeniy Polyakov +M: [email protected] +L: [email protected] +S: Maintained +F: drivers/connector/ + CONTROL GROUPS (CGROUPS) P: Paul Menage M: [email protected]
drivers/connector/cn_queue.c +1 -1
@@ -1,7 +1,7 @@/* * cn_queue.c * -* 2004-2005 Copyright (c) Evgeniy Polyakov <[email protected]> +* 2004+ Copyright (c) Evgeniy Polyakov <[email protected]> * All rights reserved. * * This program is free software; you can redistribute it and/or modify
drivers/connector/connector.c +2 -2
@@ -1,7 +1,7 @@/* * connector.c * -* 2004-2005 Copyright (c) Evgeniy Polyakov <[email protected]> +* 2004+ Copyright (c) Evgeniy Polyakov <[email protected]> * All rights reserved. * * This program is free software; you can redistribute it and/or modify
@@ -33,7 +33,7 @@#include <net/sock.h> MODULE_LICENSE ("GPL" ); -MODULE_AUTHOR ("Evgeniy Polyakov <[email protected]>" ); +MODULE_AUTHOR ("Evgeniy Polyakov <[email protected]>" );MODULE_DESCRIPTION ("Generic userspace <-> kernelspace connector." );static u32 cn_idx =CN_IDX_CONNECTOR ;
Signature · 1 line
Evgeniy Polyakov
Re: [1/1] connector maintainer/mail update.
Quoted 2 lines · Evgeniy Polyakov
- * 2004-2005 Copyright (c) Evgeniy Polyakov <[email protected]>
+ * 2004+ Copyright (c) Evgeniy Polyakov <[email protected]>
i dont think open-ended copyrights are acceptable. copyrights arent something that extend forever which is why they need explicit updating (i.e. you'd want 2004-<last year you made a change>).
MAINTAINERS S: Supported · line 1526
Quoted 8 lines
MAINTAINERS +6
-0+CONNECTOR +P: Evgeniy Polyakov +M: [email protected] +L: [email protected] +S: Maintained +F: drivers/connector/
thanks
-mike
Re: [1/1] connector maintainer/mail update.
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · Evgeniy Polyakov
- * 2004-2005 Copyright (c) Evgeniy Polyakov <[email protected]>
+ * 2004+ Copyright (c) Evgeniy Polyakov <[email protected]>i dont think open-ended copyrights are acceptable. copyrights arent something that extend forever which is why they need explicit updating (i.e. you'd want 2004-<last year you made a change>).
It can be always replaced back if I will step aside.
Signature · 1 line
Evgeniy Polyakov
Re: [1/1] connector maintainer/mail update.
Quoted 10 lines · Evgeniy Polyakov
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · Evgeniy Polyakov
- * 2004-2005 Copyright (c) Evgeniy Polyakov <[email protected]>
+ * 2004+ Copyright (c) Evgeniy Polyakov <[email protected]>i dont think open-ended copyrights are acceptable. copyrights arent something that extend forever which is why they need explicit updating (i.e. you'd want 2004-<last year you made a change>).
It can be always replaced back if I will step aside.
copyright doesnt disappear or go away if the maintainer changes. there's nothing wrong with multiple people claiming copyright on a file.
-mike
Re: [1/1] connector maintainer/mail update.
Quoted 9 lines · Mike Frysinger
Quoted 5 lines
Quoted 3 lines
i dont think open-ended copyrights are acceptable. copyrights arent something that extend forever which is why they need explicit updating (i.e. you'd want 2004-<last year you made a change>).
It can be always replaced back if I will step aside.
copyright doesnt disappear or go away if the maintainer changes. there's nothing wrong with multiple people claiming copyright on a file.
But apparently you do not like that there is no 'finish' date. And this can be changed when I step aside :)
Signature · 1 line
Evgeniy Polyakov
Re: [1/1] connector maintainer/mail update.
2009/7/18 Evgeniy Polyakov
Quoted 5 lines · Mike Frysinger
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
i dont think open-ended copyrights are acceptable. copyrights arent something that extend forever which is why they need explicit updating (i.e. you'd want 2004-<last year you made a change>).
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It can be always replaced back if I will step aside.
copyright doesnt disappear or go away if the maintainer changes. there's nothing wrong with multiple people claiming copyright on a file.
But apparently you do not like that there is no 'finish' date. And this can be changed when I step aside :)
*i* dont personally give two sh*ts about copyright. i'm only pointing out common accepted practice with regard to maintaining copyright information. accepted practice is that open ended markings like this are not legally applicable (ask the SFLC).
-mike
Re: [1/1] connector maintainer/mail update.
Quoted 12 lines · Mike Frysinger
2009/7/18 Evgeniy Polyakov
Quoted 11 lines · Mike Frysinger
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
i dont think open-ended copyrights are acceptable. copyrights arent something that extend forever which is why they need explicit updating (i.e. you'd want 2004-<last year you made a change>).
It can be always replaced back if I will step aside.
copyright doesnt disappear or go away if the maintainer changes. there's nothing wrong with multiple people claiming copyright on a file.
Quoted 7 lines
Quoted 2 lines
But apparently you do not like that there is no 'finish' date. And this can be changed when I step aside :)
*i* dont personally give two sh*ts about copyright. i'm only pointing out common accepted practice with regard to maintaining copyright information. accepted practice is that open ended markings like this are not legally applicable (ask the SFLC).
btw, dont take my comments as a NAK. if someone merges it anyways, i dont really care. i'm just giving [what i think is] some useful feedback.
-mike
Re: [1/1] connector maintainer/mail update.
In reply to Evgeniy PolyakovFrom: Evgeniy Polyakov <[email protected]>
Date: Sat, 18 Jul 2009 18:25:33 +0400
Quoted 1 line
Signed-off-by Evgeniy Polyakov <[email protected]>
Applied, thanks.