/* Calculate the logical drive number based on the information in scsi command and the channel number.  */
static int mega_get_ldrv_num(adapter_t *adapter, Scsi_Cmnd *cmd, int channel)
/* Calculate the logical drive number based on the information in scsi command and the channel number.  */
static int mega_get_ldrv_num(adapter_t *adapter, Scsi_Cmnd *cmd, int channel)
{
	int		tgt;
	int		ldrv_num;
	tgt = cmd->device->id;
	if ( tgt > adapter->this_id )
		tgt--;
	ldrv_num = (channel * 15) + tgt;
	if( adapter->boot_ldrv_enabled ) {
		if( ldrv_num == 0 ) {
			ldrv_num = adapter->boot_ldrv;
		}
		else {
			if( ldrv_num <= adapter->boot_ldrv ) {
				ldrv_num--;
			}
		}
	}
	if (adapter->support_random_del && adapter->read_ldidmap )
		switch (cmd->cmnd[0]) {
		case READ_6:
		case WRITE_6:
		case READ_10:
		case WRITE_10:
			ldrv_num += 0x80;
		}
	return ldrv_num;
}