aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-01-21 09:45:17 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-02-18 18:15:33 -0500
commitf5ae587f5d258bda9c24bb8387315eb2ebedeee9 (patch)
treea854b3717407390f2be1b7a3dc4df3e65a9e5aa9 /drivers
parentcae154767a96563d33924872aacfdc63d584f707 (diff)
MFD: ucb1x00-core: clean up device handling in probe
Clean up the device handling so we can use the struct device sanely. Acked-by: Jochen Friedrich <jochen@scram.de> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/ucb1x00-core.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c
index 7386f822d4cd..74d9fcf891d5 100644
--- a/drivers/mfd/ucb1x00-core.c
+++ b/drivers/mfd/ucb1x00-core.c
@@ -553,6 +553,7 @@ static int ucb1x00_probe(struct mcp *mcp)
553 if (!ucb) 553 if (!ucb)
554 goto err_disable; 554 goto err_disable;
555 555
556 device_initialize(&ucb->dev);
556 ucb->dev.class = &ucb1x00_class; 557 ucb->dev.class = &ucb1x00_class;
557 ucb->dev.parent = &mcp->attached_device; 558 ucb->dev.parent = &mcp->attached_device;
558 dev_set_name(&ucb->dev, "ucb1x00"); 559 dev_set_name(&ucb->dev, "ucb1x00");
@@ -563,11 +564,16 @@ static int ucb1x00_probe(struct mcp *mcp)
563 564
564 ucb->id = id; 565 ucb->id = id;
565 ucb->mcp = mcp; 566 ucb->mcp = mcp;
567
568 ret = device_add(&ucb->dev);
569 if (ret)
570 goto err_dev_add;
571
566 ucb->irq = ucb1x00_detect_irq(ucb); 572 ucb->irq = ucb1x00_detect_irq(ucb);
567 if (ucb->irq == NO_IRQ) { 573 if (ucb->irq == NO_IRQ) {
568 printk(KERN_ERR "UCB1x00: IRQ probe failed\n"); 574 dev_err(&ucb->dev, "IRQ probe failed\n");
569 ret = -ENODEV; 575 ret = -ENODEV;
570 goto err_free; 576 goto err_no_irq;
571 } 577 }
572 578
573 ucb->gpio.base = -1; 579 ucb->gpio.base = -1;
@@ -581,25 +587,20 @@ static int ucb1x00_probe(struct mcp *mcp)
581 ucb->gpio.direction_output = ucb1x00_gpio_direction_output; 587 ucb->gpio.direction_output = ucb1x00_gpio_direction_output;
582 ret = gpiochip_add(&ucb->gpio); 588 ret = gpiochip_add(&ucb->gpio);
583 if (ret) 589 if (ret)
584 goto err_free; 590 goto err_gpio_add;
585 } else 591 } else
586 dev_info(&ucb->dev, "gpio_base not set so no gpiolib support"); 592 dev_info(&ucb->dev, "gpio_base not set so no gpiolib support");
587 593
588 ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING, 594 ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING,
589 "UCB1x00", ucb); 595 "UCB1x00", ucb);
590 if (ret) { 596 if (ret) {
591 printk(KERN_ERR "ucb1x00: unable to grab irq%d: %d\n", 597 dev_err(&ucb->dev, "ucb1x00: unable to grab irq%d: %d\n",
592 ucb->irq, ret); 598 ucb->irq, ret);
593 goto err_gpio; 599 goto err_irq;
594 } 600 }
595 601
596 mcp_set_drvdata(mcp, ucb); 602 mcp_set_drvdata(mcp, ucb);
597 603
598 ret = device_register(&ucb->dev);
599 if (ret)
600 goto err_irq;
601
602
603 INIT_LIST_HEAD(&ucb->devs); 604 INIT_LIST_HEAD(&ucb->devs);
604 mutex_lock(&ucb1x00_mutex); 605 mutex_lock(&ucb1x00_mutex);
605 list_add(&ucb->node, &ucb1x00_devices); 606 list_add(&ucb->node, &ucb1x00_devices);
@@ -611,12 +612,13 @@ static int ucb1x00_probe(struct mcp *mcp)
611 return ret; 612 return ret;
612 613
613 err_irq: 614 err_irq:
614 free_irq(ucb->irq, ucb);
615 err_gpio:
616 if (ucb->gpio.base != -1) 615 if (ucb->gpio.base != -1)
617 temp = gpiochip_remove(&ucb->gpio); 616 temp = gpiochip_remove(&ucb->gpio);
618 err_free: 617 err_gpio_add:
619 kfree(ucb); 618 err_no_irq:
619 device_del(&ucb->dev);
620 err_dev_add:
621 put_device(&ucb->dev);
620 err_disable: 622 err_disable:
621 mcp_disable(mcp); 623 mcp_disable(mcp);
622 out: 624 out: