Commit 6c9b9c554b2a369d2b46558975ef2eaa3a84c1c3

Authored by Ondrej Zary
Committed by Martin K. Petersen
1 parent dd5a5f7951

atp870u: Simplify _probe()

Move shpnt common code to the top, remove base_io, use pci_resource_len.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

Showing 1 changed file with 28 additions and 37 deletions Side-by-side Diff

drivers/scsi/atp870u.c
... ... @@ -1245,7 +1245,7 @@
1245 1245 {
1246 1246 unsigned char k, m, c;
1247 1247 unsigned long flags;
1248   - unsigned int base_io, error,n;
  1248 + unsigned int error,n;
1249 1249 unsigned char host_id;
1250 1250 struct Scsi_Host *shpnt = NULL;
1251 1251 struct atp_unit *atpdev;
1252 1252  
1253 1253  
... ... @@ -1278,21 +1278,24 @@
1278 1278 atpdev->pdev = pdev;
1279 1279 pci_set_drvdata(pdev, atpdev);
1280 1280  
1281   - base_io = pci_resource_start(pdev, 0);
1282   - base_io &= 0xfffffff8;
1283   - atpdev->baseport = base_io;
  1281 + shpnt->io_port = pci_resource_start(pdev, 0);
  1282 + shpnt->io_port &= 0xfffffff8;
  1283 + shpnt->n_io_port = pci_resource_len(pdev, 0);
  1284 + atpdev->baseport = shpnt->io_port;
  1285 + shpnt->unique_id = shpnt->io_port;
  1286 + shpnt->irq = pdev->irq;
1284 1287  
1285 1288 if ((ent->device == ATP880_DEVID1)||(ent->device == ATP880_DEVID2)) {
1286 1289 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x80);//JCC082803
1287 1290  
1288   - atpdev->ioport[0] = base_io + 0x40;
1289   - atpdev->pciport[0] = base_io + 0x28;
  1291 + atpdev->ioport[0] = shpnt->io_port + 0x40;
  1292 + atpdev->pciport[0] = shpnt->io_port + 0x28;
1290 1293  
1291 1294 host_id = atp_readb_base(atpdev, 0x39);
1292 1295 host_id >>= 0x04;
1293 1296  
1294 1297 printk(KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter:"
1295   - " IO:%x, IRQ:%d.\n", base_io, pdev->irq);
  1298 + " IO:%lx, IRQ:%d.\n", shpnt->io_port, shpnt->irq);
1296 1299 atpdev->dev_id = ent->device;
1297 1300 atpdev->host_id[0] = host_id;
1298 1301  
1299 1302  
... ... @@ -1358,9 +1361,9 @@
1358 1361 goto unregister;
1359 1362 }
1360 1363  
1361   - err = request_irq(pdev->irq, atp870u_intr_handle, IRQF_SHARED, "atp880i", shpnt);
  1364 + err = request_irq(shpnt->irq, atp870u_intr_handle, IRQF_SHARED, "atp880i", shpnt);
