Skip to content

Commit cd5f1a1

Browse files
committed
firewire: core: code cleanup to remove old implementations for once operation
The helper functions for iso_resource allocation and work item still include codes for once operation. This commit refactors them to remove the old implementations. Link: https://lore.kernel.org/r/20260429093449.160545-6-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent b3ac3b4 commit cd5f1a1

1 file changed

Lines changed: 15 additions & 22 deletions

File tree

drivers/firewire/core-cdev.c

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ struct iso_resource {
139139
struct client *client;
140140
/* Schedule work and access todo only with client->lock held. */
141141
struct delayed_work work;
142-
enum {ISO_RES_ALLOC, ISO_RES_REALLOC, ISO_RES_DEALLOC,
143-
ISO_RES_ALLOC_ONCE, ISO_RES_DEALLOC_ONCE,} todo;
142+
enum {
143+
ISO_RES_ALLOC,
144+
ISO_RES_REALLOC,
145+
ISO_RES_DEALLOC,
146+
} todo;
144147
struct iso_resource_params params;
145148
struct iso_resource_event *e_alloc, *e_dealloc;
146149
};
@@ -1342,9 +1345,7 @@ static void iso_resource_work(struct work_struct *work)
13421345
skip = todo == ISO_RES_REALLOC &&
13431346
r->params.generation == generation;
13441347
}
1345-
free = todo == ISO_RES_DEALLOC ||
1346-
todo == ISO_RES_ALLOC_ONCE ||
1347-
todo == ISO_RES_DEALLOC_ONCE;
1348+
free = todo == ISO_RES_DEALLOC;
13481349
r->params.generation = generation;
13491350
}
13501351

@@ -1356,8 +1357,7 @@ static void iso_resource_work(struct work_struct *work)
13561357
fw_iso_resource_manage(client->device->card, generation,
13571358
r->params.channels, &channel, &bandwidth,
13581359
todo == ISO_RES_ALLOC ||
1359-
todo == ISO_RES_REALLOC ||
1360-
todo == ISO_RES_ALLOC_ONCE);
1360+
todo == ISO_RES_REALLOC);
13611361
/*
13621362
* Is this generation outdated already? As long as this resource sticks
13631363
* in the xarray, it will be scheduled again for a newer generation or at
@@ -1390,7 +1390,7 @@ static void iso_resource_work(struct work_struct *work)
13901390
if (todo == ISO_RES_REALLOC && success)
13911391
goto out;
13921392

1393-
if (todo == ISO_RES_ALLOC || todo == ISO_RES_ALLOC_ONCE) {
1393+
if (todo == ISO_RES_ALLOC) {
13941394
e = r->e_alloc;
13951395
r->e_alloc = NULL;
13961396
} else {
@@ -1425,8 +1425,7 @@ static void release_iso_resource(struct client *client,
14251425
schedule_iso_resource(r, 0);
14261426
}
14271427

1428-
static int init_iso_resource(struct client *client,
1429-
struct fw_cdev_allocate_iso_resource *request, int todo)
1428+
static int init_iso_resource(struct client *client, struct fw_cdev_allocate_iso_resource *request)
14301429
{
14311430
struct iso_resource_event *e1, *e2;
14321431
struct iso_resource *r;
@@ -1446,7 +1445,7 @@ static int init_iso_resource(struct client *client,
14461445

14471446
INIT_DELAYED_WORK(&r->work, iso_resource_work);
14481447
r->client = client;
1449-
r->todo = todo;
1448+
r->todo = ISO_RES_ALLOC;
14501449
r->e_alloc = e1;
14511450
r->e_dealloc = e2;
14521451

@@ -1455,15 +1454,10 @@ static int init_iso_resource(struct client *client,
14551454
e2->iso_resource.closure = request->closure;
14561455
e2->iso_resource.type = FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED;
14571456

1458-
if (todo == ISO_RES_ALLOC) {
1459-
r->resource.release = release_iso_resource;
1460-
ret = add_client_resource(client, &r->resource, GFP_KERNEL);
1461-
if (ret < 0)
1462-
goto fail;
1463-
} else {
1464-
r->resource.release = NULL;
1465-
r->resource.handle = -1;
1466-
}
1457+
r->resource.release = release_iso_resource;
1458+
ret = add_client_resource(client, &r->resource, GFP_KERNEL);
1459+
if (ret < 0)
1460+
goto fail;
14671461
schedule_iso_resource(r, 0);
14681462

14691463
request->handle = r->resource.handle;
@@ -1480,8 +1474,7 @@ static int init_iso_resource(struct client *client,
14801474
static int ioctl_allocate_iso_resource(struct client *client,
14811475
union ioctl_arg *arg)
14821476
{
1483-
return init_iso_resource(client,
1484-
&arg->allocate_iso_resource, ISO_RES_ALLOC);
1477+
return init_iso_resource(client, &arg->allocate_iso_resource);
14851478
}
14861479

14871480
static int ioctl_deallocate_iso_resource(struct client *client,

0 commit comments

Comments
 (0)