200 #include <linux/module.h>
201 #include <linux/reboot.h>
205 #include <linux/errno.h>
206 #include <linux/types.h>
209 #include <linux/pci.h>
210 #include <linux/time.h>
214 #include <asm/uaccess.h>
215 #include <scsi/scsi.h>
222 #define TW_DRIVER_VERSION "1.26.02.003"
225 static int tw_device_extension_count = 0;
226 static int twe_major = -1;
240 static int tw_check_bits(
u32 status_reg_value)
243 dprintk(
KERN_WARNING "3w-xxxx: tw_check_bits(): No expected bits (0x%x).\n", status_reg_value);
247 dprintk(
KERN_WARNING "3w-xxxx: tw_check_bits(): Found unexpected bits (0x%x).\n", status_reg_value);
301 u32 status_reg_value;
302 unsigned long before;
308 if (tw_check_bits(status_reg_value))
309 tw_decode_bits(tw_dev, status_reg_value, 0);
311 while ((status_reg_value & flag) != flag) {
314 if (tw_check_bits(status_reg_value))
315 tw_decode_bits(tw_dev, status_reg_value, 0);
330 u32 status_reg_value;
331 unsigned long before;
337 if (tw_check_bits(status_reg_value))
338 tw_decode_bits(tw_dev, status_reg_value, 0);
340 while ((status_reg_value & flag) != 0) {
343 if (tw_check_bits(status_reg_value))
344 tw_decode_bits(tw_dev, status_reg_value, 0);
359 u32 status_reg_value;
360 unsigned long command_que_value;
366 if (tw_check_bits(status_reg_value)) {
368 tw_decode_bits(tw_dev, status_reg_value, 1);
413 if ((command->
status == 0xc7) || (command->
status == 0xcb)) {
414 for (i = 0; i <
ARRAY_SIZE(tw_sense_table); i++) {
415 if (command->
flags == tw_sense_table[i][0]) {
418 tw_dev->
srb[
request_id]->sense_buffer[0] = (0x1 << 7 | 0x70);
448 u32 status_reg_value;
452 if (
TW_STATUS_ERRORS(status_reg_value) || tw_check_bits(status_reg_value)) {
453 tw_decode_bits(tw_dev, status_reg_value, 0);
463 u32 status_reg_value, response_que_value;
495 unsigned long flags = 0;
500 "Current commands posted: %4d\n"
501 "Max commands posted: %4d\n"
502 "Current pending commands: %4d\n"
503 "Max pending commands: %4d\n"
504 "Last sgl length: %4d\n"
505 "Max sgl length: %4d\n"
506 "Last sector count: %4d\n"
507 "Max sector count: %4d\n"
508 "SCSI Host Resets: %4d\n"
521 spin_unlock_irqrestore(tw_dev->
host->host_lock,
flags);
544 .show = tw_show_stats
558 unsigned long command_que_value;
559 u32 status_reg_value;
560 unsigned long param_value = 0;
565 if (tw_check_bits(status_reg_value)) {
567 tw_decode_bits(tw_dev, status_reg_value, 1);
571 printk(
KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad command packet virtual address.\n");
577 command_packet->
size = 4;
579 command_packet->
status = 0;
580 command_packet->
flags = 0;
583 if (command_que_value == 0) {
584 printk(
KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad command packet physical address.\n");
589 printk(
KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad alignment virtual address.\n");
598 if (param_value == 0) {
599 printk(
KERN_WARNING "3w-xxxx: tw_aen_read_queue(): Bad alignment physical address.\n");
602 command_packet->
byte8.
param.sgl[0].address = param_value;
606 if ((status_reg_value & TW_STATUS_COMMAND_QUEUE_FULL) == 0) {
624 int error = 0, table_max = 0;
632 aen = *(
unsigned short *)(param->
data);
640 if ((aen & 0x0ff) < table_max) {
641 if ((tw_aen_string[aen & 0xff][
strlen(tw_aen_string[aen & 0xff])-1]) ==
'#') {
642 printk(
KERN_WARNING "3w-xxxx: scsi%d: AEN: %s%d.\n", tw_dev->
host->host_no, tw_aen_string[aen & 0xff], aen >> 8);
669 error = tw_aen_read_queue(tw_dev, request_id);
673 tw_state_request_finish(tw_dev, request_id);
677 tw_state_request_finish(tw_dev, request_id);
689 unsigned long command_que_value;
690 unsigned long param_value;
693 unsigned short aen_code;
697 int found = 0, table_max = 0;
702 dprintk(
KERN_WARNING "3w-xxxx: tw_aen_drain_queue(): No attention interrupt for card %d.\n", tw_device_extension_count);
708 tw_empty_response_que(tw_dev);
712 printk(
KERN_WARNING "3w-xxxx: tw_aen_drain_queue(): Bad command packet virtual address.\n");
718 command_packet->
size = 4;
720 command_packet->
status = 0;
721 command_packet->
flags = 0;
724 if (command_que_value == 0) {
725 printk(
KERN_WARNING "3w-xxxx: tw_aen_drain_queue(): Bad command packet physical address.\n");
731 printk(
KERN_WARNING "3w-xxxx: tw_aen_drain_queue(): Bad alignment virtual address.\n");
740 if (param_value == 0) {
741 printk(
KERN_WARNING "3w-xxxx: tw_aen_drain_queue(): Bad alignment physical address.\n");
744 command_packet->
byte8.
param.sgl[0].address = param_value;
753 if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) {
757 if (request_id != 0) {
763 if (command_packet->
status != 0) {
766 tw_decode_sense(tw_dev, request_id, 0);
775 aen = *(
unsigned short *)(param->
data);
776 aen_code = (aen & 0x0ff);
781 if (first_reset != 1) {
788 if (first_reset == 0) {
801 if ((aen & 0x0ff) < table_max) {
802 if ((tw_aen_string[aen & 0xff][
strlen(tw_aen_string[aen & 0xff])-1]) ==
'#') {
836 }
while (finished == 0);
851 if (cpu_addr ==
NULL) {
875 printk(
KERN_WARNING "3w-xxxx: tw_allocate_memory(): case slip in tw_allocate_memory()\n");
884 static long tw_chrdev_ioctl(
struct file *
file,
unsigned int cmd,
unsigned long arg)
888 unsigned short tw_aen_code;
890 unsigned int data_buffer_length = 0;
891 unsigned long data_buffer_length_adjusted = 0;
892 struct inode *
inode = file->f_dentry->d_inode;
911 if (
copy_from_user(&data_buffer_length, argp,
sizeof(
unsigned int)))
921 data_buffer_length_adjusted = (data_buffer_length + 511) & ~511;
925 if (cpu_addr ==
NULL) {
952 if (tw_dev->
aen_head == TW_Q_LENGTH - 1) {
958 spin_unlock_irqrestore(tw_dev->
host->host_lock, flags);
965 tw_state_request_start(tw_dev, &request_id);
994 tw_post_command_packet(tw_dev, request_id);
995 spin_unlock_irqrestore(tw_dev->
host->host_lock, flags);
1005 printk(
KERN_WARNING "3w-xxxx: scsi%d: Character ioctl (0x%x) timed out, resetting card.\n", tw_dev->
host->host_no, cmd);
1007 if (tw_reset_device_extension(tw_dev)) {
1020 tw_state_request_finish(tw_dev, request_id);
1021 spin_unlock_irqrestore(tw_dev->
host->host_lock, flags);
1043 static int tw_chrdev_open(
struct inode *inode,
struct file *file)
1045 unsigned int minor_number;
1049 minor_number = iminor(inode);
1050 if (minor_number >= tw_device_extension_count)
1059 .unlocked_ioctl = tw_chrdev_ioctl,
1060 .open = tw_chrdev_open,
1081 unsigned long command_que_value;
1090 printk(
KERN_WARNING "3w-xxxx: tw_initconnection(): Bad command packet virtual address.\n");
1099 command_packet->
status = 0x0;
1100 command_packet->
flags = 0x0;
1105 if (command_que_value == 0) {
1106 printk(
KERN_WARNING "3w-xxxx: tw_initconnection(): Bad command packet physical address.\n");
1114 if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) {
1118 if (request_id != 0) {
1123 if (command_packet->
status != 0) {
1125 tw_decode_sense(tw_dev, request_id, 0);
1140 unsigned long command_que_value;
1141 unsigned long param_value;
1145 printk(
KERN_WARNING "3w-xxxx: tw_setfeature(): Bad command packet virtual address.\n");
1159 if (param_value == 0) {
1162 tw_state_request_finish(tw_dev, request_id);
1166 command_packet->
byte8.
param.sgl[0].address = param_value;
1169 command_packet->
size = 4;
1174 if (command_que_value == 0) {
1175 printk(
KERN_WARNING "3w-xxxx: tw_setfeature(): Bad command packet physical address.\n");
1183 if (tw_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, 30) == 0) {
1187 if (request_id != 0) {
1192 if (command_packet->
status != 0) {
1194 tw_decode_sense(tw_dev, request_id, 0);
1207 unsigned char c = 1;
1213 error = tw_aen_drain_queue(tw_dev);
1221 if (tw_check_errors(tw_dev)) {
1232 printk(
KERN_WARNING "3w-xxxx: scsi%d: Controller errors, card not responding, check all cabling.\n", tw_dev->
host->host_no);
1242 error = tw_setfeature(tw_dev, 2, 1, &c);
1244 printk(
KERN_WARNING "3w-xxxx: Unable to set features for card, probable old firmware or card.\n");
1258 error = tw_allocate_memory(tw_dev,
sizeof(
TW_Command), 0);
1265 error = tw_allocate_memory(tw_dev,
sizeof(
TW_Sector), 1);
1286 static int tw_map_scsi_sg_data(
struct pci_dev *pdev,
struct scsi_cmnd *cmd)
1299 cmd->
SCp.have_data_in = use_sg;
1304 static void tw_unmap_scsi_data(
struct pci_dev *pdev,
struct scsi_cmnd *cmd)
1317 unsigned long flags = 0;
1331 srb = tw_dev->
srb[
i];
1334 tw_dev->
srb[
i]->scsi_done(tw_dev->
srb[i]);
1353 spin_unlock_irqrestore(tw_dev->
host->host_lock, flags);
1355 if (tw_reset_sequence(tw_dev)) {
1379 cylinders =
sector_div(capacity, heads * sectors);
1381 if (capacity >= 0x200000) {
1384 cylinders =
sector_div(capacity, heads * sectors);
1387 dprintk(
KERN_NOTICE "3w-xxxx: tw_scsi_biosparam(): heads = %d, sectors = %d, cylinders = %d\n", heads, sectors, cylinders);
1396 static int tw_scsi_eh_reset(
struct scsi_cmnd *SCpnt)
1406 "WARNING: Command (0x%x) timed out, resetting card.\n",
1413 if (tw_reset_device_extension(tw_dev)) {
1429 unsigned long command_que_value;
1430 unsigned long param_value;
1436 if (command_packet ==
NULL) {
1437 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_inquiry(): Bad command packet virtual address.\n");
1442 command_packet->
size = 4;
1444 command_packet->
status = 0;
1445 command_packet->
flags = 0;
1450 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_inquiry(): Bad alignment virtual address.\n");
1459 if (param_value == 0) {
1460 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_inquiry(): Bad alignment physical address.\n");
1464 command_packet->
byte8.
param.sgl[0].address = param_value;
1467 if (command_que_value == 0) {
1468 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_inquiry(): Bad command packet physical address.\n");
1473 tw_post_command_packet(tw_dev, request_id);
1479 void *
data,
unsigned int len)
1481 scsi_sg_copy_from_buffer(tw_dev->
srb[request_id], data, len);
1487 unsigned char *is_unit_present;
1493 memset(request_buffer, 0,
sizeof(request_buffer));
1495 request_buffer[1] = 0;
1496 request_buffer[2] = 0;
1497 request_buffer[4] = 31;
1498 memcpy(&request_buffer[8],
"3ware ", 8);
1499 sprintf(&request_buffer[16],
"Logical Disk %-2d ", tw_dev->
srb[request_id]->device->id);
1501 tw_transfer_internal(tw_dev, request_id, request_buffer,
1502 sizeof(request_buffer));
1506 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_inquiry_complete(): Bad alignment virtual address.\n");
1509 is_unit_present = &(param->
data[0]);
1527 unsigned long command_que_value;
1528 unsigned long param_value;
1533 if (tw_dev->
srb[request_id]->cmnd[2] != 0x8) {
1535 tw_state_request_finish(tw_dev, request_id);
1543 if (command_packet ==
NULL) {
1544 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_mode_sense(): Bad command packet virtual address.\n");
1551 command_packet->
size = 4;
1553 command_packet->
status = 0;
1554 command_packet->
flags = 0;
1559 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_mode_sense(): Bad alignment virtual address.\n");
1569 if (param_value == 0) {
1570 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_mode_sense(): Bad alignment physical address.\n");
1574 command_packet->
byte8.
param.sgl[0].address = param_value;
1577 if (command_que_value == 0) {
1578 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_mode_sense(): Bad command packet physical address.\n");
1583 tw_post_command_packet(tw_dev, request_id);
1592 unsigned char *
flags;
1593 unsigned char request_buffer[8];
1599 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_mode_sense_complete(): Bad alignment virtual address.\n");
1602 flags = (
char *)&(param->
data[0]);
1603 memset(request_buffer, 0,
sizeof(request_buffer));
1605 request_buffer[0] = 0xf;
1606 request_buffer[1] = 0;
1607 request_buffer[2] = 0x10;
1608 request_buffer[3] = 0;
1609 request_buffer[4] = 0x8;
1610 request_buffer[5] = 0xa;
1612 request_buffer[6] = 0x5;
1614 request_buffer[6] = 0x1;
1615 tw_transfer_internal(tw_dev, request_id, request_buffer,
1616 sizeof(request_buffer));
1626 unsigned long command_que_value;
1627 unsigned long param_value;
1634 if (command_packet ==
NULL) {
1635 dprintk(
KERN_NOTICE "3w-xxxx: tw_scsiop_read_capacity(): Bad command packet virtual address.\n");
1640 command_packet->
size = 4;
1643 command_packet->
status = 0;
1644 command_packet->
flags = 0;
1649 dprintk(
KERN_NOTICE "3w-xxxx: tw_scsiop_read_capacity(): Bad alignment virtual address.\n");
1659 if (param_value == 0) {
1660 dprintk(
KERN_NOTICE "3w-xxxx: tw_scsiop_read_capacity(): Bad alignment physical address.\n");
1664 command_packet->
byte8.
param.sgl[0].address = param_value;
1667 if (command_que_value == 0) {
1668 dprintk(
KERN_NOTICE "3w-xxxx: tw_scsiop_read_capacity(): Bad command packet physical address.\n");
1673 tw_post_command_packet(tw_dev, request_id);
1681 unsigned char *param_data;
1688 memset(buff, 0,
sizeof(buff));
1691 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_read_capacity_complete(): Bad alignment virtual address.\n");
1694 param_data = &(param->
data[0]);
1696 capacity = (param_data[3] << 24) | (param_data[2] << 16) |
1697 (param_data[1] << 8) | param_data[0];
1702 dprintk(
KERN_NOTICE "3w-xxxx: tw_scsiop_read_capacity_complete(): Capacity = 0x%x.\n", capacity);
1705 buff[0] = (capacity >> 24);
1706 buff[1] = (capacity >> 16) & 0xff;
1707 buff[2] = (capacity >> 8) & 0xff;
1708 buff[3] = capacity & 0xff;
1716 tw_transfer_internal(tw_dev, request_id, buff,
sizeof(buff));
1725 unsigned long command_que_value;
1726 u32 lba = 0x0, num_sectors = 0x0;
1735 sglist = scsi_sglist(srb);
1743 if (command_packet ==
NULL) {
1744 dprintk(
KERN_NOTICE "3w-xxxx: tw_scsiop_read_write(): Bad command packet virtual address.\n");
1754 command_packet->
size = 3;
1757 command_packet->
status = 0;
1758 command_packet->
flags = 0;
1761 if ((srb->
cmnd[1] & 0x8) || (srb->
cmnd[1] & 0x10))
1762 command_packet->
flags = 1;
1767 num_sectors = (
u32)srb->
cmnd[4];
1778 dprintk(
KERN_NOTICE "3w-xxxx: tw_scsiop_read_write(): lba = 0x%x num_sectors = 0x%x\n", lba, num_sectors);
1782 use_sg = tw_map_scsi_sg_data(tw_dev->
tw_pci_dev, tw_dev->
srb[request_id]);
1789 command_packet->
size+=2;
1798 if (command_que_value == 0) {
1799 dprintk(
KERN_WARNING "3w-xxxx: tw_scsiop_read_write(): Bad command packet physical address.\n");
1804 tw_post_command_packet(tw_dev, request_id);
1812 char request_buffer[18];
1816 memset(request_buffer, 0,
sizeof(request_buffer));
1817 request_buffer[0] = 0x70;
1818 request_buffer[7] = 10;
1820 tw_transfer_internal(tw_dev, request_id, request_buffer,
1821 sizeof(request_buffer));
1824 tw_state_request_finish(tw_dev, request_id);
1837 unsigned long command_que_value;
1843 if (command_packet ==
NULL) {
1844 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_synchronize_cache(): Bad command packet virtual address.\n");
1851 command_packet->
size = 2;
1854 command_packet->
status = 0;
1855 command_packet->
flags = 0;
1858 if (command_que_value == 0) {
1859 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_synchronize_cache(): Bad command packet physical address.\n");
1864 tw_post_command_packet(tw_dev, request_id);
1874 unsigned long command_que_value;
1875 unsigned long param_value;
1881 if (command_packet ==
NULL) {
1882 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready(): Bad command packet virtual address.\n");
1887 command_packet->
size = 4;
1889 command_packet->
status = 0;
1890 command_packet->
flags = 0;
1895 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready(): Bad alignment virtual address.\n");
1904 if (param_value == 0) {
1905 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready(): Bad alignment physical address.\n");
1909 command_packet->
byte8.
param.sgl[0].address = param_value;
1912 if (command_que_value == 0) {
1913 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready(): Bad command packet physical address.\n");
1918 tw_post_command_packet(tw_dev, request_id);
1924 static int tw_scsiop_test_unit_ready_complete(
TW_Device_Extension *tw_dev,
int request_id)
1926 unsigned char *is_unit_present;
1933 printk(
KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready_complete(): Bad alignment virtual address.\n");
1936 is_unit_present = &(param->
data[0]);
1952 unsigned char *command = SCpnt->
cmnd;
1965 tw_state_request_start(tw_dev, &request_id);
1979 retval = tw_scsiop_read_write(tw_dev, request_id);
1983 retval = tw_scsiop_test_unit_ready(tw_dev, request_id);
1987 retval = tw_scsiop_inquiry(tw_dev, request_id);
1991 retval = tw_scsiop_read_capacity(tw_dev, request_id);
1995 retval = tw_scsiop_request_sense(tw_dev, request_id);
1999 retval = tw_scsiop_mode_sense(tw_dev, request_id);
2003 retval = tw_scsiop_synchronize_cache(tw_dev, request_id);
2006 printk(
KERN_WARNING "3w-xxxx: SCSI_IOCTL_SEND_COMMAND deprecated, please update your 3ware tools.\n");
2009 printk(
KERN_NOTICE "3w-xxxx: scsi%d: Unknown scsi opcode: 0x%x\n", tw_dev->
host->host_no, *command);
2011 tw_state_request_finish(tw_dev, request_id);
2018 tw_state_request_finish(tw_dev, request_id);
2029 static
irqreturn_t tw_interrupt(
int irq,
void *dev_instance)
2032 u32 status_reg_value;
2035 int error = 0, retval = 0;
2040 spin_lock(tw_dev->
host->host_lock);
2047 goto tw_interrupt_bail;
2053 goto tw_interrupt_bail;
2056 if (tw_check_bits(status_reg_value)) {
2058 if (tw_decode_bits(tw_dev, status_reg_value, 1)) {
2060 goto tw_interrupt_bail;
2074 tw_state_request_start(tw_dev, &request_id);
2075 error = tw_aen_read_queue(tw_dev, request_id);
2079 tw_state_request_finish(tw_dev, request_id);
2092 if (tw_post_command_packet(tw_dev, request_id)==0) {
2112 while ((status_reg_value & TW_STATUS_RESPONSE_QUEUE_EMPTY) == 0) {
2122 if (tw_dev->
srb[request_id] ==
NULL) {
2123 tw_decode_sense(tw_dev, request_id, 0);
2125 error = tw_decode_sense(tw_dev, request_id, 1);
2131 if (tw_dev->
srb[request_id] !=
NULL) {
2132 printk(
KERN_WARNING "3w-xxxx: scsi%d: Received a request id that wasn't posted.\n", tw_dev->
host->host_no);
2137 dprintk(
KERN_NOTICE "3w-xxxx: tw_interrupt(): Response queue request id: %d.\n", request_id);
2140 if (tw_dev->
srb[request_id] ==
NULL) {
2144 retval = tw_aen_complete(tw_dev, request_id);
2153 switch (tw_dev->
srb[request_id]->cmnd[0]) {
2164 error = tw_scsiop_test_unit_ready_complete(tw_dev, request_id);
2168 error = tw_scsiop_inquiry_complete(tw_dev, request_id);
2172 error = tw_scsiop_read_capacity_complete(tw_dev, request_id);
2176 error = tw_scsiop_mode_sense_complete(tw_dev, request_id);
2200 tw_state_request_finish(tw_dev, request_id);
2204 tw_unmap_scsi_data(tw_dev->
tw_pci_dev, tw_dev->
srb[request_id]);
2210 if (tw_check_bits(status_reg_value)) {
2212 if (tw_decode_bits(tw_dev, status_reg_value, 1)) {
2214 goto tw_interrupt_bail;
2221 spin_unlock(tw_dev->
host->host_lock);
2237 if (tw_initconnection(tw_dev, 1)) {
2248 static void tw_shutdown(
struct pci_dev *pdev)
2250 struct Scsi_Host *host = pci_get_drvdata(pdev);
2253 __tw_shutdown(tw_dev);
2257 static int tw_slave_configure(
struct scsi_device *sdev)
2267 .name =
"3ware Storage Controller",
2268 .queuecommand = tw_scsi_queue,
2269 .eh_host_reset_handler = tw_scsi_eh_reset,
2270 .bios_param = tw_scsi_biosparam,
2271 .change_queue_depth = tw_change_queue_depth,
2272 .can_queue = TW_Q_LENGTH-2,
2273 .slave_configure = tw_slave_configure,
2279 .shost_attrs = tw_host_attrs,
2293 goto out_disable_device;
2301 goto out_disable_device;
2308 goto out_disable_device;
2313 tw_dev->
host = host;
2316 if (tw_initialize_device_extension(tw_dev)) {
2318 goto out_free_device_extension;
2325 goto out_free_device_extension;
2332 goto out_release_mem_region;
2339 if (tw_reset_sequence(tw_dev))
2340 goto out_release_mem_region;
2351 retval = scsi_add_host(host, &pdev->
dev);
2354 goto out_release_mem_region;
2357 pci_set_drvdata(pdev, host);
2365 goto out_remove_host;
2368 tw_device_extension_list[tw_device_extension_count] = tw_dev;
2369 tw_device_extension_count++;
2377 if (twe_major == -1) {
2378 if ((twe_major = register_chrdev (0,
"twe", &tw_fops)) < 0)
2385 out_release_mem_region:
2387 out_free_device_extension:
2388 tw_free_device_extension(tw_dev);
2397 static void tw_remove(
struct pci_dev *pdev)
2399 struct Scsi_Host *host = pci_get_drvdata(pdev);
2405 if (twe_major >= 0) {
2406 unregister_chrdev(twe_major,
"twe");
2411 __tw_shutdown(tw_dev);
2417 tw_free_device_extension(tw_dev);
2421 tw_device_extension_count--;
2437 .id_table = tw_pci_tbl,
2439 .remove = tw_remove,
2440 .shutdown = tw_shutdown,
2444 static int __init tw_init(
void)
2448 return pci_register_driver(&tw_driver);
2452 static void __exit tw_exit(
void)