瀏覽代碼

[PATCH] synclink.c: add clear stats

Add the ability to clear statistics.

Signed-off-by: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Paul Fulghum 19 年之前
父節點
當前提交
9661239f7f
共有 1 個文件被更改,包括 8 次插入6 次删除
  1. 8 6
      drivers/char/synclink.c

+ 8 - 6
drivers/char/synclink.c

@@ -1814,6 +1814,8 @@ static int startup(struct mgsl_struct * info)
 
 
 	info->pending_bh = 0;
 	info->pending_bh = 0;
 	
 	
+	memset(&info->icount, 0, sizeof(info->icount));
+
 	init_timer(&info->tx_timer);
 	init_timer(&info->tx_timer);
 	info->tx_timer.data = (unsigned long)info;
 	info->tx_timer.data = (unsigned long)info;
 	info->tx_timer.function = mgsl_tx_timeout;
 	info->tx_timer.function = mgsl_tx_timeout;
@@ -2470,12 +2472,12 @@ static int mgsl_get_stats(struct mgsl_struct * info, struct mgsl_icount __user *
 		printk("%s(%d):mgsl_get_params(%s)\n",
 		printk("%s(%d):mgsl_get_params(%s)\n",
 			 __FILE__,__LINE__, info->device_name);
 			 __FILE__,__LINE__, info->device_name);
 			
 			
-	COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount));
-	if (err) {
-		if ( debug_level >= DEBUG_LEVEL_INFO )
-			printk( "%s(%d):mgsl_get_stats(%s) user buffer copy failed\n",
-				__FILE__,__LINE__,info->device_name);
-		return -EFAULT;
+	if (!user_icount) {
+		memset(&info->icount, 0, sizeof(info->icount));
+	} else {
+		COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount));
+		if (err)
+			return -EFAULT;
 	}
 	}
 	
 	
 	return 0;
 	return 0;