diff options
author | mark gross <mgross@linux.intel.com> | 2008-02-08 07:18:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 12:22:24 -0500 |
commit | d94afc6ccf6690b30ae112ec8101b3f10d50114e (patch) | |
tree | f54fb1fe147861db876b99809ff1cd1a316c45c0 | |
parent | f8bab73515ca5b392680bb033dceeb37b8463e95 (diff) |
intel-iommu: fault_reason index cleanup
Fix an off by one bug in the fault reason string reporting function, and
clean up some of the code around this buglet.
[akpm@linux-foundation.org: cleanup]
Signed-off-by: mark gross <mgross@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/pci/intel-iommu.c | 11 | ||||
-rw-r--r-- | include/linux/dmar.h | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index 585e188c1746..a4c3089f892a 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -745,7 +745,7 @@ static int iommu_disable_translation(struct intel_iommu *iommu) | |||
745 | 745 | ||
746 | /* iommu interrupt handling. Most stuff are MSI-like. */ | 746 | /* iommu interrupt handling. Most stuff are MSI-like. */ |
747 | 747 | ||
748 | static char *fault_reason_strings[] = | 748 | static const char *fault_reason_strings[] = |
749 | { | 749 | { |
750 | "Software", | 750 | "Software", |
751 | "Present bit in root entry is clear", | 751 | "Present bit in root entry is clear", |
@@ -760,14 +760,13 @@ static char *fault_reason_strings[] = | |||
760 | "non-zero reserved fields in RTP", | 760 | "non-zero reserved fields in RTP", |
761 | "non-zero reserved fields in CTP", | 761 | "non-zero reserved fields in CTP", |
762 | "non-zero reserved fields in PTE", | 762 | "non-zero reserved fields in PTE", |
763 | "Unknown" | ||
764 | }; | 763 | }; |
765 | #define MAX_FAULT_REASON_IDX (ARRAY_SIZE(fault_reason_strings) - 1) | 764 | #define MAX_FAULT_REASON_IDX (ARRAY_SIZE(fault_reason_strings) - 1) |
766 | 765 | ||
767 | char *dmar_get_fault_reason(u8 fault_reason) | 766 | const char *dmar_get_fault_reason(u8 fault_reason) |
768 | { | 767 | { |
769 | if (fault_reason >= MAX_FAULT_REASON_IDX) | 768 | if (fault_reason > MAX_FAULT_REASON_IDX) |
770 | return fault_reason_strings[MAX_FAULT_REASON_IDX - 1]; | 769 | return "Unknown"; |
771 | else | 770 | else |
772 | return fault_reason_strings[fault_reason]; | 771 | return fault_reason_strings[fault_reason]; |
773 | } | 772 | } |
@@ -825,7 +824,7 @@ void dmar_msi_read(int irq, struct msi_msg *msg) | |||
825 | static int iommu_page_fault_do_one(struct intel_iommu *iommu, int type, | 824 | static int iommu_page_fault_do_one(struct intel_iommu *iommu, int type, |
826 | u8 fault_reason, u16 source_id, u64 addr) | 825 | u8 fault_reason, u16 source_id, u64 addr) |
827 | { | 826 | { |
828 | char *reason; | 827 | const char *reason; |
829 | 828 | ||
830 | reason = dmar_get_fault_reason(fault_reason); | 829 | reason = dmar_get_fault_reason(fault_reason); |
831 | 830 | ||
diff --git a/include/linux/dmar.h b/include/linux/dmar.h index ffb6439cb5e6..56c73b847551 100644 --- a/include/linux/dmar.h +++ b/include/linux/dmar.h | |||
@@ -28,7 +28,7 @@ | |||
28 | #ifdef CONFIG_DMAR | 28 | #ifdef CONFIG_DMAR |
29 | struct intel_iommu; | 29 | struct intel_iommu; |
30 | 30 | ||
31 | extern char *dmar_get_fault_reason(u8 fault_reason); | 31 | extern const char *dmar_get_fault_reason(u8 fault_reason); |
32 | 32 | ||
33 | /* Can't use the common MSI interrupt functions | 33 | /* Can't use the common MSI interrupt functions |
34 | * since DMAR is not a pci device | 34 | * since DMAR is not a pci device |