diff options
Diffstat (limited to 'drivers/s390/cio/idset.c')
-rw-r--r-- | drivers/s390/cio/idset.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/s390/cio/idset.c b/drivers/s390/cio/idset.c index e6d5f8c49524..199bc6791177 100644 --- a/drivers/s390/cio/idset.c +++ b/drivers/s390/cio/idset.c | |||
@@ -1,9 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright IBM Corp. 2007 | 2 | * Copyright IBM Corp. 2007, 2012 |
3 | * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> | 3 | * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <linux/vmalloc.h> | 6 | #include <linux/vmalloc.h> |
7 | #include <linux/bitmap.h> | ||
7 | #include <linux/bitops.h> | 8 | #include <linux/bitops.h> |
8 | #include "idset.h" | 9 | #include "idset.h" |
9 | #include "css.h" | 10 | #include "css.h" |
@@ -89,6 +90,14 @@ void idset_sch_del(struct idset *set, struct subchannel_id schid) | |||
89 | idset_del(set, schid.ssid, schid.sch_no); | 90 | idset_del(set, schid.ssid, schid.sch_no); |
90 | } | 91 | } |
91 | 92 | ||
93 | /* Clear ids starting from @schid up to end of subchannel set. */ | ||
94 | void idset_sch_del_subseq(struct idset *set, struct subchannel_id schid) | ||
95 | { | ||
96 | int pos = schid.ssid * set->num_id + schid.sch_no; | ||
97 | |||
98 | bitmap_clear(set->bitmap, pos, set->num_id - schid.sch_no); | ||
99 | } | ||
100 | |||
92 | int idset_sch_contains(struct idset *set, struct subchannel_id schid) | 101 | int idset_sch_contains(struct idset *set, struct subchannel_id schid) |
93 | { | 102 | { |
94 | return idset_contains(set, schid.ssid, schid.sch_no); | 103 | return idset_contains(set, schid.ssid, schid.sch_no); |
@@ -111,20 +120,13 @@ int idset_sch_get_first(struct idset *set, struct subchannel_id *schid) | |||
111 | 120 | ||
112 | int idset_is_empty(struct idset *set) | 121 | int idset_is_empty(struct idset *set) |
113 | { | 122 | { |
114 | int bitnum; | 123 | return bitmap_empty(set->bitmap, set->num_ssid * set->num_id); |
115 | |||
116 | bitnum = find_first_bit(set->bitmap, set->num_ssid * set->num_id); | ||
117 | if (bitnum >= set->num_ssid * set->num_id) | ||
118 | return 1; | ||
119 | return 0; | ||
120 | } | 124 | } |
121 | 125 | ||
122 | void idset_add_set(struct idset *to, struct idset *from) | 126 | void idset_add_set(struct idset *to, struct idset *from) |
123 | { | 127 | { |
124 | unsigned long i, len; | 128 | int len = min(__BITOPS_WORDS(to->num_ssid * to->num_id), |
129 | __BITOPS_WORDS(from->num_ssid * from->num_id)); | ||
125 | 130 | ||
126 | len = min(__BITOPS_WORDS(to->num_ssid * to->num_id), | 131 | bitmap_or(to->bitmap, to->bitmap, from->bitmap, len); |
127 | __BITOPS_WORDS(from->num_ssid * from->num_id)); | ||
128 | for (i = 0; i < len ; i++) | ||
129 | to->bitmap[i] |= from->bitmap[i]; | ||
130 | } | 132 | } |