Commit 9b5c9f043e7a70665b2eb092f316d5d5cd238d49

Authored by Andy Shevchenko
Committed by Wolfram Sang
1 parent 13a7a6ac0a

i2c: designware-baytrail: describe magic numbers

The patch converts hardcoded numerical constants to a named ones.

While here, align the variable name in get_sem() and reset_semaphore().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: David E. Box <david.e.box@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Showing 1 changed file with 9 additions and 7 deletions Side-by-side Diff

drivers/i2c/busses/i2c-designware-baytrail.c
... ... @@ -22,22 +22,24 @@
22 22  
23 23 #define SEMAPHORE_TIMEOUT 100
24 24 #define PUNIT_SEMAPHORE 0x7
  25 +#define PUNIT_SEMAPHORE_BIT BIT(0)
  26 +#define PUNIT_SEMAPHORE_ACQUIRE BIT(1)
25 27  
26 28 static unsigned long acquired;
27 29  
28 30 static int get_sem(struct device *dev, u32 *sem)
29 31 {
30   - u32 reg_val;
  32 + u32 data;
31 33 int ret;
32 34  
33 35 ret = iosf_mbi_read(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_READ, PUNIT_SEMAPHORE,
34   - &reg_val);
  36 + &data);
35 37 if (ret) {
36 38 dev_err(dev, "iosf failed to read punit semaphore\n");
37 39 return ret;
38 40 }
39 41  
40   - *sem = reg_val & 0x1;
  42 + *sem = data & PUNIT_SEMAPHORE_BIT;
41 43  
42 44 return 0;
43 45 }
44 46  
... ... @@ -52,9 +54,9 @@
52 54 return;
53 55 }
54 56  
55   - data = data & 0xfffffffe;
  57 + data &= ~PUNIT_SEMAPHORE_BIT;
56 58 if (iosf_mbi_write(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_WRITE,
57   - PUNIT_SEMAPHORE, data))
  59 + PUNIT_SEMAPHORE, data))
58 60 dev_err(dev, "iosf failed to reset punit semaphore during write\n");
59 61 }
60 62  
61 63  
... ... @@ -70,9 +72,9 @@
70 72 if (!dev->acquire_lock)
71 73 return 0;
72 74  
73   - /* host driver writes 0x2 to side band semaphore register */
  75 + /* host driver writes to side band semaphore register */
74 76 ret = iosf_mbi_write(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_WRITE,
75   - PUNIT_SEMAPHORE, 0x2);
  77 + PUNIT_SEMAPHORE, PUNIT_SEMAPHORE_ACQUIRE);
76 78 if (ret) {
77 79 dev_err(dev->dev, "iosf punit semaphore request failed\n");
78 80 return ret;