aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-keywest.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-keywest.c')
-rw-r--r--drivers/i2c/busses/i2c-keywest.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c
index d61f748278fc..93e7080e3bc5 100644
--- a/drivers/i2c/busses/i2c-keywest.c
+++ b/drivers/i2c/busses/i2c-keywest.c
@@ -505,16 +505,23 @@ static int
505create_iface(struct device_node *np, struct device *dev) 505create_iface(struct device_node *np, struct device *dev)
506{ 506{
507 unsigned long steps; 507 unsigned long steps;
508 unsigned bsteps, tsize, i, nchan, addroffset; 508 unsigned bsteps, tsize, i, nchan;
509 struct keywest_iface* iface; 509 struct keywest_iface* iface;
510 u32 *psteps, *prate; 510 u32 *psteps, *prate, *addrp;
511 int rc; 511 int rc;
512 512
513 if (np->n_intrs < 1 || np->n_addrs < 1) { 513 if (np->n_intrs < 1) {
514 printk(KERN_ERR "%s: Missing interrupt or address !\n", 514 printk(KERN_ERR "%s: Missing interrupt !\n",
515 np->full_name); 515 np->full_name);
516 return -ENODEV; 516 return -ENODEV;
517 } 517 }
518 addrp = (u32 *)get_property(np, "AAPL,address", NULL);
519 if (addrp == NULL) {
520 printk(KERN_ERR "%s: Can't find address !\n",
521 np->full_name);
522 return -ENODEV;
523 }
524
518 if (pmac_low_i2c_lock(np)) 525 if (pmac_low_i2c_lock(np))
519 return -ENODEV; 526 return -ENODEV;
520 527
@@ -525,13 +532,10 @@ create_iface(struct device_node *np, struct device *dev)
525 for (bsteps = 0; (steps & 0x01) == 0; bsteps++) 532 for (bsteps = 0; (steps & 0x01) == 0; bsteps++)
526 steps >>= 1; 533 steps >>= 1;
527 534
528 if (np->parent->name[0] == 'u') { 535 if (np->parent->name[0] == 'u')
529 nchan = 2; 536 nchan = 2;
530 addroffset = 3; 537 else
531 } else {
532 addroffset = 0;
533 nchan = 1; 538 nchan = 1;
534 }
535 539
536 tsize = sizeof(struct keywest_iface) + 540 tsize = sizeof(struct keywest_iface) +
537 (sizeof(struct keywest_chan) + 4) * nchan; 541 (sizeof(struct keywest_chan) + 4) * nchan;
@@ -550,8 +554,7 @@ create_iface(struct device_node *np, struct device *dev)
550 iface->irq = np->intrs[0].line; 554 iface->irq = np->intrs[0].line;
551 iface->channels = (struct keywest_chan *) 555 iface->channels = (struct keywest_chan *)
552 (((unsigned long)(iface + 1) + 3UL) & ~3UL); 556 (((unsigned long)(iface + 1) + 3UL) & ~3UL);
553 iface->base = ioremap(np->addrs[0].address + addroffset, 557 iface->base = ioremap(*addrp, 0x1000);
554 np->addrs[0].size);
555 if (!iface->base) { 558 if (!iface->base) {
556 printk(KERN_ERR "i2c-keywest: can't map inteface !\n"); 559 printk(KERN_ERR "i2c-keywest: can't map inteface !\n");
557 kfree(iface); 560 kfree(iface);