diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-09-27 06:41:25 -0400 |
---|---|---|
committer | Jens Axboe <axboe@carl.home.kernel.dk> | 2007-10-10 03:25:59 -0400 |
commit | 4e0af881afee2b399854b1cdfdbe37e6ab6a09ca (patch) | |
tree | 84fd69a82b717996614c99cf29e342fbbfc8b5cd /drivers/block/umem.c | |
parent | 3084f0c6105a71e43225c36b4d97c1407988a242 (diff) |
drivers/block/umem: use dev_printk()
dev_printk() gives us a consistent prefix (driver name + PCI bus id),
which allows us to eliminate the hand-rolled one.
Also allows us to eliminate card->card_number, which was used solely in
printk() calls.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/block/umem.c')
-rw-r--r-- | drivers/block/umem.c | 111 |
1 files changed, 62 insertions, 49 deletions
diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 33ef7661e1c1..32060b84c0fd 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c | |||
@@ -97,7 +97,6 @@ static int major_nr; | |||
97 | #include <linux/blkpg.h> | 97 | #include <linux/blkpg.h> |
98 | 98 | ||
99 | struct cardinfo { | 99 | struct cardinfo { |
100 | int card_number; | ||
101 | struct pci_dev *dev; | 100 | struct pci_dev *dev; |
102 | 101 | ||
103 | int irq; | 102 | int irq; |
@@ -236,7 +235,7 @@ static void dump_regs(struct cardinfo *card) | |||
236 | */ | 235 | */ |
237 | static void dump_dmastat(struct cardinfo *card, unsigned int dmastat) | 236 | static void dump_dmastat(struct cardinfo *card, unsigned int dmastat) |
238 | { | 237 | { |
239 | printk(KERN_DEBUG "MM%d*: DMAstat - ", card->card_number); | 238 | dev_printk(KERN_DEBUG, &card->dev->dev, "DMAstat - "); |
240 | if (dmastat & DMASCR_ANY_ERR) | 239 | if (dmastat & DMASCR_ANY_ERR) |
241 | printk("ANY_ERR "); | 240 | printk("ANY_ERR "); |
242 | if (dmastat & DMASCR_MBE_ERR) | 241 | if (dmastat & DMASCR_MBE_ERR) |
@@ -499,17 +498,17 @@ static void process_page(unsigned long data) | |||
499 | if (control & DMASCR_HARD_ERROR) { | 498 | if (control & DMASCR_HARD_ERROR) { |
500 | /* error */ | 499 | /* error */ |
501 | clear_bit(BIO_UPTODATE, &bio->bi_flags); | 500 | clear_bit(BIO_UPTODATE, &bio->bi_flags); |
502 | printk(KERN_WARNING "MM%d: I/O error on sector %d/%d\n", | 501 | dev_printk(KERN_WARNING, &card->dev->dev, |
503 | card->card_number, | 502 | "I/O error on sector %d/%d\n", |
504 | le32_to_cpu(desc->local_addr)>>9, | 503 | le32_to_cpu(desc->local_addr)>>9, |
505 | le32_to_cpu(desc->transfer_size)); | 504 | le32_to_cpu(desc->transfer_size)); |
506 | dump_dmastat(card, control); | 505 | dump_dmastat(card, control); |
507 | } else if (test_bit(BIO_RW, &bio->bi_rw) && | 506 | } else if (test_bit(BIO_RW, &bio->bi_rw) && |
508 | le32_to_cpu(desc->local_addr)>>9 == card->init_size) { | 507 | le32_to_cpu(desc->local_addr)>>9 == card->init_size) { |
509 | card->init_size += le32_to_cpu(desc->transfer_size)>>9; | 508 | card->init_size += le32_to_cpu(desc->transfer_size)>>9; |
510 | if (card->init_size>>1 >= card->mm_size) { | 509 | if (card->init_size>>1 >= card->mm_size) { |
511 | printk(KERN_INFO "MM%d: memory now initialised\n", | 510 | dev_printk(KERN_INFO, &card->dev->dev, |
512 | card->card_number); | 511 | "memory now initialised\n"); |
513 | set_userbit(card, MEMORY_INITIALIZED, 1); | 512 | set_userbit(card, MEMORY_INITIALIZED, 1); |
514 | } | 513 | } |
515 | } | 514 | } |
@@ -618,46 +617,51 @@ HW_TRACE(0x30); | |||
618 | dump_dmastat(card, dma_status); | 617 | dump_dmastat(card, dma_status); |
619 | 618 | ||
620 | if (stat & 0x01) | 619 | if (stat & 0x01) |
621 | printk(KERN_ERR "MM%d*: Memory access error detected (err count %d)\n", | 620 | dev_printk(KERN_ERR, &card->dev->dev, |
622 | card->card_number, count); | 621 | "Memory access error detected (err count %d)\n", |
622 | count); | ||
623 | if (stat & 0x02) | 623 | if (stat & 0x02) |
624 | printk(KERN_ERR "MM%d*: Multi-bit EDC error\n", | 624 | dev_printk(KERN_ERR, &card->dev->dev, |
625 | card->card_number); | 625 | "Multi-bit EDC error\n"); |
626 | 626 | ||
627 | printk(KERN_ERR "MM%d*: Fault Address 0x%02x%08x, Fault Data 0x%08x%08x\n", | 627 | dev_printk(KERN_ERR, &card->dev->dev, |
628 | card->card_number, addr_log2, addr_log1, data_log2, data_log1); | 628 | "Fault Address 0x%02x%08x, Fault Data 0x%08x%08x\n", |
629 | printk(KERN_ERR "MM%d*: Fault Check 0x%02x, Fault Syndrome 0x%02x\n", | 629 | addr_log2, addr_log1, data_log2, data_log1); |
630 | card->card_number, check, syndrome); | 630 | dev_printk(KERN_ERR, &card->dev->dev, |
631 | "Fault Check 0x%02x, Fault Syndrome 0x%02x\n", | ||
632 | check, syndrome); | ||
631 | 633 | ||
632 | writeb(0, card->csr_remap + ERROR_COUNT); | 634 | writeb(0, card->csr_remap + ERROR_COUNT); |
633 | } | 635 | } |
634 | 636 | ||
635 | if (dma_status & DMASCR_PARITY_ERR_REP) { | 637 | if (dma_status & DMASCR_PARITY_ERR_REP) { |
636 | printk(KERN_ERR "MM%d*: PARITY ERROR REPORTED\n", card->card_number); | 638 | dev_printk(KERN_ERR, &card->dev->dev, |
639 | "PARITY ERROR REPORTED\n"); | ||
637 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); | 640 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); |
638 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); | 641 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); |
639 | } | 642 | } |
640 | 643 | ||
641 | if (dma_status & DMASCR_PARITY_ERR_DET) { | 644 | if (dma_status & DMASCR_PARITY_ERR_DET) { |
642 | printk(KERN_ERR "MM%d*: PARITY ERROR DETECTED\n", card->card_number); | 645 | dev_printk(KERN_ERR, &card->dev->dev, |
646 | "PARITY ERROR DETECTED\n"); | ||
643 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); | 647 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); |
644 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); | 648 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); |
645 | } | 649 | } |
646 | 650 | ||
647 | if (dma_status & DMASCR_SYSTEM_ERR_SIG) { | 651 | if (dma_status & DMASCR_SYSTEM_ERR_SIG) { |
648 | printk(KERN_ERR "MM%d*: SYSTEM ERROR\n", card->card_number); | 652 | dev_printk(KERN_ERR, &card->dev->dev, "SYSTEM ERROR\n"); |
649 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); | 653 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); |
650 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); | 654 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); |
651 | } | 655 | } |
652 | 656 | ||
653 | if (dma_status & DMASCR_TARGET_ABT) { | 657 | if (dma_status & DMASCR_TARGET_ABT) { |
654 | printk(KERN_ERR "MM%d*: TARGET ABORT\n", card->card_number); | 658 | dev_printk(KERN_ERR, &card->dev->dev, "TARGET ABORT\n"); |
655 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); | 659 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); |
656 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); | 660 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); |
657 | } | 661 | } |
658 | 662 | ||
659 | if (dma_status & DMASCR_MASTER_ABT) { | 663 | if (dma_status & DMASCR_MASTER_ABT) { |
660 | printk(KERN_ERR "MM%d*: MASTER ABORT\n", card->card_number); | 664 | dev_printk(KERN_ERR, &card->dev->dev, "MASTER ABORT\n"); |
661 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); | 665 | pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); |
662 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); | 666 | pci_write_config_word(card->dev, PCI_STATUS, cfg_status); |
663 | } | 667 | } |
@@ -708,20 +712,20 @@ static int check_battery(struct cardinfo *card, int battery, int status) | |||
708 | card->battery[battery].last_change = jiffies; | 712 | card->battery[battery].last_change = jiffies; |
709 | 713 | ||
710 | if (card->battery[battery].good) { | 714 | if (card->battery[battery].good) { |
711 | printk(KERN_ERR "MM%d: Battery %d now good\n", | 715 | dev_printk(KERN_ERR, &card->dev->dev, |
712 | card->card_number, battery + 1); | 716 | "Battery %d now good\n", battery + 1); |
713 | card->battery[battery].warned = 0; | 717 | card->battery[battery].warned = 0; |
714 | } else | 718 | } else |
715 | printk(KERN_ERR "MM%d: Battery %d now FAILED\n", | 719 | dev_printk(KERN_ERR, &card->dev->dev, |
716 | card->card_number, battery + 1); | 720 | "Battery %d now FAILED\n", battery + 1); |
717 | 721 | ||
718 | return 1; | 722 | return 1; |
719 | } else if (!card->battery[battery].good && | 723 | } else if (!card->battery[battery].good && |
720 | !card->battery[battery].warned && | 724 | !card->battery[battery].warned && |
721 | time_after_eq(jiffies, card->battery[battery].last_change + | 725 | time_after_eq(jiffies, card->battery[battery].last_change + |
722 | (HZ * 60 * 60 * 5))) { | 726 | (HZ * 60 * 60 * 5))) { |
723 | printk(KERN_ERR "MM%d: Battery %d still FAILED after 5 hours\n", | 727 | dev_printk(KERN_ERR, &card->dev->dev, |
724 | card->card_number, battery + 1); | 728 | "Battery %d still FAILED after 5 hours\n", battery + 1); |
725 | card->battery[battery].warned = 1; | 729 | card->battery[battery].warned = 1; |
726 | 730 | ||
727 | return 1; | 731 | return 1; |
@@ -745,8 +749,8 @@ static void check_batteries(struct cardinfo *card) | |||
745 | 749 | ||
746 | status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY); | 750 | status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY); |
747 | if (debug & DEBUG_BATTERY_POLLING) | 751 | if (debug & DEBUG_BATTERY_POLLING) |
748 | printk(KERN_DEBUG "MM%d: checking battery status, 1 = %s, 2 = %s\n", | 752 | dev_printk(KERN_DEBUG, &card->dev->dev, |
749 | card->card_number, | 753 | "checking battery status, 1 = %s, 2 = %s\n", |
750 | (status & BATTERY_1_FAILURE) ? "FAILURE" : "OK", | 754 | (status & BATTERY_1_FAILURE) ? "FAILURE" : "OK", |
751 | (status & BATTERY_2_FAILURE) ? "FAILURE" : "OK"); | 755 | (status & BATTERY_2_FAILURE) ? "FAILURE" : "OK"); |
752 | 756 | ||
@@ -866,6 +870,10 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
866 | unsigned char batt_status; | 870 | unsigned char batt_status; |
867 | unsigned int saved_bar, data; | 871 | unsigned int saved_bar, data; |
868 | int magic_number; | 872 | int magic_number; |
873 | static int printed_version; | ||
874 | |||
875 | if (!printed_version++) | ||
876 | printk(KERN_INFO DRIVER_VERSION " : " DRIVER_DESC "\n"); | ||
869 | 877 | ||
870 | if (pci_enable_device(dev) < 0) | 878 | if (pci_enable_device(dev) < 0) |
871 | return -ENODEV; | 879 | return -ENODEV; |
@@ -874,21 +882,21 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
874 | pci_set_master(dev); | 882 | pci_set_master(dev); |
875 | 883 | ||
876 | card->dev = dev; | 884 | card->dev = dev; |
877 | card->card_number = num_cards; | ||
878 | 885 | ||
879 | card->csr_base = pci_resource_start(dev, 0); | 886 | card->csr_base = pci_resource_start(dev, 0); |
880 | card->csr_len = pci_resource_len(dev, 0); | 887 | card->csr_len = pci_resource_len(dev, 0); |
881 | 888 | ||
882 | printk(KERN_INFO "Micro Memory(tm) controller #%d found at %02x:%02x (PCI Mem Module (Battery Backup))\n", | 889 | dev_printk(KERN_INFO, &dev->dev, |
883 | card->card_number, dev->bus->number, dev->devfn); | 890 | "Micro Memory(tm) controller found (PCI Mem Module (Battery Backup))\n"); |
884 | 891 | ||
885 | if (pci_set_dma_mask(dev, DMA_64BIT_MASK) && | 892 | if (pci_set_dma_mask(dev, DMA_64BIT_MASK) && |
886 | pci_set_dma_mask(dev, DMA_32BIT_MASK)) { | 893 | pci_set_dma_mask(dev, DMA_32BIT_MASK)) { |
887 | printk(KERN_WARNING "MM%d: NO suitable DMA found\n",num_cards); | 894 | dev_printk(KERN_WARNING, &dev->dev, "NO suitable DMA found\n"); |
888 | return -ENOMEM; | 895 | return -ENOMEM; |
889 | } | 896 | } |
890 | if (!request_mem_region(card->csr_base, card->csr_len, "Micro Memory")) { | 897 | if (!request_mem_region(card->csr_base, card->csr_len, "Micro Memory")) { |
891 | printk(KERN_ERR "MM%d: Unable to request memory region\n", card->card_number); | 898 | dev_printk(KERN_ERR, &card->dev->dev, |
899 | "Unable to request memory region\n"); | ||
892 | ret = -ENOMEM; | 900 | ret = -ENOMEM; |
893 | 901 | ||
894 | goto failed_req_csr; | 902 | goto failed_req_csr; |
@@ -896,13 +904,15 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
896 | 904 | ||
897 | card->csr_remap = ioremap_nocache(card->csr_base, card->csr_len); | 905 | card->csr_remap = ioremap_nocache(card->csr_base, card->csr_len); |
898 | if (!card->csr_remap) { | 906 | if (!card->csr_remap) { |
899 | printk(KERN_ERR "MM%d: Unable to remap memory region\n", card->card_number); | 907 | dev_printk(KERN_ERR, &card->dev->dev, |
908 | "Unable to remap memory region\n"); | ||
900 | ret = -ENOMEM; | 909 | ret = -ENOMEM; |
901 | 910 | ||
902 | goto failed_remap_csr; | 911 | goto failed_remap_csr; |
903 | } | 912 | } |
904 | 913 | ||
905 | printk(KERN_INFO "MM%d: CSR 0x%08lx -> 0x%p (0x%lx)\n", card->card_number, | 914 | dev_printk(KERN_INFO, &card->dev->dev, |
915 | "CSR 0x%08lx -> 0x%p (0x%lx)\n", | ||
906 | card->csr_base, card->csr_remap, card->csr_len); | 916 | card->csr_base, card->csr_remap, card->csr_len); |
907 | 917 | ||
908 | switch(card->dev->device) { | 918 | switch(card->dev->device) { |
@@ -927,7 +937,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
927 | } | 937 | } |
928 | 938 | ||
929 | if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != magic_number) { | 939 | if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != magic_number) { |
930 | printk(KERN_ERR "MM%d: Magic number invalid\n", card->card_number); | 940 | dev_printk(KERN_ERR, &card->dev->dev, "Magic number invalid\n"); |
931 | ret = -ENOMEM; | 941 | ret = -ENOMEM; |
932 | goto failed_magic; | 942 | goto failed_magic; |
933 | } | 943 | } |
@@ -940,7 +950,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
940 | &card->mm_pages[1].page_dma); | 950 | &card->mm_pages[1].page_dma); |
941 | if (card->mm_pages[0].desc == NULL || | 951 | if (card->mm_pages[0].desc == NULL || |
942 | card->mm_pages[1].desc == NULL) { | 952 | card->mm_pages[1].desc == NULL) { |
943 | printk(KERN_ERR "MM%d: alloc failed\n", card->card_number); | 953 | dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n"); |
944 | goto failed_alloc; | 954 | goto failed_alloc; |
945 | } | 955 | } |
946 | reset_page(&card->mm_pages[0]); | 956 | reset_page(&card->mm_pages[0]); |
@@ -995,11 +1005,12 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
995 | card->battery[0].last_change = card->battery[1].last_change = jiffies; | 1005 | card->battery[0].last_change = card->battery[1].last_change = jiffies; |
996 | 1006 | ||
997 | if (card->flags & UM_FLAG_NO_BATT) | 1007 | if (card->flags & UM_FLAG_NO_BATT) |
998 | printk(KERN_INFO "MM%d: Size %d KB\n", | 1008 | dev_printk(KERN_INFO, &card->dev->dev, |
999 | card->card_number, card->mm_size); | 1009 | "Size %d KB\n", card->mm_size); |
1000 | else { | 1010 | else { |
1001 | printk(KERN_INFO "MM%d: Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n", | 1011 | dev_printk(KERN_INFO, &card->dev->dev, |
1002 | card->card_number, card->mm_size, | 1012 | "Size %d KB, Battery 1 %s (%s), Battery 2 %s (%s)\n", |
1013 | card->mm_size, | ||
1003 | (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"), | 1014 | (batt_status & BATTERY_1_DISABLED ? "Disabled" : "Enabled"), |
1004 | card->battery[0].good ? "OK" : "FAILURE", | 1015 | card->battery[0].good ? "OK" : "FAILURE", |
1005 | (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"), | 1016 | (batt_status & BATTERY_2_DISABLED ? "Disabled" : "Enabled"), |
@@ -1021,14 +1032,16 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
1021 | 1032 | ||
1022 | 1033 | ||
1023 | if (request_irq(dev->irq, mm_interrupt, IRQF_SHARED, "pci-umem", card)) { | 1034 | if (request_irq(dev->irq, mm_interrupt, IRQF_SHARED, "pci-umem", card)) { |
1024 | printk(KERN_ERR "MM%d: Unable to allocate IRQ\n", card->card_number); | 1035 | dev_printk(KERN_ERR, &card->dev->dev, |
1036 | "Unable to allocate IRQ\n"); | ||
1025 | ret = -ENODEV; | 1037 | ret = -ENODEV; |
1026 | 1038 | ||
1027 | goto failed_req_irq; | 1039 | goto failed_req_irq; |
1028 | } | 1040 | } |
1029 | 1041 | ||
1030 | card->irq = dev->irq; | 1042 | card->irq = dev->irq; |
1031 | printk(KERN_INFO "MM%d: Window size %d bytes, IRQ %d\n", card->card_number, | 1043 | dev_printk(KERN_INFO, &card->dev->dev, |
1044 | "Window size %d bytes, IRQ %d\n", | ||
1032 | card->win_size, card->irq); | 1045 | card->win_size, card->irq); |
1033 | 1046 | ||
1034 | spin_lock_init(&card->lock); | 1047 | spin_lock_init(&card->lock); |
@@ -1049,10 +1062,12 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i | |||
1049 | num_cards++; | 1062 | num_cards++; |
1050 | 1063 | ||
1051 | if (!get_userbit(card, MEMORY_INITIALIZED)) { | 1064 | if (!get_userbit(card, MEMORY_INITIALIZED)) { |
1052 | printk(KERN_INFO "MM%d: memory NOT initialized. Consider over-writing whole device.\n", card->card_number); | 1065 | dev_printk(KERN_INFO, &card->dev->dev, |
1066 | "memory NOT initialized. Consider over-writing whole device.\n"); | ||
1053 | card->init_size = 0; | 1067 | card->init_size = 0; |
1054 | } else { | 1068 | } else { |
1055 | printk(KERN_INFO "MM%d: memory already initialized\n", card->card_number); | 1069 | dev_printk(KERN_INFO, &card->dev->dev, |
1070 | "memory already initialized\n"); | ||
1056 | card->init_size = card->mm_size; | 1071 | card->init_size = card->mm_size; |
1057 | } | 1072 | } |
1058 | 1073 | ||
@@ -1137,8 +1152,6 @@ static int __init mm_init(void) | |||
1137 | int retval, i; | 1152 | int retval, i; |
1138 | int err; | 1153 | int err; |
1139 | 1154 | ||
1140 | printk(KERN_INFO DRIVER_VERSION " : " DRIVER_DESC "\n"); | ||
1141 | |||
1142 | retval = pci_register_driver(&mm_pci_driver); | 1155 | retval = pci_register_driver(&mm_pci_driver); |
1143 | if (retval) | 1156 | if (retval) |
1144 | return -ENOMEM; | 1157 | return -ENOMEM; |
@@ -1169,7 +1182,7 @@ static int __init mm_init(void) | |||
1169 | } | 1182 | } |
1170 | 1183 | ||
1171 | init_battery_timer(); | 1184 | init_battery_timer(); |
1172 | printk("MM: desc_per_page = %ld\n", DESC_PER_PAGE); | 1185 | printk(KERN_INFO "MM: desc_per_page = %ld\n", DESC_PER_PAGE); |
1173 | /* printk("mm_init: Done. 10-19-01 9:00\n"); */ | 1186 | /* printk("mm_init: Done. 10-19-01 9:00\n"); */ |
1174 | return 0; | 1187 | return 0; |
1175 | 1188 | ||