Skip to content

Commit 16aed0a

Browse files
nxpfranklialexandrebelloni
authored andcommitted
i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS
Replace the hardcoded value 2, which indicates 2 bits for I3C address status, with the predefined macro I3C_ADDR_SLOT_STATUS_BITS. Improve maintainability and extensibility of the code. Reviewed-by: Miquel Raynal <[email protected]> Signed-off-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 9852d85 commit 16aed0a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

drivers/i3c/master.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static enum i3c_addr_slot_status
348348
i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr)
349349
{
350350
unsigned long status;
351-
int bitpos = addr * 2;
351+
int bitpos = addr * I3C_ADDR_SLOT_STATUS_BITS;
352352

353353
if (addr > I2C_MAX_ADDR)
354354
return I3C_ADDR_SLOT_RSVD;
@@ -362,7 +362,7 @@ i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr)
362362
static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr,
363363
enum i3c_addr_slot_status status)
364364
{
365-
int bitpos = addr * 2;
365+
int bitpos = addr * I3C_ADDR_SLOT_STATUS_BITS;
366366
unsigned long *ptr;
367367

368368
if (addr > I2C_MAX_ADDR)

include/linux/i3c/master.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ enum i3c_addr_slot_status {
313313
I3C_ADDR_SLOT_STATUS_MASK = 3,
314314
};
315315

316+
#define I3C_ADDR_SLOT_STATUS_BITS 2
317+
316318
/**
317319
* struct i3c_bus - I3C bus object
318320
* @cur_master: I3C master currently driving the bus. Since I3C is multi-master
@@ -354,7 +356,7 @@ enum i3c_addr_slot_status {
354356
struct i3c_bus {
355357
struct i3c_dev_desc *cur_master;
356358
int id;
357-
unsigned long addrslots[((I2C_MAX_ADDR + 1) * 2) / BITS_PER_LONG];
359+
unsigned long addrslots[((I2C_MAX_ADDR + 1) * I3C_ADDR_SLOT_STATUS_BITS) / BITS_PER_LONG];
358360
enum i3c_bus_mode mode;
359361
struct {
360362
unsigned long i3c;

0 commit comments

Comments
 (0)