Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i3c: master: dw: reattach device on first available location of address table

For today the reattach function only update the device address on the
controller.

Update the location to the first available too, will optimize the
enumeration process avoiding additional checks to keep the available
positions on address table consecutive.

Signed-off-by: Vitor Soares <vitor.soares@synopsys.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>

authored by

Vitor Soares and committed by
Boris Brezillon
3952cf8f 3c67166d

+16
+16
drivers/i3c/master/dw-i3c-master.c
··· 899 899 struct dw_i3c_i2c_dev_data *data = i3c_dev_get_master_data(dev); 900 900 struct i3c_master_controller *m = i3c_dev_get_master(dev); 901 901 struct dw_i3c_master *master = to_dw_i3c_master(m); 902 + int pos; 903 + 904 + pos = dw_i3c_master_get_free_pos(master); 905 + 906 + if (data->index > pos && pos > 0) { 907 + writel(0, 908 + master->regs + 909 + DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index)); 910 + 911 + master->addrs[data->index] = 0; 912 + master->free_pos |= BIT(data->index); 913 + 914 + data->index = pos; 915 + master->addrs[pos] = dev->info.dyn_addr; 916 + master->free_pos &= ~BIT(pos); 917 + } 902 918 903 919 writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(dev->info.dyn_addr), 904 920 master->regs +