Advertisement
Guest User

Untitled

a guest
Apr 20th, 2012
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.23 KB | None | 0 0
  1. From 382731502c73afe0672a2a32f6059f5ced1ca894 Mon Sep 17 00:00:00 2001
  2. From: detule <ogjoneski@gmail.com>
  3. Date: Fri, 20 Apr 2012 16:44:43 -0400
  4. Subject: [PATCH] For CptAJ: intermediate tty patch
  5.  
  6. ---
  7. arch/arm/mach-msm/smd_tty.c | 39 +++++++++------------------------------
  8. 1 files changed, 9 insertions(+), 30 deletions(-)
  9.  
  10. diff --git a/arch/arm/mach-msm/smd_tty.c b/arch/arm/mach-msm/smd_tty.c
  11. index 61f3c18..d0210f2 100644
  12. --- a/arch/arm/mach-msm/smd_tty.c
  13. +++ b/arch/arm/mach-msm/smd_tty.c
  14. @@ -18,7 +18,7 @@
  15. #include <linux/fs.h>
  16. #include <linux/cdev.h>
  17. #include <linux/device.h>
  18. -#include <linux/wait.h>
  19. +#include <linux/interrupt.h>
  20. #include <linux/wakelock.h>
  21. #include <linux/slab.h>
  22.  
  23. @@ -39,7 +39,7 @@ struct smd_tty_info {
  24. struct tty_struct *tty;
  25. struct wake_lock wake_lock;
  26. int open_count;
  27. - struct delayed_work tty_delayed_work;
  28. + struct tasklet_struct tty_tsklt;
  29. unsigned char *rx_buffer;
  30. };
  31.  
  32. @@ -69,20 +69,14 @@ static void smd_readx_cb(void *data, int count, void *ctxt)
  33. }
  34. }
  35.  
  36. -static void smd_tty_work_func(struct work_struct *work)
  37. +static void smd_tty_read(unsigned long param)
  38. {
  39. unsigned char *ptr;
  40. int avail;
  41. int fail_cnt=0;
  42. int exit_loop=0;
  43.  
  44. - struct delayed_work *delayed_work = container_of(work,
  45. - struct delayed_work,
  46. - work);
  47. -
  48. - struct smd_tty_info *info = container_of(delayed_work,
  49. - struct smd_tty_info,
  50. - tty_delayed_work);
  51. + struct smd_tty_info *info = (struct smd_tty_info *)param;
  52.  
  53. struct tty_struct *tty = info->tty;
  54.  
  55. @@ -93,15 +87,8 @@ static void smd_tty_work_func(struct work_struct *work)
  56. if (test_bit(TTY_THROTTLED, &tty->flags))
  57. break;
  58.  
  59. - mutex_lock(&smd_tty_lock);
  60. - if (info->ch == 0) {
  61. - mutex_unlock(&smd_tty_lock);
  62. - break;
  63. - }
  64. -
  65. avail = smd_read_avail(info->ch);
  66. if (avail == 0) {
  67. - mutex_unlock(&smd_tty_lock);
  68. break;
  69. }
  70.  
  71. @@ -131,7 +118,7 @@ static void smd_tty_work_func(struct work_struct *work)
  72. //We have had about enough
  73. //need to get started up later because we have already been notified of a non empty
  74. //buffer, unforunately the SLAB is not going to give in atm
  75. - queue_delayed_work(smd_tty_wq, &info->tty_delayed_work,HZ/50);
  76. + tasklet_hi_schedule(&info->tty_tsklt);
  77. printk("SMD%s: tty induced slab failure. high probability of smd pipe freeze. chan %d, needed %d, smallish %d\n",__func__, tty->index, smd_read_avail(info->ch),avail);
  78. if(avail==0)
  79. exit_loop=1;
  80. @@ -175,8 +162,7 @@ static void smd_tty_notify(void *priv, unsigned event)
  81. if (event != SMD_EVENT_DATA)
  82. return;
  83.  
  84. - queue_delayed_work(smd_tty_wq, &info->tty_delayed_work,0);
  85. -
  86. + tasklet_hi_schedule(&info->tty_tsklt);
  87. }
  88.  
  89. static int smd_tty_open(struct tty_struct *tty, struct file *f)
  90. @@ -213,6 +199,7 @@ static int smd_tty_open(struct tty_struct *tty, struct file *f)
  91.  
  92. if (info->open_count++ == 0) {
  93. info->tty = tty;
  94. + tasklet_init(&info->tty_tsklt, smd_tty_read, (unsigned long)info);
  95. if (info->ch) {
  96. smd_kick(info->ch);
  97. } else {
  98. @@ -235,6 +222,7 @@ static void smd_tty_close(struct tty_struct *tty, struct file *f)
  99. if (--info->open_count == 0) {
  100. info->tty = 0;
  101. tty->driver_data = 0;
  102. + tasklet_kill(&info->tty_tsklt);
  103. wake_lock_destroy(&info->wake_lock);
  104. if (info->ch) {
  105. smd_close(info->ch);
  106. @@ -275,7 +263,7 @@ static int smd_tty_chars_in_buffer(struct tty_struct *tty)
  107. static void smd_tty_unthrottle(struct tty_struct *tty)
  108. {
  109. struct smd_tty_info *info = tty->driver_data;
  110. - queue_delayed_work(smd_tty_wq, &info->tty_delayed_work,0);
  111. + tasklet_hi_schedule(&info->tty_tsklt);
  112. return;
  113. }
  114.  
  115. @@ -294,13 +282,8 @@ static int __init smd_tty_init(void)
  116. {
  117. int ret;
  118.  
  119. - smd_tty_wq = create_singlethread_workqueue("smd_tty");
  120. - if (smd_tty_wq == 0)
  121. - return -ENOMEM;
  122. -
  123. smd_tty_driver = alloc_tty_driver(MAX_SMD_TTYS);
  124. if (smd_tty_driver == 0) {
  125. - destroy_workqueue(smd_tty_wq);
  126. return -ENOMEM;
  127. }
  128.  
  129. @@ -325,16 +308,12 @@ static int __init smd_tty_init(void)
  130.  
  131. /* this should be dynamic */
  132. tty_register_device(smd_tty_driver, 0, 0);
  133. - INIT_DELAYED_WORK(&smd_tty[0].tty_delayed_work, smd_tty_work_func);
  134. smd_tty[1].rx_buffer = (unsigned char *)kmalloc(SMD_BUF_SIZE,GFP_KERNEL);
  135. tty_register_device(smd_tty_driver, 1, 0);
  136. - INIT_DELAYED_WORK(&smd_tty[1].tty_delayed_work, smd_tty_work_func);
  137. smd_tty[1].rx_buffer = (unsigned char *)kmalloc(SMD_BUF_SIZE,GFP_KERNEL);
  138. tty_register_device(smd_tty_driver, 7, 0);
  139. - INIT_DELAYED_WORK(&smd_tty[7].tty_delayed_work, smd_tty_work_func);
  140. smd_tty[7].rx_buffer = (unsigned char *)kmalloc(SMD_BUF_SIZE,GFP_KERNEL);
  141. tty_register_device(smd_tty_driver, 27, 0);
  142. - INIT_DELAYED_WORK(&smd_tty[27].tty_delayed_work, smd_tty_work_func);
  143. smd_tty[27].rx_buffer = (unsigned char *)kmalloc(SMD_BUF_SIZE,GFP_KERNEL);
  144.  
  145. return 0;
  146. --
  147. 1.7.7.6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement