Skip to content

Commit ad9d9a1

Browse files
cris-masudeep-holla
authored andcommitted
firmware: arm_ffa: Simplify ffa_partitions_cleanup()
On cleanup iterate the XArrays with xa_for_each() and remove the existent entries with xa_erase(), finally destroy the XArray itself. Remove partition_count field from drv_info since no more used anywhwere. Signed-off-by: Cristian Marussi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sudeep Holla <[email protected]>
1 parent c00d973 commit ad9d9a1

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

drivers/firmware/arm_ffa/driver.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ struct ffa_drv_info {
107107
struct work_struct notif_pcpu_work;
108108
struct work_struct irq_work;
109109
struct xarray partition_info;
110-
unsigned int partition_count;
111110
DECLARE_HASHTABLE(notifier_hash, ilog2(FFA_MAX_NOTIFICATIONS));
112111
struct mutex notify_lock; /* lock to protect notifier hashtable */
113112
};
@@ -1239,7 +1238,6 @@ static void ffa_setup_partitions(void)
12391238
rwlock_init(&info->rw_lock);
12401239
xa_store(&drv_info->partition_info, tpbuf->id, info, GFP_KERNEL);
12411240
}
1242-
drv_info->partition_count = count;
12431241

12441242
kfree(pbuf);
12451243

@@ -1249,29 +1247,18 @@ static void ffa_setup_partitions(void)
12491247
return;
12501248
rwlock_init(&info->rw_lock);
12511249
xa_store(&drv_info->partition_info, drv_info->vm_id, info, GFP_KERNEL);
1252-
drv_info->partition_count++;
12531250
}
12541251

12551252
static void ffa_partitions_cleanup(void)
12561253
{
1257-
struct ffa_dev_part_info **info;
1258-
int idx, count = drv_info->partition_count;
1259-
1260-
if (!count)
1261-
return;
1262-
1263-
info = kcalloc(count, sizeof(*info), GFP_KERNEL);
1264-
if (!info)
1265-
return;
1266-
1267-
xa_extract(&drv_info->partition_info, (void **)info, 0, VM_ID_MASK,
1268-
count, XA_PRESENT);
1254+
struct ffa_dev_part_info *info;
1255+
unsigned long idx;
12691256

1270-
for (idx = 0; idx < count; idx++)
1271-
kfree(info[idx]);
1272-
kfree(info);
1257+
xa_for_each(&drv_info->partition_info, idx, info) {
1258+
xa_erase(&drv_info->partition_info, idx);
1259+
kfree(info);
1260+
}
12731261

1274-
drv_info->partition_count = 0;
12751262
xa_destroy(&drv_info->partition_info);
12761263
}
12771264

@@ -1547,7 +1534,6 @@ static void __exit ffa_exit(void)
15471534
ffa_rxtx_unmap(drv_info->vm_id);
15481535
free_pages_exact(drv_info->tx_buffer, RXTX_BUFFER_SIZE);
15491536
free_pages_exact(drv_info->rx_buffer, RXTX_BUFFER_SIZE);
1550-
xa_destroy(&drv_info->partition_info);
15511537
kfree(drv_info);
15521538
arm_ffa_bus_exit();
15531539
}

0 commit comments

Comments
 (0)