patch-2.0.1 linux/drivers/scsi/sg.c

Next file: linux/drivers/scsi/st.c
Previous file: linux/drivers/scsi/scsi.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.0/linux/drivers/scsi/sg.c linux/drivers/scsi/sg.c
@@ -230,7 +230,7 @@
      * Now copy the result back to the user buffer.
      */
     device->header.pack_len=device->header.reply_len;
-    device->header.result=0;
+
     if (count>=sizeof(struct sg_header))
     {
 	memcpy_tofs(buf,&device->header,sizeof(struct sg_header));
@@ -242,7 +242,7 @@
 	}
     }
     else
-	count=0;
+	count= device->header.result==0 ? 0 : -EIO;
     
     /*
      * Clean up, and release the device so that we can send another
@@ -276,12 +276,7 @@
      * wrong.
      */
     memcpy(device->header.sense_buffer, SCpnt->sense_buffer, sizeof(SCpnt->sense_buffer));
-    if (SCpnt->sense_buffer[0])
-    {
-	device->header.result=EIO;
-    }
-    else
-	device->header.result=SCpnt->result;
+    device->header.result=SCpnt->result;
 
     /*
      * Now wake up the process that is waiting for the
@@ -593,6 +588,11 @@
 	    gpnt->device = NULL;
 	    SDp->attached--;
 	    sg_template.nr_dev--;
+            /* 
+             * avoid associated device /dev/sg? bying incremented 
+             * each time module is inserted/removed , <dan@lectra.fr>
+             */
+            sg_template.dev_noticed--;
 	    return;
 	}
     return;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov