rationalize allocation and freeing of struct scsi_device
PATCH 1/1 rationalize allocation and freeing of struct scsi_device
Currently allocation and freeing of struct scsi_device is a mess. We have two nice functions in scsi_scan.c (scsi_allocate_sdev/ scsi_free_sdev) that are the right interfaces to deal with it, so I moved them to scsi and made them non-static. I've changed all functions allocation freeing them to use it. There's also a new helper scsi_release_sdev that deals with getting rid of a currently attached sdev.
drivers/scsi/hosts.c +2 -22
@@ -182,33 +182,13 @@ } } -/* -* Next we detach the high level drivers from the Scsi_Device -* structures -*/ -for (sdev = shost->host_queue; sdev; sdev = sdev->next) { -scsi_detach_device (sdev); - +for (sdev = shost->host_queue; sdev; sdev = shost->host_queue) {/* If something still attached, punt */ -if (sdev->attached) { +if (scsi_release_sdev (sdev)) {printk (KERN_ERR "Attached usage count = %d\n" , sdev->attached);return 1 ; } -devfs_unregister (sdev->de); -device_unregister (&sdev->sdev_driverfs_dev); - } - -/* Next we free up the Scsi_Cmnd structures for this host */ - -for (sdev = shost->host_queue; sdev; - sdev = shost->host_queue) { -blk_cleanup_queue (&sdev->request_queue); -/* Next free up the Scsi_Device structures for this host */ - shost->host_queue = sdev->next; -if (sdev->inquiry) -kfree (sdev->inquiry); -kfree (sdev); }return 0 ;
===== drivers/scsi/scsi.c 1.59 vs edited =====
drivers/scsi/scsi.c +159 -80
277 lines not on this page · raw message
===== drivers/scsi/scsi.h 1.36 vs edited =====
drivers/scsi/scsi.h +6 -0
@@ -397,6 +397,8 @@typedef struct scsi_cmnd Scsi_Cmnd ;typedef struct scsi_request Scsi_Request ; +struct Scsi_Host ; +#define SCSI_CMND_MAGIC 0xE25C23A5#define SCSI_REQ_MAGIC 0x75F6D354
@@ -483,6 +485,10 @@extern int scsi_mlqueue_insert (struct scsi_cmnd *,int );extern int scsi_attach_device (struct scsi_device *);extern void scsi_detach_device (struct scsi_device *); +extern struct scsi_device *scsi_alloc_sdev (struct Scsi_Host *, +uint ,uint ,uint ); +extern void scsi_free_sdev (struct scsi_device *); +extern int scsi_release_sdev (struct scsi_device *);/* * Newer request-based interfaces.
===== drivers/scsi/scsi_scan.c 1.34 vs edited =====
drivers/scsi/scsi_scan.c +0 -114
126 lines not on this page · raw message
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html