generic: mt7530: fix roaming from DSA user ports
[oweals/openwrt.git] / target / linux / generic / backport-5.4 / 808-v5.8-i2c-pxa-add-and-use-definitions-for-IBMR-register.patch
1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Bcc: linux@mail.armlinux.org.uk
3 Cc: linux-i2c@vger.kernel.org
4 Subject: [PATCH 06/17] i2c: pxa: add and use definitions for IBMR register
5 MIME-Version: 1.0
6 Content-Disposition: inline
7 Content-Transfer-Encoding: 8bit
8 Content-Type: text/plain; charset="utf-8"
9
10 Add definitions for the bits in the IBMR register, and use them in the
11 code. This improves readability.
12
13 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
14 ---
15  drivers/i2c/busses/i2c-pxa.c | 12 ++++++++----
16  1 file changed, 8 insertions(+), 4 deletions(-)
17
18 --- a/drivers/i2c/busses/i2c-pxa.c
19 +++ b/drivers/i2c/busses/i2c-pxa.c
20 @@ -34,6 +34,9 @@
21  #include <linux/slab.h>
22  
23  /* I2C register field definitions */
24 +#define IBMR_SDAS      (1 << 0)
25 +#define IBMR_SCLS      (1 << 1)
26 +
27  #define ICR_START      (1 << 0)           /* start bit */
28  #define ICR_STOP       (1 << 1)           /* stop bit */
29  #define ICR_ACKNAK     (1 << 2)           /* send ACK(0) or NAK(1) */
30 @@ -335,7 +338,7 @@ static void i2c_pxa_abort(struct pxa_i2c
31                 return;
32         }
33  
34 -       while ((i > 0) && (readl(_IBMR(i2c)) & 0x1) == 0) {
35 +       while ((i > 0) && (readl(_IBMR(i2c)) & IBMR_SDAS) == 0) {
36                 unsigned long icr = readl(_ICR(i2c));
37  
38                 icr &= ~ICR_START;
39 @@ -390,7 +393,8 @@ static int i2c_pxa_wait_master(struct px
40                  * quick check of the i2c lines themselves to ensure they've
41                  * gone high...
42                  */
43 -               if ((readl(_ISR(i2c)) & (ISR_UB | ISR_IBB)) == 0 && readl(_IBMR(i2c)) == 3) {
44 +               if ((readl(_ISR(i2c)) & (ISR_UB | ISR_IBB)) == 0 &&
45 +                   readl(_IBMR(i2c)) == (IBMR_SCLS | IBMR_SDAS)) {
46                         if (i2c_debug > 0)
47                                 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__);
48                         return 1;
49 @@ -575,7 +579,7 @@ static void i2c_pxa_slave_start(struct p
50         timeout = 0x10000;
51  
52         while (1) {
53 -               if ((readl(_IBMR(i2c)) & 2) == 2)
54 +               if ((readl(_IBMR(i2c)) & IBMR_SCLS) == IBMR_SCLS)
55                         break;
56  
57                 timeout--;
58 @@ -638,7 +642,7 @@ static void i2c_pxa_slave_start(struct p
59         timeout = 0x10000;
60  
61         while (1) {
62 -               if ((readl(_IBMR(i2c)) & 2) == 2)
63 +               if ((readl(_IBMR(i2c)) & IBMR_SCLS) == IBMR_SCLS)
64                         break;
65  
66                 timeout--;