Skip to content

Commit

Permalink
i3c: dw: use parity8 helper instead of open coding it
Browse files Browse the repository at this point in the history
The kernel has now a generic helper for getting parity with easier to
understand semantics. Make use of it.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20250107090204.6593-4-wsa+renesas@sang-engineering.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
  • Loading branch information
Wolfram Sang authored and Alexandre Belloni committed Jan 12, 2025
1 parent 32a8d36 commit e89cc14
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions drivers/i3c/master/dw-i3c-master.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,6 @@ struct dw_i3c_i2c_dev_data {
struct i3c_generic_ibi_pool *ibi_pool;
};

static u8 even_parity(u8 p)
{
p ^= p >> 4;
p &= 0xf;

return (0x9669 >> p) & 1;
}

static bool dw_i3c_master_supports_ccc_cmd(struct i3c_master_controller *m,
const struct i3c_ccc_cmd *cmd)
{
Expand Down Expand Up @@ -848,7 +840,7 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
struct dw_i3c_xfer *xfer;
struct dw_i3c_cmd *cmd;
u32 olddevs, newdevs;
u8 p, last_addr = 0;
u8 last_addr = 0;
int ret, pos;

ret = pm_runtime_resume_and_get(master->dev);
Expand All @@ -873,9 +865,9 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
}

master->devs[pos].addr = ret;
p = even_parity(ret);
last_addr = ret;
ret |= (p << 7);

ret |= parity8(ret) ? 0 : BIT(7);

writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(ret),
master->regs +
Expand Down

0 comments on commit e89cc14

Please sign in to comment.