6 #include <linux/module.h>
10 #include <linux/netdevice.h>
12 #include <linux/poll.h>
13 #include <linux/sched.h>
24 #define OZ_RD_BUF_SZ 256
66 oz_trace(
"Dealloc serial context.\n");
77 oz_trace(
"major = %d minor = %d\n", imajor(inode), iminor(inode));
102 spin_lock_bh(&g_cdev.lock);
103 pd = g_cdev.active_pd;
106 spin_unlock_bh(&g_cdev.lock);
109 ctx = oz_cdev_claim_ctx(pd);
137 oz_cdev_release_ctx(ctx);
155 spin_lock_bh(&g_cdev.lock);
156 pd = g_cdev.active_pd;
159 spin_unlock_bh(&g_cdev.lock);
183 spin_lock(&eb->
lock);
186 spin_unlock(&eb->
lock);
192 spin_lock_bh(&eb->
lock);
194 spin_unlock_bh(&eb->
lock);
202 static int oz_set_active_pd(
u8 *
addr)
206 struct oz_pd *old_pd;
209 spin_lock_bh(&g_cdev.lock);
211 old_pd = g_cdev.active_pd;
212 g_cdev.active_pd = pd;
213 spin_unlock_bh(&g_cdev.lock);
217 if (is_zero_ether_addr(addr)) {
218 spin_lock_bh(&g_cdev.lock);
219 pd = g_cdev.active_pd;
220 g_cdev.active_pd = 0;
221 memset(g_cdev.active_addr, 0,
222 sizeof(g_cdev.active_addr));
223 spin_unlock_bh(&g_cdev.lock);
262 oz_trace(
"OZ_IOCTL_SET_ACTIVE_PD\n");
265 rc = oz_set_active_pd(addr);
270 oz_trace(
"OZ_IOCTL_GET_ACTIVE_PD\n");
271 spin_lock_bh(&g_cdev.lock);
273 spin_unlock_bh(&g_cdev.lock);
301 unsigned int ret = 0;
303 oz_trace(
"Poll called wait = %p\n", wait);
304 spin_lock_bh(&dev->
lock);
310 oz_cdev_release_ctx(ctx);
313 spin_unlock_bh(&dev->
lock);
315 poll_wait(filp, &dev->
rdq, wait);
336 memset(&g_cdev, 0,
sizeof(g_cdev));
341 MINOR(g_cdev.devnum));
347 err =
cdev_add(&g_cdev.cdev, g_cdev.devnum, 1);
353 if (IS_ERR(g_oz_class)) {
354 oz_trace(
"Failed to register ozmo_wpan class\n");
359 oz_trace(
"Failed to create sysfs entry for cdev\n");
409 oz_trace(
"Serial service resumed.\n");
426 spin_lock(&g_cdev.lock);
427 if ((g_cdev.active_pd ==
NULL) &&
430 g_cdev.active_pd = pd;
433 spin_unlock(&g_cdev.lock);
434 oz_trace(
"Serial service started.\n");
445 oz_trace(
"Serial service paused.\n");
453 oz_cdev_release_ctx(ctx);
454 spin_lock(&g_cdev.lock);
455 if (pd == g_cdev.active_pd)
456 g_cdev.active_pd = 0;
459 spin_unlock(&g_cdev.lock);
464 oz_trace(
"Serial service stopped.\n");
479 ctx = oz_cdev_claim_ctx(pd);
481 oz_trace(
"Cannot claim serial context.\n");
491 oz_trace(
"Duplicate element:%02x %02x\n",
505 oz_trace(
"Not enough space:%d %d\n", len, space);
524 oz_cdev_release_ctx(ctx);