aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/pktgen.c
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@mandriva.com.br>2006-03-21 01:24:45 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-21 01:24:45 -0500
commit6146e6a43b3584c0c67b0ac94e3f14fdc618bd30 (patch)
tree0e8844508a6554fadc0dfddde70c594455288731 /net/core/pktgen.c
parent222fa076652cc1faf56eb7d554c2797ace3c5beb (diff)
[PKTGEN]: Removes thread_{un,}lock() macros.
As suggested by Arnaldo, this patch replaces the thread_lock()/thread_unlock() by directly calls to mutex_lock()/mutex_unlock(). This change makes the code a bit more readable, and the direct calls are used everywhere in the kernel. Signed-off-by: Luiz Capitulino <lcapitulino@mandriva.com.br> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/pktgen.c')
-rw-r--r--net/core/pktgen.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 29a969ef2bb2..df4d531e27e0 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -180,10 +180,6 @@
180#define T_REMDEVALL (1<<3) /* Remove all devs */ 180#define T_REMDEVALL (1<<3) /* Remove all devs */
181#define T_REMDEV (1<<4) /* Remove one dev */ 181#define T_REMDEV (1<<4) /* Remove one dev */
182 182
183/* Locks */
184#define thread_lock() mutex_lock(&pktgen_thread_lock)
185#define thread_unlock() mutex_unlock(&pktgen_thread_lock)
186
187/* If lock -- can be removed after some work */ 183/* If lock -- can be removed after some work */
188#define if_lock(t) spin_lock(&(t->if_lock)); 184#define if_lock(t) spin_lock(&(t->if_lock));
189#define if_unlock(t) spin_unlock(&(t->if_lock)); 185#define if_unlock(t) spin_unlock(&(t->if_lock));
@@ -1472,18 +1468,18 @@ static ssize_t pktgen_thread_write(struct file *file,
1472 if (copy_from_user(f, &user_buffer[i], len)) 1468 if (copy_from_user(f, &user_buffer[i], len))
1473 return -EFAULT; 1469 return -EFAULT;
1474 i += len; 1470 i += len;
1475 thread_lock(); 1471 mutex_lock(&pktgen_thread_lock);
1476 pktgen_add_device(t, f); 1472 pktgen_add_device(t, f);
1477 thread_unlock(); 1473 mutex_unlock(&pktgen_thread_lock);
1478 ret = count; 1474 ret = count;
1479 sprintf(pg_result, "OK: add_device=%s", f); 1475 sprintf(pg_result, "OK: add_device=%s", f);
1480 goto out; 1476 goto out;
1481 } 1477 }
1482 1478
1483 if (!strcmp(name, "rem_device_all")) { 1479 if (!strcmp(name, "rem_device_all")) {
1484 thread_lock(); 1480 mutex_lock(&pktgen_thread_lock);
1485 t->control |= T_REMDEVALL; 1481 t->control |= T_REMDEVALL;
1486 thread_unlock(); 1482 mutex_unlock(&pktgen_thread_lock);
1487 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ 1483 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */
1488 ret = count; 1484 ret = count;
1489 sprintf(pg_result, "OK: rem_device_all"); 1485 sprintf(pg_result, "OK: rem_device_all");
@@ -1492,9 +1488,9 @@ static ssize_t pktgen_thread_write(struct file *file,
1492 1488
1493 if (!strcmp(name, "max_before_softirq")) { 1489 if (!strcmp(name, "max_before_softirq")) {
1494 len = num_arg(&user_buffer[i], 10, &value); 1490 len = num_arg(&user_buffer[i], 10, &value);
1495 thread_lock(); 1491 mutex_lock(&pktgen_thread_lock);
1496 t->max_before_softirq = value; 1492 t->max_before_softirq = value;
1497 thread_unlock(); 1493 mutex_unlock(&pktgen_thread_lock);
1498 ret = count; 1494 ret = count;
1499 sprintf(pg_result, "OK: max_before_softirq=%lu", value); 1495 sprintf(pg_result, "OK: max_before_softirq=%lu", value);
1500 goto out; 1496 goto out;
@@ -1550,7 +1546,7 @@ static int pktgen_mark_device(const char *ifname)
1550 int i = 0; 1546 int i = 0;
1551 int ret = 0; 1547 int ret = 0;
1552 1548
1553 thread_lock(); 1549 mutex_lock(&pktgen_thread_lock);
1554 PG_DEBUG(printk("pktgen: pktgen_mark_device marking %s for removal\n", 1550 PG_DEBUG(printk("pktgen: pktgen_mark_device marking %s for removal\n",
1555 ifname)); 1551 ifname));
1556 1552
@@ -1560,11 +1556,11 @@ static int pktgen_mark_device(const char *ifname)
1560 if (pkt_dev == NULL) 1556 if (pkt_dev == NULL)
1561 break; /* success */ 1557 break; /* success */
1562 1558
1563 thread_unlock(); 1559 mutex_unlock(&pktgen_thread_lock);
1564 PG_DEBUG(printk("pktgen: pktgen_mark_device waiting for %s " 1560 PG_DEBUG(printk("pktgen: pktgen_mark_device waiting for %s "
1565 "to disappear....\n", ifname)); 1561 "to disappear....\n", ifname));
1566 schedule_timeout_interruptible(msecs_to_jiffies(msec_per_try)); 1562 schedule_timeout_interruptible(msecs_to_jiffies(msec_per_try));
1567 thread_lock(); 1563 mutex_lock(&pktgen_thread_lock);
1568 1564
1569 if (++i >= max_tries) { 1565 if (++i >= max_tries) {
1570 printk("pktgen_mark_device: timed out after waiting " 1566 printk("pktgen_mark_device: timed out after waiting "
@@ -1576,7 +1572,7 @@ static int pktgen_mark_device(const char *ifname)
1576 1572
1577 } 1573 }
1578 1574
1579 thread_unlock(); 1575 mutex_unlock(&pktgen_thread_lock);
1580 1576
1581 return ret; 1577 return ret;
1582} 1578}
@@ -2459,12 +2455,12 @@ static void pktgen_stop_all_threads_ifs(void)
2459 2455
2460 PG_DEBUG(printk("pktgen: entering pktgen_stop_all_threads_ifs.\n")); 2456 PG_DEBUG(printk("pktgen: entering pktgen_stop_all_threads_ifs.\n"));
2461 2457
2462 thread_lock(); 2458 mutex_lock(&pktgen_thread_lock);
2463 2459
2464 list_for_each_entry(t, &pktgen_threads, th_list) 2460 list_for_each_entry(t, &pktgen_threads, th_list)
2465 t->control |= T_STOP; 2461 t->control |= T_STOP;
2466 2462
2467 thread_unlock(); 2463 mutex_unlock(&pktgen_thread_lock);
2468} 2464}
2469 2465
2470static int thread_is_running(struct pktgen_thread *t) 2466static int thread_is_running(struct pktgen_thread *t)
@@ -2505,7 +2501,7 @@ static int pktgen_wait_all_threads_run(void)
2505 struct pktgen_thread *t; 2501 struct pktgen_thread *t;
2506 int sig = 1; 2502 int sig = 1;
2507 2503
2508 thread_lock(); 2504 mutex_lock(&pktgen_thread_lock);
2509 2505
2510 list_for_each_entry(t, &pktgen_threads, th_list) { 2506 list_for_each_entry(t, &pktgen_threads, th_list) {
2511 sig = pktgen_wait_thread_run(t); 2507 sig = pktgen_wait_thread_run(t);
@@ -2517,7 +2513,7 @@ static int pktgen_wait_all_threads_run(void)
2517 list_for_each_entry(t, &pktgen_threads, th_list) 2513 list_for_each_entry(t, &pktgen_threads, th_list)
2518 t->control |= (T_STOP); 2514 t->control |= (T_STOP);
2519 2515
2520 thread_unlock(); 2516 mutex_unlock(&pktgen_thread_lock);
2521 return sig; 2517 return sig;
2522} 2518}
2523 2519
@@ -2527,12 +2523,12 @@ static void pktgen_run_all_threads(void)
2527 2523
2528 PG_DEBUG(printk("pktgen: entering pktgen_run_all_threads.\n")); 2524 PG_DEBUG(printk("pktgen: entering pktgen_run_all_threads.\n"));
2529 2525
2530 thread_lock(); 2526 mutex_lock(&pktgen_thread_lock);
2531 2527
2532 list_for_each_entry(t, &pktgen_threads, th_list) 2528 list_for_each_entry(t, &pktgen_threads, th_list)
2533 t->control |= (T_RUN); 2529 t->control |= (T_RUN);
2534 2530
2535 thread_unlock(); 2531 mutex_unlock(&pktgen_thread_lock);
2536 2532
2537 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */ 2533 schedule_timeout_interruptible(msecs_to_jiffies(125)); /* Propagate thread->control */
2538 2534
@@ -2692,11 +2688,11 @@ static void pktgen_rem_thread(struct pktgen_thread *t)
2692 2688
2693 remove_proc_entry(t->name, pg_proc_dir); 2689 remove_proc_entry(t->name, pg_proc_dir);
2694 2690
2695 thread_lock(); 2691 mutex_lock(&pktgen_thread_lock);
2696 2692
2697 list_del(&t->th_list); 2693 list_del(&t->th_list);
2698 2694
2699 thread_unlock(); 2695 mutex_unlock(&pktgen_thread_lock);
2700} 2696}
2701 2697
2702static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev) 2698static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev)
@@ -3070,15 +3066,15 @@ static struct pktgen_thread *__init pktgen_find_thread(const char *name)
3070{ 3066{
3071 struct pktgen_thread *t; 3067 struct pktgen_thread *t;
3072 3068
3073 thread_lock(); 3069 mutex_lock(&pktgen_thread_lock);
3074 3070
3075 list_for_each_entry(t, &pktgen_threads, th_list) 3071 list_for_each_entry(t, &pktgen_threads, th_list)
3076 if (strcmp(t->name, name) == 0) { 3072 if (strcmp(t->name, name) == 0) {
3077 thread_unlock(); 3073 mutex_unlock(&pktgen_thread_lock);
3078 return t; 3074 return t;
3079 } 3075 }
3080 3076
3081 thread_unlock(); 3077 mutex_unlock(&pktgen_thread_lock);
3082 return NULL; 3078 return NULL;
3083} 3079}
3084 3080