diff options
Diffstat (limited to 'Documentation/connector/cn_test.c')
-rw-r--r-- | Documentation/connector/cn_test.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/Documentation/connector/cn_test.c b/Documentation/connector/cn_test.c index 50d5ce4899c8..6e73190af0be 100644 --- a/Documentation/connector/cn_test.c +++ b/Documentation/connector/cn_test.c | |||
@@ -19,6 +19,8 @@ | |||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #define pr_fmt(fmt) "cn_test: " fmt | ||
23 | |||
22 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
23 | #include <linux/module.h> | 25 | #include <linux/module.h> |
24 | #include <linux/moduleparam.h> | 26 | #include <linux/moduleparam.h> |
@@ -27,16 +29,17 @@ | |||
27 | 29 | ||
28 | #include <linux/connector.h> | 30 | #include <linux/connector.h> |
29 | 31 | ||
30 | static struct cb_id cn_test_id = { 0x123, 0x456 }; | 32 | static struct cb_id cn_test_id = { CN_NETLINK_USERS + 3, 0x456 }; |
31 | static char cn_test_name[] = "cn_test"; | 33 | static char cn_test_name[] = "cn_test"; |
32 | static struct sock *nls; | 34 | static struct sock *nls; |
33 | static struct timer_list cn_test_timer; | 35 | static struct timer_list cn_test_timer; |
34 | 36 | ||
35 | void cn_test_callback(struct cn_msg *msg) | 37 | static void cn_test_callback(struct cn_msg *msg) |
36 | { | 38 | { |
37 | printk("%s: %lu: idx=%x, val=%x, seq=%u, ack=%u, len=%d: %s.\n", | 39 | pr_info("%s: %lu: idx=%x, val=%x, seq=%u, ack=%u, len=%d: %s.\n", |
38 | __func__, jiffies, msg->id.idx, msg->id.val, | 40 | __func__, jiffies, msg->id.idx, msg->id.val, |
39 | msg->seq, msg->ack, msg->len, (char *)msg->data); | 41 | msg->seq, msg->ack, msg->len, |
42 | msg->len ? (char *)msg->data : ""); | ||
40 | } | 43 | } |
41 | 44 | ||
42 | /* | 45 | /* |
@@ -61,9 +64,7 @@ static int cn_test_want_notify(void) | |||
61 | 64 | ||
62 | skb = alloc_skb(size, GFP_ATOMIC); | 65 | skb = alloc_skb(size, GFP_ATOMIC); |
63 | if (!skb) { | 66 | if (!skb) { |
64 | printk(KERN_ERR "Failed to allocate new skb with size=%u.\n", | 67 | pr_err("failed to allocate new skb with size=%u\n", size); |
65 | size); | ||
66 | |||
67 | return -ENOMEM; | 68 | return -ENOMEM; |
68 | } | 69 | } |
69 | 70 | ||
@@ -112,12 +113,12 @@ static int cn_test_want_notify(void) | |||
112 | //netlink_broadcast(nls, skb, 0, ctl->group, GFP_ATOMIC); | 113 | //netlink_broadcast(nls, skb, 0, ctl->group, GFP_ATOMIC); |
113 | netlink_unicast(nls, skb, 0, 0); | 114 | netlink_unicast(nls, skb, 0, 0); |
114 | 115 | ||
115 | printk(KERN_INFO "Request was sent. Group=0x%x.\n", ctl->group); | 116 | pr_info("request was sent: group=0x%x\n", ctl->group); |
116 | 117 | ||
117 | return 0; | 118 | return 0; |
118 | 119 | ||
119 | nlmsg_failure: | 120 | nlmsg_failure: |
120 | printk(KERN_ERR "Failed to send %u.%u\n", msg->seq, msg->ack); | 121 | pr_err("failed to send %u.%u\n", msg->seq, msg->ack); |
121 | kfree_skb(skb); | 122 | kfree_skb(skb); |
122 | return -EINVAL; | 123 | return -EINVAL; |
123 | } | 124 | } |
@@ -129,6 +130,8 @@ static void cn_test_timer_func(unsigned long __data) | |||
129 | struct cn_msg *m; | 130 | struct cn_msg *m; |
130 | char data[32]; | 131 | char data[32]; |
131 | 132 | ||
133 | pr_debug("%s: timer fired with data %lu\n", __func__, __data); | ||
134 | |||
132 | m = kzalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC); | 135 | m = kzalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC); |
133 | if (m) { | 136 | if (m) { |
134 | 137 | ||
@@ -148,7 +151,7 @@ static void cn_test_timer_func(unsigned long __data) | |||
148 | 151 | ||
149 | cn_test_timer_counter++; | 152 | cn_test_timer_counter++; |
150 | 153 | ||
151 | mod_timer(&cn_test_timer, jiffies + HZ); | 154 | mod_timer(&cn_test_timer, jiffies + msecs_to_jiffies(1000)); |
152 | } | 155 | } |
153 | 156 | ||
154 | static int cn_test_init(void) | 157 | static int cn_test_init(void) |
@@ -166,8 +169,10 @@ static int cn_test_init(void) | |||
166 | } | 169 | } |
167 | 170 | ||
168 | setup_timer(&cn_test_timer, cn_test_timer_func, 0); | 171 | setup_timer(&cn_test_timer, cn_test_timer_func, 0); |
169 | cn_test_timer.expires = jiffies + HZ; | 172 | mod_timer(&cn_test_timer, jiffies + msecs_to_jiffies(1000)); |
170 | add_timer(&cn_test_timer); | 173 | |
174 | pr_info("initialized with id={%u.%u}\n", | ||
175 | cn_test_id.idx, cn_test_id.val); | ||
171 | 176 | ||
172 | return 0; | 177 | return 0; |
173 | 178 | ||