Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 382731502c73afe0672a2a32f6059f5ced1ca894 Mon Sep 17 00:00:00 2001
- From: detule <ogjoneski@gmail.com>
- Date: Fri, 20 Apr 2012 16:44:43 -0400
- Subject: [PATCH] For CptAJ: intermediate tty patch
- ---
- arch/arm/mach-msm/smd_tty.c | 39 +++++++++------------------------------
- 1 files changed, 9 insertions(+), 30 deletions(-)
- diff --git a/arch/arm/mach-msm/smd_tty.c b/arch/arm/mach-msm/smd_tty.c
- index 61f3c18..d0210f2 100644
- --- a/arch/arm/mach-msm/smd_tty.c
- +++ b/arch/arm/mach-msm/smd_tty.c
- @@ -18,7 +18,7 @@
- #include <linux/fs.h>
- #include <linux/cdev.h>
- #include <linux/device.h>
- -#include <linux/wait.h>
- +#include <linux/interrupt.h>
- #include <linux/wakelock.h>
- #include <linux/slab.h>
- @@ -39,7 +39,7 @@ struct smd_tty_info {
- struct tty_struct *tty;
- struct wake_lock wake_lock;
- int open_count;
- - struct delayed_work tty_delayed_work;
- + struct tasklet_struct tty_tsklt;
- unsigned char *rx_buffer;
- };
- @@ -69,20 +69,14 @@ static void smd_readx_cb(void *data, int count, void *ctxt)
- }
- }
- -static void smd_tty_work_func(struct work_struct *work)
- +static void smd_tty_read(unsigned long param)
- {
- unsigned char *ptr;
- int avail;
- int fail_cnt=0;
- int exit_loop=0;
- - struct delayed_work *delayed_work = container_of(work,
- - struct delayed_work,
- - work);
- -
- - struct smd_tty_info *info = container_of(delayed_work,
- - struct smd_tty_info,
- - tty_delayed_work);
- + struct smd_tty_info *info = (struct smd_tty_info *)param;
- struct tty_struct *tty = info->tty;
- @@ -93,15 +87,8 @@ static void smd_tty_work_func(struct work_struct *work)
- if (test_bit(TTY_THROTTLED, &tty->flags))
- break;
- - mutex_lock(&smd_tty_lock);
- - if (info->ch == 0) {
- - mutex_unlock(&smd_tty_lock);
- - break;
- - }
- -
- avail = smd_read_avail(info->ch);
- if (avail == 0) {
- - mutex_unlock(&smd_tty_lock);
- break;
- }
- @@ -131,7 +118,7 @@ static void smd_tty_work_func(struct work_struct *work)
- //We have had about enough
- //need to get started up later because we have already been notified of a non empty
- //buffer, unforunately the SLAB is not going to give in atm
- - queue_delayed_work(smd_tty_wq, &info->tty_delayed_work,HZ/50);
- + tasklet_hi_schedule(&info->tty_tsklt);
- 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);
- if(avail==0)
- exit_loop=1;
- @@ -175,8 +162,7 @@ static void smd_tty_notify(void *priv, unsigned event)
- if (event != SMD_EVENT_DATA)
- return;
- - queue_delayed_work(smd_tty_wq, &info->tty_delayed_work,0);
- -
- + tasklet_hi_schedule(&info->tty_tsklt);
- }
- static int smd_tty_open(struct tty_struct *tty, struct file *f)
- @@ -213,6 +199,7 @@ static int smd_tty_open(struct tty_struct *tty, struct file *f)
- if (info->open_count++ == 0) {
- info->tty = tty;
- + tasklet_init(&info->tty_tsklt, smd_tty_read, (unsigned long)info);
- if (info->ch) {
- smd_kick(info->ch);
- } else {
- @@ -235,6 +222,7 @@ static void smd_tty_close(struct tty_struct *tty, struct file *f)
- if (--info->open_count == 0) {
- info->tty = 0;
- tty->driver_data = 0;
- + tasklet_kill(&info->tty_tsklt);
- wake_lock_destroy(&info->wake_lock);
- if (info->ch) {
- smd_close(info->ch);
- @@ -275,7 +263,7 @@ static int smd_tty_chars_in_buffer(struct tty_struct *tty)
- static void smd_tty_unthrottle(struct tty_struct *tty)
- {
- struct smd_tty_info *info = tty->driver_data;
- - queue_delayed_work(smd_tty_wq, &info->tty_delayed_work,0);
- + tasklet_hi_schedule(&info->tty_tsklt);
- return;
- }
- @@ -294,13 +282,8 @@ static int __init smd_tty_init(void)
- {
- int ret;
- - smd_tty_wq = create_singlethread_workqueue("smd_tty");
- - if (smd_tty_wq == 0)
- - return -ENOMEM;
- -
- smd_tty_driver = alloc_tty_driver(MAX_SMD_TTYS);
- if (smd_tty_driver == 0) {
- - destroy_workqueue(smd_tty_wq);
- return -ENOMEM;
- }
- @@ -325,16 +308,12 @@ static int __init smd_tty_init(void)
- /* this should be dynamic */
- tty_register_device(smd_tty_driver, 0, 0);
- - INIT_DELAYED_WORK(&smd_tty[0].tty_delayed_work, smd_tty_work_func);
- smd_tty[1].rx_buffer = (unsigned char *)kmalloc(SMD_BUF_SIZE,GFP_KERNEL);
- tty_register_device(smd_tty_driver, 1, 0);
- - INIT_DELAYED_WORK(&smd_tty[1].tty_delayed_work, smd_tty_work_func);
- smd_tty[1].rx_buffer = (unsigned char *)kmalloc(SMD_BUF_SIZE,GFP_KERNEL);
- tty_register_device(smd_tty_driver, 7, 0);
- - INIT_DELAYED_WORK(&smd_tty[7].tty_delayed_work, smd_tty_work_func);
- smd_tty[7].rx_buffer = (unsigned char *)kmalloc(SMD_BUF_SIZE,GFP_KERNEL);
- tty_register_device(smd_tty_driver, 27, 0);
- - INIT_DELAYED_WORK(&smd_tty[27].tty_delayed_work, smd_tty_work_func);
- smd_tty[27].rx_buffer = (unsigned char *)kmalloc(SMD_BUF_SIZE,GFP_KERNEL);
- return 0;
- --
- 1.7.7.6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement