mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-11 00:08:50 +00:00
firewire: cdev: simplify a schedule_delayed_work wrapper
The kernel API documentation says that queue_delayed_work() returns 0 (only) if the work was already queued. The return codes of schedule_delayed_work() are not documented but the same. In init_iso_resource(), the work has never been queued yet, hence we can assume schedule_delayed_work() to be a guaranteed success there. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
This commit is contained in:
parent
5d9cb7d276
commit
81610b8fbf
@ -129,7 +129,7 @@ struct iso_resource {
|
|||||||
struct iso_resource_event *e_alloc, *e_dealloc;
|
struct iso_resource_event *e_alloc, *e_dealloc;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int schedule_iso_resource(struct iso_resource *);
|
static void schedule_iso_resource(struct iso_resource *);
|
||||||
static void release_iso_resource(struct client *, struct client_resource *);
|
static void release_iso_resource(struct client *, struct client_resource *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1111,17 +1111,11 @@ static void iso_resource_work(struct work_struct *work)
|
|||||||
client_put(client);
|
client_put(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int schedule_iso_resource(struct iso_resource *r)
|
static void schedule_iso_resource(struct iso_resource *r)
|
||||||
{
|
{
|
||||||
int scheduled;
|
|
||||||
|
|
||||||
client_get(r->client);
|
client_get(r->client);
|
||||||
|
if (!schedule_delayed_work(&r->work, 0))
|
||||||
scheduled = schedule_delayed_work(&r->work, 0);
|
|
||||||
if (!scheduled)
|
|
||||||
client_put(r->client);
|
client_put(r->client);
|
||||||
|
|
||||||
return scheduled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void release_iso_resource(struct client *client,
|
static void release_iso_resource(struct client *client,
|
||||||
@ -1173,13 +1167,13 @@ static int init_iso_resource(struct client *client,
|
|||||||
if (todo == ISO_RES_ALLOC) {
|
if (todo == ISO_RES_ALLOC) {
|
||||||
r->resource.release = release_iso_resource;
|
r->resource.release = release_iso_resource;
|
||||||
ret = add_client_resource(client, &r->resource, GFP_KERNEL);
|
ret = add_client_resource(client, &r->resource, GFP_KERNEL);
|
||||||
|
if (ret < 0)
|
||||||
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
r->resource.release = NULL;
|
r->resource.release = NULL;
|
||||||
r->resource.handle = -1;
|
r->resource.handle = -1;
|
||||||
ret = schedule_iso_resource(r) ? 0 : -ENOMEM;
|
schedule_iso_resource(r);
|
||||||
}
|
}
|
||||||
if (ret < 0)
|
|
||||||
goto fail;
|
|
||||||
request->handle = r->resource.handle;
|
request->handle = r->resource.handle;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user