struct scsi_command *scsicmd =
container_of ( refcnt, struct scsi_command, refcnt );
- /* Remove from list of commands */
- list_del ( &scsicmd->list );
+ /* Drop reference to SCSI device */
scsidev_put ( scsicmd->scsidev );
/* Free command */
/* Shut down interfaces */
intfs_shutdown ( rc, &scsicmd->scsi, &scsicmd->block, NULL );
+
+ /* Remove from list of commands and drop list's reference */
+ list_del ( &scsicmd->list );
+ scsicmd_put ( scsicmd );
}
/**
if ( ( rc = scsicmd_command ( scsicmd ) ) != 0 )
goto err_command;
- /* Attach to parent interface, mortalise self, and return */
+ /* Attach to parent interface, transfer reference to list, and return */
intf_plug_plug ( &scsicmd->block, block );
- ref_put ( &scsicmd->refcnt );
return 0;
err_command:
NULL );
/* Shut down any remaining commands */
- list_for_each_entry_safe ( scsicmd, tmp, &scsidev->cmds, list ) {
- scsicmd_get ( scsicmd );
+ list_for_each_entry_safe ( scsicmd, tmp, &scsidev->cmds, list )
scsicmd_close ( scsicmd, rc );
- scsicmd_put ( scsicmd );
- }
}
/** SCSI device block interface operations */