Commit e55905a3 authored by Wolfram Sang's avatar Wolfram Sang Committed by Alexandre Belloni
Browse files

i3c: mipi-i3c-hci: use parity8 helper instead of open coding it



The kernel has now a generic helper for getting parity with easier to
understand semantics. Make use of it. Here, it also fixes a bug because
the correct algorithm is using XOR ('^=') instead of ADD ('+=').

Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: default avatarJarkko Nikula <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20250107090204.6593-5-wsa+renesas@sang-engineering.com


Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent e89cc14e
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -40,15 +40,6 @@
#define dat_w0_write(i, v)	writel(v, hci->DAT_regs + (i) * 8)
#define dat_w1_write(i, v)	writel(v, hci->DAT_regs + (i) * 8 + 4)

static inline bool dynaddr_parity(unsigned int addr)
{
	addr |= 1 << 7;
	addr += addr >> 4;
	addr += addr >> 2;
	addr += addr >> 1;
	return (addr & 1);
}

static int hci_dat_v1_init(struct i3c_hci *hci)
{
	unsigned int dat_idx;
@@ -123,7 +114,7 @@ static void hci_dat_v1_set_dynamic_addr(struct i3c_hci *hci,
	dat_w0 = dat_w0_read(dat_idx);
	dat_w0 &= ~(DAT_0_DYNAMIC_ADDRESS | DAT_0_DYNADDR_PARITY);
	dat_w0 |= FIELD_PREP(DAT_0_DYNAMIC_ADDRESS, address) |
		  (dynaddr_parity(address) ? DAT_0_DYNADDR_PARITY : 0);
		  (parity8(address) ? 0 : DAT_0_DYNADDR_PARITY);
	dat_w0_write(dat_idx, dat_w0);
}