63
63
static struct pci_driver ali1563_pci_driver ;
64
64
static unsigned short ali1563_smba ;
65
65
66
- static int ali1563_transaction (struct i2c_adapter * a , int size )
66
+ static int ali1563_transaction (struct i2c_adapter * a , int size )
67
67
{
68
68
u32 data ;
69
69
int timeout ;
@@ -78,7 +78,7 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
78
78
data = inb_p (SMB_HST_STS );
79
79
if (data & HST_STS_BAD ) {
80
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
82
data = inb_p (SMB_HST_STS );
83
83
if (data & HST_STS_BAD )
84
84
return - EBUSY ;
@@ -102,10 +102,10 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
102
102
if (!timeout ) {
103
103
dev_err (& a -> dev , "Timeout - Trying to KILL transaction!\n" );
104
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
106
data = inb_p (SMB_HST_STS );
107
107
status = - ETIMEDOUT ;
108
- }
108
+ }
109
109
110
110
/* device error - no response, ignore the autodetection case */
111
111
if (data & HST_STS_DEVERR ) {
@@ -117,18 +117,18 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
117
117
if (data & HST_STS_BUSERR ) {
118
118
dev_err (& a -> dev , "Bus collision!\n" );
119
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
123
if (data & HST_STS_FAIL ) {
124
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
128
return status ;
129
129
}
130
130
131
- static int ali1563_block_start (struct i2c_adapter * a )
131
+ static int ali1563_block_start (struct i2c_adapter * a )
132
132
{
133
133
u32 data ;
134
134
int timeout ;
@@ -142,8 +142,8 @@ static int ali1563_block_start(struct i2c_adapter * a)
142
142
143
143
data = inb_p (SMB_HST_STS );
144
144
if (data & HST_STS_BAD ) {
145
- dev_warn (& a -> dev ,"ali1563: Trying to reset busy device\n" );
146
- outb_p (data | HST_STS_BAD ,SMB_HST_STS );
145
+ dev_warn (& a -> dev , "ali1563: Trying to reset busy device\n" );
146
+ outb_p (data | HST_STS_BAD , SMB_HST_STS );
147
147
data = inb_p (SMB_HST_STS );
148
148
if (data & HST_STS_BAD )
149
149
return - EBUSY ;
@@ -184,22 +184,23 @@ static int ali1563_block_start(struct i2c_adapter * a)
184
184
return status ;
185
185
}
186
186
187
- static int ali1563_block (struct i2c_adapter * a , union i2c_smbus_data * data , u8 rw )
187
+ static int ali1563_block (struct i2c_adapter * a ,
188
+ union i2c_smbus_data * data , u8 rw )
188
189
{
189
190
int i , len ;
190
191
int error = 0 ;
191
192
192
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
196
if (rw == I2C_SMBUS_WRITE ) {
196
197
len = data -> block [0 ];
197
198
if (len < 1 )
198
199
len = 1 ;
199
200
else if (len > 32 )
200
201
len = 32 ;
201
- outb_p (len ,SMB_HST_DAT0 );
202
- outb_p (data -> block [1 ],SMB_BLK_DAT );
202
+ outb_p (len , SMB_HST_DAT0 );
203
+ outb_p (data -> block [1 ], SMB_BLK_DAT );
203
204
} else
204
205
len = 32 ;
205
206
@@ -208,10 +209,12 @@ static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8
208
209
for (i = 0 ; i < len ; i ++ ) {
209
210
if (rw == I2C_SMBUS_WRITE ) {
210
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
214
break ;
213
215
} else {
214
- if ((error = ali1563_block_start (a )))
216
+ error = ali1563_block_start (a );
217
+ if (error )
215
218
break ;
216
219
if (i == 0 ) {
217
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
229
/* Do we need this? */
227
- outb_p (HST_CNTL1_LAST ,SMB_HST_CNTL1 );
230
+ outb_p (HST_CNTL1_LAST , SMB_HST_CNTL1 );
228
231
return error ;
229
232
}
230
233
231
- static s32 ali1563_access (struct i2c_adapter * a , u16 addr ,
234
+ static s32 ali1563_access (struct i2c_adapter * a , u16 addr ,
232
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
238
int error = 0 ;
236
239
int timeout ;
237
240
u32 reg ;
238
241
239
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
245
break ;
242
246
}
243
247
if (!timeout )
244
- dev_warn (& a -> dev ,"SMBus not idle. HST_STS = %02x\n" ,reg );
245
- outb_p (0xff ,SMB_HST_STS );
248
+ dev_warn (& a -> dev , "SMBus not idle. HST_STS = %02x\n" , reg );
249
+ outb_p (0xff , SMB_HST_STS );
246
250
247
251
/* Map the size to what the chip understands */
248
252
switch (size ) {
@@ -268,13 +272,14 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
268
272
}
269
273
270
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
278
/* Write the command register */
274
279
275
- switch (size ) {
280
+ switch (size ) {
276
281
case HST_CNTL2_BYTE :
277
- if (rw == I2C_SMBUS_WRITE )
282
+ if (rw == I2C_SMBUS_WRITE )
278
283
/* Beware it uses DAT0 register and not CMD! */
279
284
outb_p (cmd , SMB_HST_DAT0 );
280
285
break ;
@@ -292,11 +297,12 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
292
297
break ;
293
298
case HST_CNTL2_BLOCK :
294
299
outb_p (cmd , SMB_HST_CMD );
295
- error = ali1563_block (a ,data ,rw );
300
+ error = ali1563_block (a , data , rw );
296
301
goto Done ;
297
302
}
298
303
299
- if ((error = ali1563_transaction (a , size )))
304
+ error = ali1563_transaction (a , size );
305
+ if (error )
300
306
goto Done ;
301
307
302
308
if ((rw == I2C_SMBUS_WRITE ) || (size == HST_CNTL2_QUICK ))
@@ -317,7 +323,7 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
317
323
return error ;
318
324
}
319
325
320
- static u32 ali1563_func (struct i2c_adapter * a )
326
+ static u32 ali1563_func (struct i2c_adapter * a )
321
327
{
322
328
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
323
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
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
340
/* SMB I/O Base in high 12 bits and must be aligned with the
335
341
* size of the I/O space. */
336
342
ali1563_smba = ctrl & ~(ALI1563_SMB_IOSIZE - 1 );
337
343
if (!ali1563_smba ) {
338
- dev_warn (& dev -> dev ,"ali1563_smba Uninitialized\n" );
344
+ dev_warn (& dev -> dev , "ali1563_smba Uninitialized\n" );
339
345
goto Err ;
340
346
}
341
347
@@ -350,8 +356,8 @@ static int ali1563_setup(struct pci_dev *dev)
350
356
ctrl | ALI1563_SMB_IOEN );
351
357
pci_read_config_word (dev , ALI1563_SMBBA , & ctrl );
352
358
if (!(ctrl & ALI1563_SMB_IOEN )) {
353
- dev_err (& dev -> dev , "I/O space still not enabled, "
354
- "giving up\n" );
359
+ dev_err (& dev -> dev ,
360
+ "I/O space still not enabled, giving up\n" );
355
361
goto Err ;
356
362
}
357
363
}
@@ -375,7 +381,7 @@ static int ali1563_setup(struct pci_dev *dev)
375
381
376
382
static 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
381
387
static const struct i2c_algorithm ali1563_algorithm = {
@@ -394,12 +400,14 @@ static int ali1563_probe(struct pci_dev *dev,
394
400
{
395
401
int error ;
396
402
397
- if ((error = ali1563_setup (dev )))
403
+ error = ali1563_setup (dev );
404
+ if (error )
398
405
goto exit ;
399
406
ali1563_adapter .dev .parent = & dev -> dev ;
400
407
snprintf (ali1563_adapter .name , sizeof (ali1563_adapter .name ),
401
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
411
goto exit_shutdown ;
404
412
return 0 ;
405
413
@@ -421,12 +429,12 @@ static const struct pci_device_id ali1563_id_table[] = {
421
429
{},
422
430
};
423
431
424
- MODULE_DEVICE_TABLE (pci , ali1563_id_table );
432
+ MODULE_DEVICE_TABLE (pci , ali1563_id_table );
425
433
426
434
static struct pci_driver ali1563_pci_driver = {
427
- .name = "ali1563_smbus" ,
435
+ .name = "ali1563_smbus" ,
428
436
.id_table = ali1563_id_table ,
429
- .probe = ali1563_probe ,
437
+ .probe = ali1563_probe ,
430
438
.remove = ali1563_remove ,
431
439
};
432
440
0 commit comments