i2c: designware: Define software status flags with BIT()
authorJarkko Nikula <jarkko.nikula@linux.intel.com>
Mon, 7 Nov 2022 13:42:39 +0000 (15:42 +0200)
committerWolfram Sang <wsa@kernel.org>
Sat, 12 Nov 2022 06:37:30 +0000 (07:37 +0100)
Define software status flags with a BIT() macro. While at it remove
STATUS_IDLE and replace its use with zero initialization and status
flags clearing with a mask.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/busses/i2c-designware-core.h
drivers/i2c/busses/i2c-designware-master.c
drivers/i2c/busses/i2c-designware-slave.c

index 6d1df28..457e696 100644 (file)
 #define DW_IC_COMP_PARAM_1_SPEED_MODE_MASK     GENMASK(3, 2)
 
 /*
- * status codes
+ * Sofware status flags
  */
-#define STATUS_IDLE                    0x0
-#define STATUS_ACTIVE                  0x1
-#define STATUS_WRITE_IN_PROGRESS       0x2
-#define STATUS_READ_IN_PROGRESS                0x4
+#define STATUS_ACTIVE                  BIT(0)
+#define STATUS_WRITE_IN_PROGRESS       BIT(1)
+#define STATUS_READ_IN_PROGRESS                BIT(2)
+#define STATUS_MASK                    GENMASK(2, 0)
 
 /*
  * operation modes
index dc3c5a1..1b7db2b 100644 (file)
@@ -574,7 +574,7 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
        dev->msg_write_idx = 0;
        dev->msg_read_idx = 0;
        dev->msg_err = 0;
-       dev->status = STATUS_IDLE;
+       dev->status = 0;
        dev->abort_source = 0;
        dev->rx_outstanding = 0;
 
@@ -731,7 +731,7 @@ static int i2c_dw_irq_handler_master(struct dw_i2c_dev *dev)
 
        if (stat & DW_IC_INTR_TX_ABRT) {
                dev->cmd_err |= DW_IC_ERR_TX_ABRT;
-               dev->status = STATUS_IDLE;
+               dev->status &= ~STATUS_MASK;
                dev->rx_outstanding = 0;
 
                /*
index 295774a..84eb0be 100644 (file)
@@ -82,7 +82,7 @@ static int i2c_dw_reg_slave(struct i2c_client *slave)
        dev->msg_write_idx = 0;
        dev->msg_read_idx = 0;
        dev->msg_err = 0;
-       dev->status = STATUS_IDLE;
+       dev->status = 0;
        dev->abort_source = 0;
        dev->rx_outstanding = 0;