Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

qlogicpti: Convert to pure OF driver.

Signed-off-by: David S. Miller <davem@davemloft.net>

+56 -54
+55 -53
drivers/scsi/qlogicpti.c
··· 1 1 /* qlogicpti.c: Performance Technologies QlogicISP sbus card driver. 2 2 * 3 - * Copyright (C) 1996, 2006 David S. Miller (davem@davemloft.net) 3 + * Copyright (C) 1996, 2006, 2008 David S. Miller (davem@davemloft.net) 4 4 * 5 5 * A lot of this driver was directly stolen from Erik H. Moe's PCI 6 6 * Qlogic ISP driver. Mucho kudos to him for this code. ··· 26 26 #include <linux/module.h> 27 27 #include <linux/jiffies.h> 28 28 #include <linux/dma-mapping.h> 29 + #include <linux/of.h> 30 + #include <linux/of_device.h> 29 31 30 32 #include <asm/byteorder.h> 31 33 32 34 #include "qlogicpti.h" 33 35 34 - #include <asm/sbus.h> 35 36 #include <asm/dma.h> 36 37 #include <asm/system.h> 37 38 #include <asm/ptrace.h> ··· 686 685 687 686 static int __devinit qpti_map_regs(struct qlogicpti *qpti) 688 687 { 689 - struct sbus_dev *sdev = qpti->sdev; 688 + struct of_device *op = qpti->op; 690 689 691 - qpti->qregs = sbus_ioremap(&sdev->resource[0], 0, 692 - sdev->reg_addrs[0].reg_size, 693 - "PTI Qlogic/ISP"); 690 + qpti->qregs = of_ioremap(&op->resource[0], 0, 691 + resource_size(&op->resource[0]), 692 + "PTI Qlogic/ISP"); 694 693 if (!qpti->qregs) { 695 694 printk("PTI: Qlogic/ISP registers are unmappable\n"); 696 695 return -1; 697 696 } 698 697 if (qpti->is_pti) { 699 - qpti->sreg = sbus_ioremap(&sdev->resource[0], (16 * 4096), 700 - sizeof(unsigned char), 701 - "PTI Qlogic/ISP statreg"); 698 + qpti->sreg = of_ioremap(&op->resource[0], (16 * 4096), 699 + sizeof(unsigned char), 700 + "PTI Qlogic/ISP statreg"); 702 701 if (!qpti->sreg) { 703 702 printk("PTI: Qlogic/ISP status register is unmappable\n"); 704 703 return -1; ··· 709 708 710 709 static int __devinit qpti_register_irq(struct qlogicpti *qpti) 711 710 { 712 - struct sbus_dev *sdev = qpti->sdev; 711 + struct of_device *op = qpti->op; 713 712 714 - qpti->qhost->irq = qpti->irq = sdev->irqs[0]; 713 + qpti->qhost->irq = qpti->irq = op->irqs[0]; 715 714 716 715 /* We used to try various overly-clever things to 717 716 * reduce the interrupt processing overhead on ··· 734 733 735 734 static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) 736 735 { 737 - qpti->scsi_id = prom_getintdefault(qpti->prom_node, 738 - "initiator-id", 739 - -1); 736 + struct of_device *op = qpti->op; 737 + struct device_node *dp; 738 + 739 + dp = op->node; 740 + 741 + qpti->scsi_id = of_getintprop_default(dp, "initiator-id", -1); 740 742 if (qpti->scsi_id == -1) 741 - qpti->scsi_id = prom_getintdefault(qpti->prom_node, 742 - "scsi-initiator-id", 743 - -1); 743 + qpti->scsi_id = of_getintprop_default(dp, "scsi-initiator-id", 744 + -1); 744 745 if (qpti->scsi_id == -1) 745 746 qpti->scsi_id = 746 - prom_getintdefault(qpti->sdev->bus->prom_node, 747 - "scsi-initiator-id", 7); 747 + of_getintprop_default(dp->parent, 748 + "scsi-initiator-id", 7); 748 749 qpti->qhost->this_id = qpti->scsi_id; 749 750 qpti->qhost->max_sectors = 64; 750 751 ··· 755 752 756 753 static void qpti_get_bursts(struct qlogicpti *qpti) 757 754 { 758 - struct sbus_dev *sdev = qpti->sdev; 755 + struct of_device *op = qpti->op; 759 756 u8 bursts, bmask; 760 757 761 - bursts = prom_getintdefault(qpti->prom_node, "burst-sizes", 0xff); 762 - bmask = prom_getintdefault(sdev->bus->prom_node, 763 - "burst-sizes", 0xff); 758 + bursts = of_getintprop_default(op->node, "burst-sizes", 0xff); 759 + bmask = of_getintprop_default(op->node->parent, "burst-sizes", 0xff); 764 760 if (bmask != 0xff) 765 761 bursts &= bmask; 766 762 if (bursts == 0xff || ··· 788 786 */ 789 787 static int __devinit qpti_map_queues(struct qlogicpti *qpti) 790 788 { 791 - struct sbus_dev *sdev = qpti->sdev; 789 + struct of_device *op = qpti->op; 792 790 793 791 #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) 794 - qpti->res_cpu = dma_alloc_coherent(&sdev->ofdev.dev, 792 + qpti->res_cpu = dma_alloc_coherent(&op->dev, 795 793 QSIZE(RES_QUEUE_LEN), 796 794 &qpti->res_dvma, GFP_ATOMIC); 797 795 if (qpti->res_cpu == NULL || ··· 800 798 return -1; 801 799 } 802 800 803 - qpti->req_cpu = dma_alloc_coherent(&sdev->ofdev.dev, 801 + qpti->req_cpu = dma_alloc_coherent(&op->dev, 804 802 QSIZE(QLOGICPTI_REQ_QUEUE_LEN), 805 803 &qpti->req_dvma, GFP_ATOMIC); 806 804 if (qpti->req_cpu == NULL || 807 805 qpti->req_dvma == 0) { 808 - dma_free_coherent(&sdev->ofdev.dev, QSIZE(RES_QUEUE_LEN), 806 + dma_free_coherent(&op->dev, QSIZE(RES_QUEUE_LEN), 809 807 qpti->res_cpu, qpti->res_dvma); 810 808 printk("QPTI: Cannot map request queue.\n"); 811 809 return -1; ··· 878 876 int sg_count; 879 877 880 878 sg = scsi_sglist(Cmnd); 881 - sg_count = dma_map_sg(&qpti->sdev->ofdev.dev, sg, 879 + sg_count = dma_map_sg(&qpti->op->dev, sg, 882 880 scsi_sg_count(Cmnd), 883 881 Cmnd->sc_data_direction); 884 882 ··· 1155 1153 Cmnd->result = DID_ERROR << 16; 1156 1154 1157 1155 if (scsi_bufflen(Cmnd)) 1158 - dma_unmap_sg(&qpti->sdev->ofdev.dev, 1156 + dma_unmap_sg(&qpti->op->dev, 1159 1157 scsi_sglist(Cmnd), scsi_sg_count(Cmnd), 1160 1158 Cmnd->sc_data_direction); 1161 1159 ··· 1271 1269 .use_clustering = ENABLE_CLUSTERING, 1272 1270 }; 1273 1271 1274 - static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_device_id *match) 1272 + static int __devinit qpti_sbus_probe(struct of_device *op, const struct of_device_id *match) 1275 1273 { 1276 - static int nqptis; 1277 - struct sbus_dev *sdev = to_sbus_device(&dev->dev); 1278 - struct device_node *dp = dev->node; 1279 1274 struct scsi_host_template *tpnt = match->data; 1275 + struct device_node *dp = op->node; 1280 1276 struct Scsi_Host *host; 1281 1277 struct qlogicpti *qpti; 1278 + static int nqptis; 1282 1279 const char *fcode; 1283 1280 1284 1281 /* Sometimes Antares cards come up not completely 1285 1282 * setup, and we get a report of a zero IRQ. 1286 1283 */ 1287 - if (sdev->irqs[0] == 0) 1284 + if (op->irqs[0] == 0) 1288 1285 return -ENODEV; 1289 1286 1290 1287 host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti)); 1291 1288 if (!host) 1292 1289 return -ENOMEM; 1293 1290 1294 - qpti = (struct qlogicpti *) host->hostdata; 1291 + qpti = shost_priv(host); 1295 1292 1296 1293 host->max_id = MAX_TARGETS; 1297 1294 qpti->qhost = host; 1298 - qpti->sdev = sdev; 1295 + qpti->op = op; 1299 1296 qpti->qpti_id = nqptis; 1300 - qpti->prom_node = sdev->prom_node; 1301 - strcpy(qpti->prom_name, sdev->ofdev.node->name); 1297 + strcpy(qpti->prom_name, op->node->name); 1302 1298 qpti->is_pti = strcmp(qpti->prom_name, "QLGC,isp"); 1303 1299 1304 1300 if (qpti_map_regs(qpti) < 0) ··· 1342 1342 (qpti->ultra ? "Ultra" : "Fast"), 1343 1343 (qpti->differential ? "differential" : "single ended")); 1344 1344 1345 - if (scsi_add_host(host, &dev->dev)) { 1345 + if (scsi_add_host(host, &op->dev)) { 1346 1346 printk("qlogicpti%d: Failed scsi_add_host\n", qpti->qpti_id); 1347 1347 goto fail_unmap_queues; 1348 1348 } 1349 1349 1350 - dev_set_drvdata(&sdev->ofdev.dev, qpti); 1350 + dev_set_drvdata(&op->dev, qpti); 1351 1351 1352 1352 qpti_chain_add(qpti); 1353 1353 ··· 1358 1358 1359 1359 fail_unmap_queues: 1360 1360 #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) 1361 - dma_free_coherent(&qpti->sdev->ofdev.dev, 1361 + dma_free_coherent(&op->dev, 1362 1362 QSIZE(RES_QUEUE_LEN), 1363 1363 qpti->res_cpu, qpti->res_dvma); 1364 - dma_free_coherent(&qpti->sdev->ofdev.dev, 1364 + dma_free_coherent(&op->dev, 1365 1365 QSIZE(QLOGICPTI_REQ_QUEUE_LEN), 1366 1366 qpti->req_cpu, qpti->req_dvma); 1367 1367 #undef QSIZE 1368 1368 1369 1369 fail_unmap_regs: 1370 - sbus_iounmap(qpti->qregs, 1371 - qpti->sdev->reg_addrs[0].reg_size); 1370 + of_iounmap(&op->resource[0], qpti->qregs, 1371 + resource_size(&op->resource[0])); 1372 1372 if (qpti->is_pti) 1373 - sbus_iounmap(qpti->sreg, sizeof(unsigned char)); 1373 + of_iounmap(&op->resource[0], qpti->sreg, 1374 + sizeof(unsigned char)); 1374 1375 1375 1376 fail_free_irq: 1376 1377 free_irq(qpti->irq, qpti); ··· 1382 1381 return -ENODEV; 1383 1382 } 1384 1383 1385 - static int __devexit qpti_sbus_remove(struct of_device *dev) 1384 + static int __devexit qpti_sbus_remove(struct of_device *op) 1386 1385 { 1387 - struct qlogicpti *qpti = dev_get_drvdata(&dev->dev); 1386 + struct qlogicpti *qpti = dev_get_drvdata(&op->dev); 1388 1387 1389 1388 qpti_chain_del(qpti); 1390 1389 ··· 1397 1396 free_irq(qpti->irq, qpti); 1398 1397 1399 1398 #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) 1400 - dma_free_coherent(&qpti->sdev->ofdev.dev, 1399 + dma_free_coherent(&op->dev, 1401 1400 QSIZE(RES_QUEUE_LEN), 1402 1401 qpti->res_cpu, qpti->res_dvma); 1403 - dma_free_coherent(&qpti->sdev->ofdev.dev, 1402 + dma_free_coherent(&op->dev, 1404 1403 QSIZE(QLOGICPTI_REQ_QUEUE_LEN), 1405 1404 qpti->req_cpu, qpti->req_dvma); 1406 1405 #undef QSIZE 1407 1406 1408 - sbus_iounmap(qpti->qregs, qpti->sdev->reg_addrs[0].reg_size); 1407 + of_iounmap(&op->resource[0], qpti->qregs, 1408 + resource_size(&op->resource[0])); 1409 1409 if (qpti->is_pti) 1410 - sbus_iounmap(qpti->sreg, sizeof(unsigned char)); 1410 + of_iounmap(&op->resource[0], qpti->sreg, sizeof(unsigned char)); 1411 1411 1412 1412 scsi_host_put(qpti->qhost); 1413 1413 ··· 1445 1443 1446 1444 static int __init qpti_init(void) 1447 1445 { 1448 - return of_register_driver(&qpti_sbus_driver, &sbus_bus_type); 1446 + return of_register_driver(&qpti_sbus_driver, &of_bus_type); 1449 1447 } 1450 1448 1451 1449 static void __exit qpti_exit(void) ··· 1456 1454 MODULE_DESCRIPTION("QlogicISP SBUS driver"); 1457 1455 MODULE_AUTHOR("David S. Miller (davem@davemloft.net)"); 1458 1456 MODULE_LICENSE("GPL"); 1459 - MODULE_VERSION("2.0"); 1457 + MODULE_VERSION("2.1"); 1460 1458 1461 1459 module_init(qpti_init); 1462 1460 module_exit(qpti_exit);
+1 -1
drivers/scsi/qlogicpti.h
··· 342 342 u_int req_in_ptr; /* index of next request slot */ 343 343 u_int res_out_ptr; /* index of next result slot */ 344 344 long send_marker; /* must we send a marker? */ 345 - struct sbus_dev *sdev; 345 + struct of_device *op; 346 346 unsigned long __pad; 347 347 348 348 int cmd_count[MAX_TARGETS];