aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Leitner <me@g0hl1n.net>2014-04-11 07:44:44 -0400
committerWolfram Sang <wsa@the-dreams.de>2014-05-22 04:09:21 -0400
commit482116badacba9308abd6c5cae2f5f19e2f81449 (patch)
tree179fae0e0c6332b7c28970e0c62449599fa9a545
parent9219982bc64a41ec7745668b06f86e97b498e10a (diff)
i2c: ali1563: fix checkpatch.pl issues
Fixed most checkpatch.pl issues Signed-off-by: Richard Leitner <me@g0hl1n.net> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c82
1 files changed, 45 insertions, 37 deletions
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index 98a1c97739ba..15517d78d5ff 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -63,7 +63,7 @@
63static struct pci_driver ali1563_pci_driver; 63static struct pci_driver ali1563_pci_driver;
64static unsigned short ali1563_smba; 64static unsigned short ali1563_smba;
65 65
66static int ali1563_transaction(struct i2c_adapter * a, int size) 66static int ali1563_transaction(struct i2c_adapter *a, int size)
67{ 67{
68 u32 data; 68 u32 data;
69 int timeout; 69 int timeout;
@@ -78,7 +78,7 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
78 data = inb_p(SMB_HST_STS); 78 data = inb_p(SMB_HST_STS);
79 if (data & HST_STS_BAD) { 79 if (data & HST_STS_BAD) {
80 dev_err(&a->dev, "ali1563: Trying to reset busy device\n"); 80 dev_err(&a->dev, "ali1563: Trying to reset busy device\n");
81 outb_p(data | HST_STS_BAD,SMB_HST_STS); 81 outb_p(data | HST_STS_BAD, SMB_HST_STS);
82 data = inb_p(SMB_HST_STS); 82 data = inb_p(SMB_HST_STS);
83 if (data & HST_STS_BAD) 83 if (data & HST_STS_BAD)
84 return -EBUSY; 84 return -EBUSY;
@@ -102,10 +102,10 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
102 if (!timeout) { 102 if (!timeout) {
103 dev_err(&a->dev, "Timeout - Trying to KILL transaction!\n"); 103 dev_err(&a->dev, "Timeout - Trying to KILL transaction!\n");
104 /* Issue 'kill' to host controller */ 104 /* Issue 'kill' to host controller */
105 outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2); 105 outb_p(HST_CNTL2_KILL, SMB_HST_CNTL2);
106 data = inb_p(SMB_HST_STS); 106 data = inb_p(SMB_HST_STS);
107 status = -ETIMEDOUT; 107 status = -ETIMEDOUT;
108 } 108 }
109 109
110 /* device error - no response, ignore the autodetection case */ 110 /* device error - no response, ignore the autodetection case */
111 if (data & HST_STS_DEVERR) { 111 if (data & HST_STS_DEVERR) {
@@ -117,18 +117,18 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
117 if (data & HST_STS_BUSERR) { 117 if (data & HST_STS_BUSERR) {
118 dev_err(&a->dev, "Bus collision!\n"); 118 dev_err(&a->dev, "Bus collision!\n");
119 /* Issue timeout, hoping it helps */ 119 /* Issue timeout, hoping it helps */
120 outb_p(HST_CNTL1_TIMEOUT,SMB_HST_CNTL1); 120 outb_p(HST_CNTL1_TIMEOUT, SMB_HST_CNTL1);
121 } 121 }
122 122
123 if (data & HST_STS_FAIL) { 123 if (data & HST_STS_FAIL) {
124 dev_err(&a->dev, "Cleaning fail after KILL!\n"); 124 dev_err(&a->dev, "Cleaning fail after KILL!\n");
125 outb_p(0x0,SMB_HST_CNTL2); 125 outb_p(0x0, SMB_HST_CNTL2);
126 } 126 }
127 127
128 return status; 128 return status;
129} 129}
130 130
131static int ali1563_block_start(struct i2c_adapter * a) 131static int ali1563_block_start(struct i2c_adapter *a)
132{ 132{
133 u32 data; 133 u32 data;
134 int timeout; 134 int timeout;
@@ -142,8 +142,8 @@ static int ali1563_block_start(struct i2c_adapter * a)
142 142
143 data = inb_p(SMB_HST_STS); 143 data = inb_p(SMB_HST_STS);
144 if (data & HST_STS_BAD) { 144 if (data & HST_STS_BAD) {
145 dev_warn(&a->dev,"ali1563: Trying to reset busy device\n"); 145 dev_warn(&a->dev, "ali1563: Trying to reset busy device\n");
146 outb_p(data | HST_STS_BAD,SMB_HST_STS); 146 outb_p(data | HST_STS_BAD, SMB_HST_STS);
147 data = inb_p(SMB_HST_STS); 147 data = inb_p(SMB_HST_STS);
148 if (data & HST_STS_BAD) 148 if (data & HST_STS_BAD)
149 return -EBUSY; 149 return -EBUSY;
@@ -184,13 +184,14 @@ static int ali1563_block_start(struct i2c_adapter * a)
184 return status; 184 return status;
185} 185}
186 186
187static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8 rw) 187static int ali1563_block(struct i2c_adapter *a,
188 union i2c_smbus_data *data, u8 rw)
188{ 189{
189 int i, len; 190 int i, len;
190 int error = 0; 191 int error = 0;
191 192
192 /* Do we need this? */ 193 /* Do we need this? */
193 outb_p(HST_CNTL1_LAST,SMB_HST_CNTL1); 194 outb_p(HST_CNTL1_LAST, SMB_HST_CNTL1);
194 195
195 if (rw == I2C_SMBUS_WRITE) { 196 if (rw == I2C_SMBUS_WRITE) {
196 len = data->block[0]; 197 len = data->block[0];
@@ -198,8 +199,8 @@ static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8
198 len = 1; 199 len = 1;
199 else if (len > 32) 200 else if (len > 32)
200 len = 32; 201 len = 32;
201 outb_p(len,SMB_HST_DAT0); 202 outb_p(len, SMB_HST_DAT0);
202 outb_p(data->block[1],SMB_BLK_DAT); 203 outb_p(data->block[1], SMB_BLK_DAT);
203 } else 204 } else
204 len = 32; 205 len = 32;
205 206
@@ -208,10 +209,12 @@ static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8
208 for (i = 0; i < len; i++) { 209 for (i = 0; i < len; i++) {
209 if (rw == I2C_SMBUS_WRITE) { 210 if (rw == I2C_SMBUS_WRITE) {
210 outb_p(data->block[i + 1], SMB_BLK_DAT); 211 outb_p(data->block[i + 1], SMB_BLK_DAT);
211 if ((error = ali1563_block_start(a))) 212 error = ali1563_block_start(a);
213 if (error)
212 break; 214 break;
213 } else { 215 } else {
214 if ((error = ali1563_block_start(a))) 216 error = ali1563_block_start(a);
217 if (error)
215 break; 218 break;
216 if (i == 0) { 219 if (i == 0) {
217 len = inb_p(SMB_HST_DAT0); 220 len = inb_p(SMB_HST_DAT0);
@@ -224,25 +227,26 @@ static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8
224 } 227 }
225 } 228 }
226 /* Do we need this? */ 229 /* Do we need this? */
227 outb_p(HST_CNTL1_LAST,SMB_HST_CNTL1); 230 outb_p(HST_CNTL1_LAST, SMB_HST_CNTL1);
228 return error; 231 return error;
229} 232}
230 233
231static s32 ali1563_access(struct i2c_adapter * a, u16 addr, 234static s32 ali1563_access(struct i2c_adapter *a, u16 addr,
232 unsigned short flags, char rw, u8 cmd, 235 unsigned short flags, char rw, u8 cmd,
233 int size, union i2c_smbus_data * data) 236 int size, union i2c_smbus_data *data)
234{ 237{
235 int error = 0; 238 int error = 0;
236 int timeout; 239 int timeout;
237 u32 reg; 240 u32 reg;
238 241
239 for (timeout = ALI1563_MAX_TIMEOUT; timeout; timeout--) { 242 for (timeout = ALI1563_MAX_TIMEOUT; timeout; timeout--) {
240 if (!(reg = inb_p(SMB_HST_STS) & HST_STS_BUSY)) 243 reg = inb_p(SMB_HST_STS);
244 if (!(reg & HST_STS_BUSY))
241 break; 245 break;
242 } 246 }
243 if (!timeout) 247 if (!timeout)
244 dev_warn(&a->dev,"SMBus not idle. HST_STS = %02x\n",reg); 248 dev_warn(&a->dev, "SMBus not idle. HST_STS = %02x\n", reg);
245 outb_p(0xff,SMB_HST_STS); 249 outb_p(0xff, SMB_HST_STS);
246 250
247 /* Map the size to what the chip understands */ 251 /* Map the size to what the chip understands */
248 switch (size) { 252 switch (size) {
@@ -268,13 +272,14 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
268 } 272 }
269 273
270 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD); 274 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD);
271 outb_p((inb_p(SMB_HST_CNTL2) & ~HST_CNTL2_SIZEMASK) | (size << 3), SMB_HST_CNTL2); 275 outb_p((inb_p(SMB_HST_CNTL2) & ~HST_CNTL2_SIZEMASK) |
276 (size << 3), SMB_HST_CNTL2);
272 277
273 /* Write the command register */ 278 /* Write the command register */
274 279
275 switch(size) { 280 switch (size) {
276 case HST_CNTL2_BYTE: 281 case HST_CNTL2_BYTE:
277 if (rw== I2C_SMBUS_WRITE) 282 if (rw == I2C_SMBUS_WRITE)
278 /* Beware it uses DAT0 register and not CMD! */ 283 /* Beware it uses DAT0 register and not CMD! */
279 outb_p(cmd, SMB_HST_DAT0); 284 outb_p(cmd, SMB_HST_DAT0);
280 break; 285 break;
@@ -292,11 +297,12 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
292 break; 297 break;
293 case HST_CNTL2_BLOCK: 298 case HST_CNTL2_BLOCK:
294 outb_p(cmd, SMB_HST_CMD); 299 outb_p(cmd, SMB_HST_CMD);
295 error = ali1563_block(a,data,rw); 300 error = ali1563_block(a, data, rw);
296 goto Done; 301 goto Done;
297 } 302 }
298 303
299 if ((error = ali1563_transaction(a, size))) 304 error = ali1563_transaction(a, size);
305 if (error)
300 goto Done; 306 goto Done;
301 307
302 if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK)) 308 if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK))
@@ -317,7 +323,7 @@ Done:
317 return error; 323 return error;
318} 324}
319 325
320static u32 ali1563_func(struct i2c_adapter * a) 326static u32 ali1563_func(struct i2c_adapter *a)
321{ 327{
322 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 328 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
323 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | 329 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
@@ -329,13 +335,13 @@ static int ali1563_setup(struct pci_dev *dev)
329{ 335{
330 u16 ctrl; 336 u16 ctrl;
331 337
332 pci_read_config_word(dev,ALI1563_SMBBA,&ctrl); 338 pci_read_config_word(dev, ALI1563_SMBBA, &ctrl);
333 339
334 /* SMB I/O Base in high 12 bits and must be aligned with the 340 /* SMB I/O Base in high 12 bits and must be aligned with the
335 * size of the I/O space. */ 341 * size of the I/O space. */
336 ali1563_smba = ctrl & ~(ALI1563_SMB_IOSIZE - 1); 342 ali1563_smba = ctrl & ~(ALI1563_SMB_IOSIZE - 1);
337 if (!ali1563_smba) { 343 if (!ali1563_smba) {
338 dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); 344 dev_warn(&dev->dev, "ali1563_smba Uninitialized\n");
339 goto Err; 345 goto Err;
340 } 346 }
341 347
@@ -350,8 +356,8 @@ static int ali1563_setup(struct pci_dev *dev)
350 ctrl | ALI1563_SMB_IOEN); 356 ctrl | ALI1563_SMB_IOEN);
351 pci_read_config_word(dev, ALI1563_SMBBA, &ctrl); 357 pci_read_config_word(dev, ALI1563_SMBBA, &ctrl);
352 if (!(ctrl & ALI1563_SMB_IOEN)) { 358 if (!(ctrl & ALI1563_SMB_IOEN)) {
353 dev_err(&dev->dev, "I/O space still not enabled, " 359 dev_err(&dev->dev,
354 "giving up\n"); 360 "I/O space still not enabled, giving up\n");
355 goto Err; 361 goto Err;
356 } 362 }
357 } 363 }
@@ -375,7 +381,7 @@ Err:
375 381
376static void ali1563_shutdown(struct pci_dev *dev) 382static void ali1563_shutdown(struct pci_dev *dev)
377{ 383{
378 release_region(ali1563_smba,ALI1563_SMB_IOSIZE); 384 release_region(ali1563_smba, ALI1563_SMB_IOSIZE);
379} 385}
380 386
381static const struct i2c_algorithm ali1563_algorithm = { 387static const struct i2c_algorithm ali1563_algorithm = {
@@ -394,12 +400,14 @@ static int ali1563_probe(struct pci_dev *dev,
394{ 400{
395 int error; 401 int error;
396 402
397 if ((error = ali1563_setup(dev))) 403 error = ali1563_setup(dev);
404 if (error)
398 goto exit; 405 goto exit;
399 ali1563_adapter.dev.parent = &dev->dev; 406 ali1563_adapter.dev.parent = &dev->dev;
400 snprintf(ali1563_adapter.name, sizeof(ali1563_adapter.name), 407 snprintf(ali1563_adapter.name, sizeof(ali1563_adapter.name),
401 "SMBus ALi 1563 Adapter @ %04x", ali1563_smba); 408 "SMBus ALi 1563 Adapter @ %04x", ali1563_smba);
402 if ((error = i2c_add_adapter(&ali1563_adapter))) 409 error = i2c_add_adapter(&ali1563_adapter);
410 if (error)
403 goto exit_shutdown; 411 goto exit_shutdown;
404 return 0; 412 return 0;
405 413
@@ -421,12 +429,12 @@ static const struct pci_device_id ali1563_id_table[] = {
421 {}, 429 {},
422}; 430};
423 431
424MODULE_DEVICE_TABLE (pci, ali1563_id_table); 432MODULE_DEVICE_TABLE(pci, ali1563_id_table);
425 433
426static struct pci_driver ali1563_pci_driver = { 434static struct pci_driver ali1563_pci_driver = {
427 .name = "ali1563_smbus", 435 .name = "ali1563_smbus",
428 .id_table = ali1563_id_table, 436 .id_table = ali1563_id_table,
429 .probe = ali1563_probe, 437 .probe = ali1563_probe,
430 .remove = ali1563_remove, 438 .remove = ali1563_remove,
431}; 439};
432 440