Input: adp5588-keys - unify common header defines

Unify adp5588-gpio and adp5588-keys common header defines (as per Andrew
Morton request). For consistency, move remaining defines and prefix
accordingly.

No functional changes.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

authored by Michael Hennerich and committed by Dmitry Torokhov 95716c0d c8ddb271

+39 -50
+25 -49
drivers/input/keyboard/adp5588-keys.c
··· 4 4 * I2C QWERTY Keypad and IO Expander 5 5 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 6 6 * 7 - * Copyright (C) 2008-2009 Analog Devices Inc. 7 + * Copyright (C) 2008-2010 Analog Devices Inc. 8 8 * Licensed under the GPL-2 or later. 9 9 */ 10 10 ··· 24 24 25 25 #include <linux/i2c/adp5588.h> 26 26 27 - /* Configuration Register1 */ 28 - #define AUTO_INC (1 << 7) 29 - #define GPIEM_CFG (1 << 6) 30 - #define OVR_FLOW_M (1 << 5) 31 - #define INT_CFG (1 << 4) 32 - #define OVR_FLOW_IEN (1 << 3) 33 - #define K_LCK_IM (1 << 2) 34 - #define GPI_IEN (1 << 1) 35 - #define KE_IEN (1 << 0) 36 - 37 - /* Interrupt Status Register */ 38 - #define CMP2_INT (1 << 5) 39 - #define CMP1_INT (1 << 4) 40 - #define OVR_FLOW_INT (1 << 3) 41 - #define K_LCK_INT (1 << 2) 42 - #define GPI_INT (1 << 1) 43 - #define KE_INT (1 << 0) 44 - 45 - /* Key Lock and Event Counter Register */ 46 - #define K_LCK_EN (1 << 6) 47 - #define LCK21 0x30 48 - #define KEC 0xF 49 - 50 27 /* Key Event Register xy */ 51 28 #define KEY_EV_PRESSED (1 << 7) 52 29 #define KEY_EV_MASK (0x7F) ··· 31 54 #define KP_SEL(x) (0xFFFF >> (16 - x)) /* 2^x-1 */ 32 55 33 56 #define KEYP_MAX_EVENT 10 34 - 35 - #define MAXGPIO 18 36 - #define ADP_BANK(offs) ((offs) >> 3) 37 - #define ADP_BIT(offs) (1u << ((offs) & 0x7)) 38 57 39 58 /* 40 59 * Early pre 4.0 Silicon required to delay readout by at least 25ms, ··· 48 75 const struct adp5588_gpi_map *gpimap; 49 76 unsigned short gpimapsize; 50 77 #ifdef CONFIG_GPIOLIB 51 - unsigned char gpiomap[MAXGPIO]; 78 + unsigned char gpiomap[ADP5588_MAXGPIO]; 52 79 bool export_gpio; 53 80 struct gpio_chip gc; 54 81 struct mutex gpio_lock; /* Protect cached dir, dat_out */ ··· 76 103 static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) 77 104 { 78 105 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 79 - unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 80 - unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 106 + unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 107 + unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 81 108 82 109 return !!(adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank) & bit); 83 110 } ··· 86 113 unsigned off, int val) 87 114 { 88 115 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 89 - unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 90 - unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 116 + unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 117 + unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 91 118 92 119 mutex_lock(&kpad->gpio_lock); 93 120 ··· 105 132 static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) 106 133 { 107 134 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 108 - unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 109 - unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 135 + unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 136 + unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 110 137 int ret; 111 138 112 139 mutex_lock(&kpad->gpio_lock); ··· 123 150 unsigned off, int val) 124 151 { 125 152 struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 126 - unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 127 - unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 153 + unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 154 + unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 128 155 int ret; 129 156 130 157 mutex_lock(&kpad->gpio_lock); ··· 149 176 static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad, 150 177 const struct adp5588_kpad_platform_data *pdata) 151 178 { 152 - bool pin_used[MAXGPIO]; 179 + bool pin_used[ADP5588_MAXGPIO]; 153 180 int n_unused = 0; 154 181 int i; 155 182 ··· 164 191 for (i = 0; i < kpad->gpimapsize; i++) 165 192 pin_used[kpad->gpimap[i].pin - GPI_PIN_BASE] = true; 166 193 167 - for (i = 0; i < MAXGPIO; i++) 194 + for (i = 0; i < ADP5588_MAXGPIO; i++) 168 195 if (!pin_used[i]) 169 196 kpad->gpiomap[n_unused++] = i; 170 197 ··· 207 234 return error; 208 235 } 209 236 210 - for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { 237 + for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { 211 238 kpad->dat_out[i] = adp5588_read(kpad->client, 212 239 GPIO_DAT_OUT1 + i); 213 240 kpad->dir[i] = adp5588_read(kpad->client, GPIO_DIR1 + i); ··· 291 318 292 319 status = adp5588_read(client, INT_STAT); 293 320 294 - if (status & OVR_FLOW_INT) /* Unlikely and should never happen */ 321 + if (status & ADP5588_OVR_FLOW_INT) /* Unlikely and should never happen */ 295 322 dev_err(&client->dev, "Event Overflow Error\n"); 296 323 297 - if (status & KE_INT) { 298 - ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & KEC; 324 + if (status & ADP5588_KE_INT) { 325 + ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & ADP5588_KEC; 299 326 if (ev_cnt) { 300 327 adp5588_report_events(kpad, ev_cnt); 301 328 input_sync(kpad->input); ··· 333 360 if (pdata->en_keylock) { 334 361 ret |= adp5588_write(client, UNLOCK1, pdata->unlock_key1); 335 362 ret |= adp5588_write(client, UNLOCK2, pdata->unlock_key2); 336 - ret |= adp5588_write(client, KEY_LCK_EC_STAT, K_LCK_EN); 363 + ret |= adp5588_write(client, KEY_LCK_EC_STAT, ADP5588_K_LCK_EN); 337 364 } 338 365 339 366 for (i = 0; i < KEYP_MAX_EVENT; i++) ··· 357 384 } 358 385 359 386 if (gpio_data) { 360 - for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { 387 + for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { 361 388 int pull_mask = gpio_data->pullup_dis_mask; 362 389 363 390 ret |= adp5588_write(client, GPIO_PULL1 + i, ··· 365 392 } 366 393 } 367 394 368 - ret |= adp5588_write(client, INT_STAT, CMP2_INT | CMP1_INT | 369 - OVR_FLOW_INT | K_LCK_INT | 370 - GPI_INT | KE_INT); /* Status is W1C */ 395 + ret |= adp5588_write(client, INT_STAT, 396 + ADP5588_CMP2_INT | ADP5588_CMP1_INT | 397 + ADP5588_OVR_FLOW_INT | ADP5588_K_LCK_INT | 398 + ADP5588_GPI_INT | ADP5588_KE_INT); /* Status is W1C */ 371 399 372 - ret |= adp5588_write(client, CFG, INT_CFG | OVR_FLOW_IEN | KE_IEN); 400 + ret |= adp5588_write(client, CFG, ADP5588_INT_CFG | 401 + ADP5588_OVR_FLOW_IEN | 402 + ADP5588_KE_IEN); 373 403 374 404 if (ret < 0) { 375 405 dev_err(&client->dev, "Write Error\n");
+14 -1
include/linux/i2c/adp5588.h
··· 1 1 /* 2 2 * Analog Devices ADP5588 I/O Expander and QWERTY Keypad Controller 3 3 * 4 - * Copyright 2009 Analog Devices Inc. 4 + * Copyright 2009-2010 Analog Devices Inc. 5 5 * 6 6 * Licensed under the GPL-2 or later. 7 7 */ ··· 77 77 /* Configuration Register1 */ 78 78 #define ADP5588_AUTO_INC (1 << 7) 79 79 #define ADP5588_GPIEM_CFG (1 << 6) 80 + #define ADP5588_OVR_FLOW_M (1 << 5) 80 81 #define ADP5588_INT_CFG (1 << 4) 82 + #define ADP5588_OVR_FLOW_IEN (1 << 3) 83 + #define ADP5588_K_LCK_IM (1 << 2) 81 84 #define ADP5588_GPI_IEN (1 << 1) 85 + #define ADP5588_KE_IEN (1 << 0) 82 86 83 87 /* Interrupt Status Register */ 88 + #define ADP5588_CMP2_INT (1 << 5) 89 + #define ADP5588_CMP1_INT (1 << 4) 90 + #define ADP5588_OVR_FLOW_INT (1 << 3) 91 + #define ADP5588_K_LCK_INT (1 << 2) 84 92 #define ADP5588_GPI_INT (1 << 1) 85 93 #define ADP5588_KE_INT (1 << 0) 94 + 95 + /* Key Lock and Event Counter Register */ 96 + #define ADP5588_K_LCK_EN (1 << 6) 97 + #define ADP5588_LCK21 0x30 98 + #define ADP5588_KEC 0xF 86 99 87 100 #define ADP5588_MAXGPIO 18 88 101 #define ADP5588_BANK(offs) ((offs) >> 3)