[PATCH 05/17] i3c: mipi-i3c-hci: Switch DAT bitmap allocation to devm_bitmap_zalloc()

Frank Li Frank.li at nxp.com
Fri Dec 19 08:27:00 PST 2025


On Fri, Dec 19, 2025 at 04:45:22PM +0200, Adrian Hunter wrote:
> 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: Adrian Hunter <adrian.hunter at intel.com>
> ---

Reviewed-by: Frank Li <Frank.Li at nxp.com>

>  drivers/i3c/master/mipi-i3c-hci/core.c   |  2 --
>  drivers/i3c/master/mipi-i3c-hci/dat.h    |  1 -
>  drivers/i3c/master/mipi-i3c-hci/dat_v1.c | 11 +++--------
>  3 files changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
> index 0d3ec674878d..c4b249fde764 100644
> --- a/drivers/i3c/master/mipi-i3c-hci/core.c
> +++ b/drivers/i3c/master/mipi-i3c-hci/core.c
> @@ -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)
> diff --git a/drivers/i3c/master/mipi-i3c-hci/dat.h b/drivers/i3c/master/mipi-i3c-hci/dat.h
> index 1f0f345c3daf..5277c65fc601 100644
> --- a/drivers/i3c/master/mipi-i3c-hci/dat.h
> +++ b/drivers/i3c/master/mipi-i3c-hci/dat.h
> @@ -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);
> diff --git a/drivers/i3c/master/mipi-i3c-hci/dat_v1.c b/drivers/i3c/master/mipi-i3c-hci/dat_v1.c
> index cc5d2deb23ab..c60ef5d77ca3 100644
> --- a/drivers/i3c/master/mipi-i3c-hci/dat_v1.c
> +++ b/drivers/i3c/master/mipi-i3c-hci/dat_v1.c
> @@ -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,
> --
> 2.51.0
>
>
> --
> linux-i3c mailing list
> linux-i3c at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-i3c



More information about the linux-i3c mailing list