Skip to content

Commit e55905a

Browse files
Wolfram Sangalexandrebelloni
authored andcommitted
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: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Link: https://lore.kernel.org/r/20250107090204.6593-5-wsa+renesas@sang-engineering.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent e89cc14 commit e55905a

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

drivers/i3c/master/mipi-i3c-hci/dat_v1.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@
4040
#define dat_w0_write(i, v) writel(v, hci->DAT_regs + (i) * 8)
4141
#define dat_w1_write(i, v) writel(v, hci->DAT_regs + (i) * 8 + 4)
4242

43-
static inline bool dynaddr_parity(unsigned int addr)
44-
{
45-
addr |= 1 << 7;
46-
addr += addr >> 4;
47-
addr += addr >> 2;
48-
addr += addr >> 1;
49-
return (addr & 1);
50-
}
51-
5243
static int hci_dat_v1_init(struct i3c_hci *hci)
5344
{
5445
unsigned int dat_idx;
@@ -123,7 +114,7 @@ static void hci_dat_v1_set_dynamic_addr(struct i3c_hci *hci,
123114
dat_w0 = dat_w0_read(dat_idx);
124115
dat_w0 &= ~(DAT_0_DYNAMIC_ADDRESS | DAT_0_DYNADDR_PARITY);
125116
dat_w0 |= FIELD_PREP(DAT_0_DYNAMIC_ADDRESS, address) |
126-
(dynaddr_parity(address) ? DAT_0_DYNADDR_PARITY : 0);
117+
(parity8(address) ? 0 : DAT_0_DYNADDR_PARITY);
127118
dat_w0_write(dat_idx, dat_w0);
128119
}
129120

0 commit comments

Comments
 (0)