patch-2.4.6 linux/drivers/atm/idt77105.c

Next file: linux/drivers/atm/iphase.c
Previous file: linux/drivers/atm/fore200e_mkfirm.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.5/linux/drivers/atm/idt77105.c linux/drivers/atm/idt77105.c
@@ -144,18 +144,18 @@
 static int fetch_stats(struct atm_dev *dev,struct idt77105_stats *arg,int zero)
 {
 	unsigned long flags;
-	int error;
+	struct idt77105_stats stats;
 
-	error = 0;
 	save_flags(flags);
 	cli();
-	if (arg)
-		error = copy_to_user(arg,&PRIV(dev)->stats,
-		    sizeof(struct idt77105_stats));
-	if (zero && !error)
-		memset(&PRIV(dev)->stats,0,sizeof(struct idt77105_stats));
+	memcpy(&stats, &PRIV(dev)->stats, sizeof(struct idt77105_stats));
+	if (zero)
+		memset(&PRIV(dev)->stats, 0, sizeof(struct idt77105_stats));
 	restore_flags(flags);
-	return error ? -EFAULT : sizeof(struct idt77105_stats);
+	if (arg == NULL)
+		return 0;
+	return copy_to_user(arg, &PRIV(dev)->stats,
+		    sizeof(struct idt77105_stats)) ? -EFAULT : 0;
 }
 
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)