aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/core-iso.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firewire/core-iso.c')
-rw-r--r--drivers/firewire/core-iso.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
index 1c0b504a42f3..8f5aebfb29df 100644
--- a/drivers/firewire/core-iso.c
+++ b/drivers/firewire/core-iso.c
@@ -26,6 +26,7 @@
26#include <linux/firewire-constants.h> 26#include <linux/firewire-constants.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/slab.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
30#include <linux/vmalloc.h> 31#include <linux/vmalloc.h>
31 32
@@ -189,7 +190,7 @@ static int manage_bandwidth(struct fw_card *card, int irm_id, int generation,
189 for (try = 0; try < 5; try++) { 190 for (try = 0; try < 5; try++) {
190 new = allocate ? old - bandwidth : old + bandwidth; 191 new = allocate ? old - bandwidth : old + bandwidth;
191 if (new < 0 || new > BANDWIDTH_AVAILABLE_INITIAL) 192 if (new < 0 || new > BANDWIDTH_AVAILABLE_INITIAL)
192 break; 193 return -EBUSY;
193 194
194 data[0] = cpu_to_be32(old); 195 data[0] = cpu_to_be32(old);
195 data[1] = cpu_to_be32(new); 196 data[1] = cpu_to_be32(new);
@@ -217,7 +218,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
217 u32 channels_mask, u64 offset, bool allocate, __be32 data[2]) 218 u32 channels_mask, u64 offset, bool allocate, __be32 data[2])
218{ 219{
219 __be32 c, all, old; 220 __be32 c, all, old;
220 int i, retry = 5; 221 int i, ret = -EIO, retry = 5;
221 222
222 old = all = allocate ? cpu_to_be32(~0) : 0; 223 old = all = allocate ? cpu_to_be32(~0) : 0;
223 224
@@ -225,6 +226,8 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
225 if (!(channels_mask & 1 << i)) 226 if (!(channels_mask & 1 << i))
226 continue; 227 continue;
227 228
229 ret = -EBUSY;
230
228 c = cpu_to_be32(1 << (31 - i)); 231 c = cpu_to_be32(1 << (31 - i));
229 if ((old & c) != (all & c)) 232 if ((old & c) != (all & c))
230 continue; 233 continue;
@@ -250,12 +253,16 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
250 253
251 /* 1394-1995 IRM, fall through to retry. */ 254 /* 1394-1995 IRM, fall through to retry. */
252 default: 255 default:
253 if (retry--) 256 if (retry) {
257 retry--;
254 i--; 258 i--;
259 } else {
260 ret = -EIO;
261 }
255 } 262 }
256 } 263 }
257 264
258 return -EIO; 265 return ret;
259} 266}
260 267
261static void deallocate_channel(struct fw_card *card, int irm_id, 268static void deallocate_channel(struct fw_card *card, int irm_id,
@@ -331,8 +338,9 @@ void fw_iso_resource_manage(struct fw_card *card, int generation,
331 if (ret < 0) 338 if (ret < 0)
332 *bandwidth = 0; 339 *bandwidth = 0;
333 340
334 if (allocate && ret < 0 && c >= 0) { 341 if (allocate && ret < 0) {
335 deallocate_channel(card, irm_id, generation, c, buffer); 342 if (c >= 0)
343 deallocate_channel(card, irm_id, generation, c, buffer);
336 *channel = ret; 344 *channel = ret;
337 } 345 }
338} 346}