aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/synclink.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/synclink.c')
-rw-r--r--drivers/char/synclink.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 0658fc548222..2b03d4d47350 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -81,7 +81,6 @@
81#include <linux/mm.h> 81#include <linux/mm.h>
82#include <linux/seq_file.h> 82#include <linux/seq_file.h>
83#include <linux/slab.h> 83#include <linux/slab.h>
84#include <linux/smp_lock.h>
85#include <linux/delay.h> 84#include <linux/delay.h>
86#include <linux/netdevice.h> 85#include <linux/netdevice.h>
87#include <linux/vmalloc.h> 86#include <linux/vmalloc.h>
@@ -2436,7 +2435,9 @@ static int mgsl_get_stats(struct mgsl_struct * info, struct mgsl_icount __user *
2436 if (!user_icount) { 2435 if (!user_icount) {
2437 memset(&info->icount, 0, sizeof(info->icount)); 2436 memset(&info->icount, 0, sizeof(info->icount));
2438 } else { 2437 } else {
2438 mutex_lock(&info->port.mutex);
2439 COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); 2439 COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount));
2440 mutex_unlock(&info->port.mutex);
2440 if (err) 2441 if (err)
2441 return -EFAULT; 2442 return -EFAULT;
2442 } 2443 }
@@ -2461,7 +2462,9 @@ static int mgsl_get_params(struct mgsl_struct * info, MGSL_PARAMS __user *user_p
2461 printk("%s(%d):mgsl_get_params(%s)\n", 2462 printk("%s(%d):mgsl_get_params(%s)\n",
2462 __FILE__,__LINE__, info->device_name); 2463 __FILE__,__LINE__, info->device_name);
2463 2464
2465 mutex_lock(&info->port.mutex);
2464 COPY_TO_USER(err,user_params, &info->params, sizeof(MGSL_PARAMS)); 2466 COPY_TO_USER(err,user_params, &info->params, sizeof(MGSL_PARAMS));
2467 mutex_unlock(&info->port.mutex);
2465 if (err) { 2468 if (err) {
2466 if ( debug_level >= DEBUG_LEVEL_INFO ) 2469 if ( debug_level >= DEBUG_LEVEL_INFO )
2467 printk( "%s(%d):mgsl_get_params(%s) user buffer copy failed\n", 2470 printk( "%s(%d):mgsl_get_params(%s) user buffer copy failed\n",
@@ -2501,11 +2504,13 @@ static int mgsl_set_params(struct mgsl_struct * info, MGSL_PARAMS __user *new_pa
2501 return -EFAULT; 2504 return -EFAULT;
2502 } 2505 }
2503 2506
2507 mutex_lock(&info->port.mutex);
2504 spin_lock_irqsave(&info->irq_spinlock,flags); 2508 spin_lock_irqsave(&info->irq_spinlock,flags);
2505 memcpy(&info->params,&tmp_params,sizeof(MGSL_PARAMS)); 2509 memcpy(&info->params,&tmp_params,sizeof(MGSL_PARAMS));
2506 spin_unlock_irqrestore(&info->irq_spinlock,flags); 2510 spin_unlock_irqrestore(&info->irq_spinlock,flags);
2507 2511
2508 mgsl_change_params(info); 2512 mgsl_change_params(info);
2513 mutex_unlock(&info->port.mutex);
2509 2514
2510 return 0; 2515 return 0;
2511 2516
@@ -2935,7 +2940,6 @@ static int mgsl_ioctl(struct tty_struct *tty, struct file * file,
2935 unsigned int cmd, unsigned long arg) 2940 unsigned int cmd, unsigned long arg)
2936{ 2941{
2937 struct mgsl_struct * info = tty->driver_data; 2942 struct mgsl_struct * info = tty->driver_data;
2938 int ret;
2939 2943
2940 if (debug_level >= DEBUG_LEVEL_INFO) 2944 if (debug_level >= DEBUG_LEVEL_INFO)
2941 printk("%s(%d):mgsl_ioctl %s cmd=%08X\n", __FILE__,__LINE__, 2945 printk("%s(%d):mgsl_ioctl %s cmd=%08X\n", __FILE__,__LINE__,
@@ -2950,10 +2954,7 @@ static int mgsl_ioctl(struct tty_struct *tty, struct file * file,
2950 return -EIO; 2954 return -EIO;
2951 } 2955 }
2952 2956
2953 lock_kernel(); 2957 return mgsl_ioctl_common(info, cmd, arg);
2954 ret = mgsl_ioctl_common(info, cmd, arg);
2955 unlock_kernel();
2956 return ret;
2957} 2958}
2958 2959
2959static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg) 2960static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg)
@@ -3109,12 +3110,14 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
3109 3110
3110 if (tty_port_close_start(&info->port, tty, filp) == 0) 3111 if (tty_port_close_start(&info->port, tty, filp) == 0)
3111 goto cleanup; 3112 goto cleanup;
3112 3113
3114 mutex_lock(&info->port.mutex);
3113 if (info->port.flags & ASYNC_INITIALIZED) 3115 if (info->port.flags & ASYNC_INITIALIZED)
3114 mgsl_wait_until_sent(tty, info->timeout); 3116 mgsl_wait_until_sent(tty, info->timeout);
3115 mgsl_flush_buffer(tty); 3117 mgsl_flush_buffer(tty);
3116 tty_ldisc_flush(tty); 3118 tty_ldisc_flush(tty);
3117 shutdown(info); 3119 shutdown(info);
3120 mutex_unlock(&info->port.mutex);
3118 3121
3119 tty_port_close_end(&info->port, tty); 3122 tty_port_close_end(&info->port, tty);
3120 info->port.tty = NULL; 3123 info->port.tty = NULL;
@@ -3162,7 +3165,6 @@ static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout)
3162 * Note: use tight timings here to satisfy the NIST-PCTS. 3165 * Note: use tight timings here to satisfy the NIST-PCTS.
3163 */ 3166 */
3164 3167
3165 lock_kernel();
3166 if ( info->params.data_rate ) { 3168 if ( info->params.data_rate ) {
3167 char_time = info->timeout/(32 * 5); 3169 char_time = info->timeout/(32 * 5);
3168 if (!char_time) 3170 if (!char_time)
@@ -3192,7 +3194,6 @@ static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout)
3192 break; 3194 break;
3193 } 3195 }
3194 } 3196 }
3195 unlock_kernel();
3196 3197
3197exit: 3198exit:
3198 if (debug_level >= DEBUG_LEVEL_INFO) 3199 if (debug_level >= DEBUG_LEVEL_INFO)