aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/i2c/busses/scx200_acb.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index f45779b7690..bfa243d5a8f 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -45,12 +45,6 @@ static int base[MAX_DEVICES] = { 0x820, 0x840 };
45module_param_array(base, int, NULL, 0); 45module_param_array(base, int, NULL, 0);
46MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers"); 46MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers");
47 47
48#ifdef DEBUG
49#define DBG(x...) printk(KERN_DEBUG NAME ": " x)
50#else
51#define DBG(x...)
52#endif
53
54/* The hardware supports interrupt driven mode too, but I haven't 48/* The hardware supports interrupt driven mode too, but I haven't
55 implemented that. */ 49 implemented that. */
56#define POLLED_MODE 1 50#define POLLED_MODE 1
@@ -119,8 +113,8 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
119{ 113{
120 const char *errmsg; 114 const char *errmsg;
121 115
122 DBG("state %s, status = 0x%02x\n", 116 dev_dbg(&iface->adapter.dev, "state %s, status = 0x%02x\n",
123 scx200_acb_state_name[iface->state], status); 117 scx200_acb_state_name[iface->state], status);
124 118
125 if (status & ACBST_BER) { 119 if (status & ACBST_BER) {
126 errmsg = "bus error"; 120 errmsg = "bus error";
@@ -209,8 +203,8 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
209 return; 203 return;
210 204
211 negack: 205 negack:
212 DBG("negative acknowledge in state %s\n", 206 dev_dbg(&iface->adapter.dev, "negative ack in state %s\n",
213 scx200_acb_state_name[iface->state]); 207 scx200_acb_state_name[iface->state]);
214 208
215 iface->state = state_idle; 209 iface->state = state_idle;
216 iface->result = -ENXIO; 210 iface->result = -ENXIO;
@@ -326,19 +320,15 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter,
326 return -EINVAL; 320 return -EINVAL;
327 } 321 }
328 322
329 DBG("size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n", 323 dev_dbg(&adapter->dev,
330 size, address, command, len, rw == I2C_SMBUS_READ); 324 "size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n",
325 size, address, command, len, rw);
331 326
332 if (!len && rw == I2C_SMBUS_READ) { 327 if (!len && rw == I2C_SMBUS_READ) {
333 dev_warn(&adapter->dev, "zero length read\n"); 328 dev_dbg(&adapter->dev, "zero length read\n");
334 return -EINVAL; 329 return -EINVAL;
335 } 330 }
336 331
337 if (len && !buffer) {
338 dev_warn(&adapter->dev, "nonzero length but no buffer\n");
339 return -EFAULT;
340 }
341
342 down(&iface->sem); 332 down(&iface->sem);
343 333
344 iface->address_byte = address<<1; 334 iface->address_byte = address<<1;
@@ -375,7 +365,7 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter,
375 data->word = le16_to_cpu(cur_word); 365 data->word = le16_to_cpu(cur_word);
376 366
377#ifdef DEBUG 367#ifdef DEBUG
378 DBG(": transfer done, result: %d", rc); 368 dev_dbg(&adapter->dev, "transfer done, result: %d", rc);
379 if (buffer) { 369 if (buffer) {
380 int i; 370 int i;
381 printk(" data:"); 371 printk(" data:");
@@ -412,7 +402,7 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface)
412 outb(0x70, ACBCTL2); 402 outb(0x70, ACBCTL2);
413 403
414 if (inb(ACBCTL2) != 0x70) { 404 if (inb(ACBCTL2) != 0x70) {
415 DBG("ACBCTL2 readback failed\n"); 405 pr_debug(NAME ": ACBCTL2 readback failed\n");
416 return -ENXIO; 406 return -ENXIO;
417 } 407 }
418 408
@@ -420,7 +410,8 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface)
420 410
421 val = inb(ACBCTL1); 411 val = inb(ACBCTL1);
422 if (val) { 412 if (val) {
423 DBG("disabled, but ACBCTL1=0x%02x\n", val); 413 pr_debug(NAME ": disabled, but ACBCTL1=0x%02x\n",
414 val);
424 return -ENXIO; 415 return -ENXIO;
425 } 416 }
426 417
@@ -430,7 +421,8 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface)
430 421
431 val = inb(ACBCTL1); 422 val = inb(ACBCTL1);
432 if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) { 423 if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) {
433 DBG("enabled, but NMINTE won't be set, ACBCTL1=0x%02x\n", val); 424 pr_debug(NAME ": enabled, but NMINTE won't be set, "
425 "ACBCTL1=0x%02x\n", val);
434 return -ENXIO; 426 return -ENXIO;
435 } 427 }
436 428
@@ -464,7 +456,7 @@ static int __init scx200_acb_create(int base, int index)
464 snprintf(description, sizeof(description), 456 snprintf(description, sizeof(description),
465 "NatSemi SCx200 ACCESS.bus [%s]", adapter->name); 457 "NatSemi SCx200 ACCESS.bus [%s]", adapter->name);
466 if (request_region(base, 8, description) == 0) { 458 if (request_region(base, 8, description) == 0) {
467 dev_err(&adapter->dev, "can't allocate io 0x%x-0x%x\n", 459 printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n",
468 base, base + 8-1); 460 base, base + 8-1);
469 rc = -EBUSY; 461 rc = -EBUSY;
470 goto errout; 462 goto errout;
@@ -473,14 +465,14 @@ static int __init scx200_acb_create(int base, int index)
473 465
474 rc = scx200_acb_probe(iface); 466 rc = scx200_acb_probe(iface);
475 if (rc) { 467 if (rc) {
476 dev_warn(&adapter->dev, "probe failed\n"); 468 printk(KERN_WARNING NAME ": probe failed\n");
477 goto errout; 469 goto errout;
478 } 470 }
479 471
480 scx200_acb_reset(iface); 472 scx200_acb_reset(iface);
481 473
482 if (i2c_add_adapter(adapter) < 0) { 474 if (i2c_add_adapter(adapter) < 0) {
483 dev_err(&adapter->dev, "failed to register\n"); 475 printk(KERN_ERR NAME ": failed to register\n");
484 rc = -ENODEV; 476 rc = -ENODEV;
485 goto errout; 477 goto errout;
486 } 478 }