1362 1365 if (err) {
1363   - printk(KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n", pdev->irq);
  1366 + printk(KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n", shpnt->irq);
1364 1367 goto free_tables;
1365 1368 }
1366 1369  
1367 1370  
1368 1371  
... ... @@ -1381,20 +1384,16 @@
1381 1384 atp_writeb_base(atpdev, 0x38, 0xb0);
1382 1385 shpnt->max_id = 16;
1383 1386 shpnt->this_id = host_id;
1384   - shpnt->unique_id = base_io;
1385   - shpnt->io_port = base_io;
1386   - shpnt->n_io_port = 0x60; /* Number of bytes of I/O space used */
1387   - shpnt->irq = pdev->irq;
1388 1387 } else if (ent->device == ATP885_DEVID) {
1389   - printk(KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%x, IRQ:%d.\n"
1390   - , base_io, pdev->irq);
  1388 + printk(KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n"
  1389 + , shpnt->io_port, shpnt->irq);
1391 1390  
1392 1391 atpdev->pdev = pdev;
1393 1392 atpdev->dev_id = ent->device;
1394   - atpdev->ioport[0] = base_io + 0x80;
1395   - atpdev->ioport[1] = base_io + 0xc0;
1396   - atpdev->pciport[0] = base_io + 0x40;
1397   - atpdev->pciport[1] = base_io + 0x50;
  1393 + atpdev->ioport[0] = shpnt->io_port + 0x80;
  1394 + atpdev->ioport[1] = shpnt->io_port + 0xc0;
  1395 + atpdev->pciport[0] = shpnt->io_port + 0x40;
  1396 + atpdev->pciport[1] = shpnt->io_port + 0x50;
1398 1397  
1399 1398 if (atp870u_init_tables(shpnt) < 0) {
1400 1399 err = -ENOMEM;
... ... @@ -1404,7 +1403,7 @@
1404 1403 #ifdef ED_DBGP
1405 1404 printk("request_irq() shpnt %p hostdata %p\n", shpnt, atpdev);
1406 1405 #endif
1407   - err = request_irq(pdev->irq, atp870u_intr_handle, IRQF_SHARED, "atp870u", shpnt);
  1406 + err = request_irq(shpnt->irq, atp870u_intr_handle, IRQF_SHARED, "atp870u", shpnt);
1408 1407 if (err) {
1409 1408 printk(KERN_ERR "Unable to allocate IRQ for Acard controller.\n");
1410 1409 goto free_tables;
... ... @@ -1516,11 +1515,6 @@
1516 1515 shpnt->max_lun = (atpdev->global_map[0] & 0x07) + 1;
1517 1516 shpnt->max_channel = 1;
1518 1517 shpnt->this_id = atpdev->host_id[0];
1519   - shpnt->unique_id = base_io;
1520   - shpnt->io_port = base_io;
1521   - shpnt->n_io_port = 0xff; /* Number of bytes of I/O space used */
1522   - shpnt->irq = pdev->irq;
1523   -
1524 1518 } else {
1525 1519 bool wide_chip =
1526 1520 (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 &&
1527 1521  
... ... @@ -1530,10 +1524,10 @@
1530 1524 error = pci_read_config_byte(pdev, 0x49, &host_id);
1531 1525  
1532 1526 printk(KERN_INFO " ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: "
1533   - "IO:%x, IRQ:%d.\n", base_io, pdev->irq);
  1527 + "IO:%lx, IRQ:%d.\n", shpnt->io_port, shpnt->irq);
1534 1528  
1535   - atpdev->ioport[0] = base_io;
1536   - atpdev->pciport[0] = base_io + 0x20;
  1529 + atpdev->ioport[0] = shpnt->io_port;
  1530 + atpdev->pciport[0] = shpnt->io_port + 0x20;
1537 1531 atpdev->dev_id = ent->device;
1538 1532 host_id &= 0x07;
1539 1533 atpdev->host_id[0] = host_id;
1540 1534  
... ... @@ -1553,9 +1547,9 @@
1553 1547 goto unregister;
1554 1548 }
1555 1549  
1556   - err = request_irq(pdev->irq, atp870u_intr_handle, IRQF_SHARED, "atp870i", shpnt);
  1550 + err = request_irq(shpnt->irq, atp870u_intr_handle, IRQF_SHARED, "atp870i", shpnt);
1557 1551 if (err) {
1558   - printk(KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n", pdev->irq);
  1552 + printk(KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n", shpnt->irq);
1559 1553 goto free_tables;
1560 1554 }
1561 1555  
1562 1556  
... ... @@ -1579,13 +1573,10 @@
1579 1573 atp_writeb_base(atpdev, 0x3b, atp_readb_base(atpdev, 0x3b) | 0x20);
1580 1574 shpnt->max_id = wide_chip ? 16 : 8;
1581 1575 shpnt->this_id = host_id;
1582   - shpnt->unique_id = base_io;
1583   - shpnt->io_port = base_io;
1584   - shpnt->n_io_port = 0x40; /* Number of bytes of I/O space used */
1585   - shpnt->irq = pdev->irq;
  1576 +
1586 1577 }
1587 1578 spin_unlock_irqrestore(shpnt->host_lock, flags);
1588   - if (!request_region(base_io, shpnt->n_io_port, "atp870u")) {
  1579 + if (!request_region(shpnt->io_port, shpnt->n_io_port, "atp870u")) {
1589 1580 err = -EBUSY;
1590 1581 goto request_io_fail;
1591 1582 }
1592 1583  
... ... @@ -1600,10 +1591,10 @@
1600 1591  
1601 1592 scsi_add_fail:
1602 1593 printk("atp870u_prob:scsi_add_fail\n");
1603   - release_region(base_io, shpnt->n_io_port);
  1594 + release_region(shpnt->io_port, shpnt->n_io_port);
1604 1595 request_io_fail:
1605 1596 printk("atp870u_prob:request_io_fail\n");
1606   - free_irq(pdev->irq, shpnt);
  1597 + free_irq(shpnt->irq, shpnt);
1607 1598 free_tables:
1608 1599 printk("atp870u_prob:free_table\n");
1609 1600 atp870u_free_tables(shpnt);