Commit f64c1a46 authored by Adrian Hunter's avatar Adrian Hunter Committed by Alexandre Belloni
Browse files

i3c: mipi-i3c-hci: Switch DAT bitmap allocation to devm_bitmap_zalloc()



The driver already uses managed resources, so convert the Device Address
Table (DAT) bitmap allocation to use devm_bitmap_zalloc().  Remove the
manual cleanup routine.

Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Reviewed-by: default avatarFrank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260113072702.16268-6-adrian.hunter@intel.com


Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 47189579
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -185,8 +185,6 @@ static void i3c_hci_bus_cleanup(struct i3c_master_controller *m)

	i3c_hci_bus_disable(hci);
	hci->io->cleanup(hci);
	if (hci->cmd == &mipi_i3c_hci_cmd_v1)
		mipi_i3c_hci_dat_v1.cleanup(hci);
}

void mipi_i3c_hci_resume(struct i3c_hci *hci)
+0 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@

struct hci_dat_ops {
	int (*init)(struct i3c_hci *hci);
	void (*cleanup)(struct i3c_hci *hci);
	int (*alloc_entry)(struct i3c_hci *hci);
	void (*free_entry)(struct i3c_hci *hci, unsigned int dat_idx);
	void (*set_dynamic_addr)(struct i3c_hci *hci, unsigned int dat_idx, u8 addr);
+3 −8
Original line number Diff line number Diff line
@@ -55,8 +55,10 @@ static int hci_dat_v1_init(struct i3c_hci *hci)
	}

	if (!hci->DAT_data) {
		struct device *dev = hci->master.dev.parent;

		/* use a bitmap for faster free slot search */
		hci->DAT_data = bitmap_zalloc(hci->DAT_entries, GFP_KERNEL);
		hci->DAT_data = devm_bitmap_zalloc(dev, hci->DAT_entries, GFP_KERNEL);
		if (!hci->DAT_data)
			return -ENOMEM;

@@ -70,12 +72,6 @@ static int hci_dat_v1_init(struct i3c_hci *hci)
	return 0;
}

static void hci_dat_v1_cleanup(struct i3c_hci *hci)
{
	bitmap_free(hci->DAT_data);
	hci->DAT_data = NULL;
}

static int hci_dat_v1_alloc_entry(struct i3c_hci *hci)
{
	unsigned int dat_idx;
@@ -170,7 +166,6 @@ static int hci_dat_v1_get_index(struct i3c_hci *hci, u8 dev_addr)

const struct hci_dat_ops mipi_i3c_hci_dat_v1 = {
	.init			= hci_dat_v1_init,
	.cleanup		= hci_dat_v1_cleanup,
	.alloc_entry		= hci_dat_v1_alloc_entry,
	.free_entry		= hci_dat_v1_free_entry,
	.set_dynamic_addr	= hci_dat_v1_set_dynamic_addr,