aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a86735d80ee0..c6c8bbea1748 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2815,11 +2815,9 @@ static void kvm_io_bus_destroy(struct kvm_io_bus *bus)
2815 kfree(bus); 2815 kfree(bus);
2816} 2816}
2817 2817
2818static int kvm_io_bus_sort_cmp(const void *p1, const void *p2) 2818static inline int __kvm_io_bus_sort_cmp(const struct kvm_io_range *r1,
2819 const struct kvm_io_range *r2)
2819{ 2820{
2820 const struct kvm_io_range *r1 = p1;
2821 const struct kvm_io_range *r2 = p2;
2822
2823 if (r1->addr < r2->addr) 2821 if (r1->addr < r2->addr)
2824 return -1; 2822 return -1;
2825 if (r1->addr + r1->len > r2->addr + r2->len) 2823 if (r1->addr + r1->len > r2->addr + r2->len)
@@ -2827,6 +2825,11 @@ static int kvm_io_bus_sort_cmp(const void *p1, const void *p2)
2827 return 0; 2825 return 0;
2828} 2826}
2829 2827
2828static int kvm_io_bus_sort_cmp(const void *p1, const void *p2)
2829{
2830 return __kvm_io_bus_sort_cmp(p1, p2);
2831}
2832
2830static int kvm_io_bus_insert_dev(struct kvm_io_bus *bus, struct kvm_io_device *dev, 2833static int kvm_io_bus_insert_dev(struct kvm_io_bus *bus, struct kvm_io_device *dev,
2831 gpa_t addr, int len) 2834 gpa_t addr, int len)
2832{ 2835{
@@ -2860,7 +2863,7 @@ static int kvm_io_bus_get_first_dev(struct kvm_io_bus *bus,
2860 2863
2861 off = range - bus->range; 2864 off = range - bus->range;
2862 2865
2863 while (off > 0 && kvm_io_bus_sort_cmp(&key, &bus->range[off-1]) == 0) 2866 while (off > 0 && __kvm_io_bus_sort_cmp(&key, &bus->range[off-1]) == 0)
2864 off--; 2867 off--;
2865 2868
2866 return off; 2869 return off;
@@ -2876,7 +2879,7 @@ static int __kvm_io_bus_write(struct kvm_io_bus *bus,
2876 return -EOPNOTSUPP; 2879 return -EOPNOTSUPP;
2877 2880
2878 while (idx < bus->dev_count && 2881 while (idx < bus->dev_count &&
2879 kvm_io_bus_sort_cmp(range, &bus->range[idx]) == 0) { 2882 __kvm_io_bus_sort_cmp(range, &bus->range[idx]) == 0) {
2880 if (!kvm_iodevice_write(bus->range[idx].dev, range->addr, 2883 if (!kvm_iodevice_write(bus->range[idx].dev, range->addr,
2881 range->len, val)) 2884 range->len, val))
2882 return idx; 2885 return idx;
@@ -2920,7 +2923,7 @@ int kvm_io_bus_write_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
2920 2923
2921 /* First try the device referenced by cookie. */ 2924 /* First try the device referenced by cookie. */
2922 if ((cookie >= 0) && (cookie < bus->dev_count) && 2925 if ((cookie >= 0) && (cookie < bus->dev_count) &&
2923 (kvm_io_bus_sort_cmp(&range, &bus->range[cookie]) == 0)) 2926 (__kvm_io_bus_sort_cmp(&range, &bus->range[cookie]) == 0))
2924 if (!kvm_iodevice_write(bus->range[cookie].dev, addr, len, 2927 if (!kvm_iodevice_write(bus->range[cookie].dev, addr, len,
2925 val)) 2928 val))
2926 return cookie; 2929 return cookie;
@@ -2942,7 +2945,7 @@ static int __kvm_io_bus_read(struct kvm_io_bus *bus, struct kvm_io_range *range,
2942 return -EOPNOTSUPP; 2945 return -EOPNOTSUPP;
2943 2946
2944 while (idx < bus->dev_count && 2947 while (idx < bus->dev_count &&
2945 kvm_io_bus_sort_cmp(range, &bus->range[idx]) == 0) { 2948 __kvm_io_bus_sort_cmp(range, &bus->range[idx]) == 0) {
2946 if (!kvm_iodevice_read(bus->range[idx].dev, range->addr, 2949 if (!kvm_iodevice_read(bus->range[idx].dev, range->addr,
2947 range->len, val)) 2950 range->len, val))
2948 return idx; 2951 return idx;
@@ -2986,7 +2989,7 @@ int kvm_io_bus_read_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
2986 2989
2987 /* First try the device referenced by cookie. */ 2990 /* First try the device referenced by cookie. */
2988 if ((cookie >= 0) && (cookie < bus->dev_count) && 2991 if ((cookie >= 0) && (cookie < bus->dev_count) &&
2989 (kvm_io_bus_sort_cmp(&range, &bus->range[cookie]) == 0)) 2992 (__kvm_io_bus_sort_cmp(&range, &bus->range[cookie]) == 0))
2990 if (!kvm_iodevice_read(bus->range[cookie].dev, addr, len, 2993 if (!kvm_iodevice_read(bus->range[cookie].dev, addr, len,
2991 val)) 2994 val))
2992 return cookie; 2995 return cookie;