u32 data[];
};
+struct iso_resource_params {
+ int generation;
+ u64 channels;
+ s32 bandwidth;
+};
+
struct iso_resource {
struct client_resource resource;
struct client *client;
struct delayed_work work;
enum {ISO_RES_ALLOC, ISO_RES_REALLOC, ISO_RES_DEALLOC,
ISO_RES_ALLOC_ONCE, ISO_RES_DEALLOC_ONCE,} todo;
- int generation;
- u64 channels;
- s32 bandwidth;
+ struct iso_resource_params params;
struct iso_resource_event *e_alloc, *e_dealloc;
};
return 0;
}
+static int fill_iso_resource_params(struct iso_resource_params *params,
+ struct fw_cdev_allocate_iso_resource *request)
+{
+ if ((request->channels == 0 && request->bandwidth == 0) ||
+ request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
+ return -EINVAL;
+
+ params->generation = -1;
+ params->channels = request->channels;
+ params->bandwidth = request->bandwidth;
+
+ return 0;
+}
+
static void iso_resource_work(struct work_struct *work)
{
struct iso_resource_event *e;
} else {
// We could be called twice within the same generation.
skip = todo == ISO_RES_REALLOC &&
- r->generation == generation;
+ r->params.generation == generation;
}
free = todo == ISO_RES_DEALLOC ||
todo == ISO_RES_ALLOC_ONCE ||
todo == ISO_RES_DEALLOC_ONCE;
- r->generation = generation;
+ r->params.generation = generation;
}
if (skip)
goto out;
- bandwidth = r->bandwidth;
+ bandwidth = r->params.bandwidth;
fw_iso_resource_manage(client->device->card, generation,
- r->channels, &channel, &bandwidth,
+ r->params.channels, &channel, &bandwidth,
todo == ISO_RES_ALLOC ||
todo == ISO_RES_REALLOC ||
todo == ISO_RES_ALLOC_ONCE);
}
if (todo == ISO_RES_ALLOC && channel >= 0)
- r->channels = 1ULL << channel;
+ r->params.channels = 1ULL << channel;
if (todo == ISO_RES_REALLOC && success)
goto out;
struct iso_resource *r;
int ret;
- if ((request->channels == 0 && request->bandwidth == 0) ||
- request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
- return -EINVAL;
-
r = kmalloc_obj(*r);
e1 = kmalloc_obj(*e1);
e2 = kmalloc_obj(*e2);
goto fail;
}
+ ret = fill_iso_resource_params(&r->params, request);
+ if (ret < 0)
+ goto fail;
+
INIT_DELAYED_WORK(&r->work, iso_resource_work);
r->client = client;
r->todo = todo;
- r->generation = -1;
- r->channels = request->channels;
- r->bandwidth = request->bandwidth;
r->e_alloc = e1;
r->e_dealloc = e2;