Commit f5ae587f authored by Russell King's avatar Russell King

MFD: ucb1x00-core: clean up device handling in probe

Clean up the device handling so we can use the struct device sanely.
Acked-by: default avatarJochen Friedrich <jochen@scram.de>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent cae15476
...@@ -553,6 +553,7 @@ static int ucb1x00_probe(struct mcp *mcp) ...@@ -553,6 +553,7 @@ static int ucb1x00_probe(struct mcp *mcp)
if (!ucb) if (!ucb)
goto err_disable; goto err_disable;
device_initialize(&ucb->dev);
ucb->dev.class = &ucb1x00_class; ucb->dev.class = &ucb1x00_class;
ucb->dev.parent = &mcp->attached_device; ucb->dev.parent = &mcp->attached_device;
dev_set_name(&ucb->dev, "ucb1x00"); dev_set_name(&ucb->dev, "ucb1x00");
...@@ -563,11 +564,16 @@ static int ucb1x00_probe(struct mcp *mcp) ...@@ -563,11 +564,16 @@ static int ucb1x00_probe(struct mcp *mcp)
ucb->id = id; ucb->id = id;
ucb->mcp = mcp; ucb->mcp = mcp;
ret = device_add(&ucb->dev);
if (ret)
goto err_dev_add;
ucb->irq = ucb1x00_detect_irq(ucb); ucb->irq = ucb1x00_detect_irq(ucb);
if (ucb->irq == NO_IRQ) { if (ucb->irq == NO_IRQ) {
printk(KERN_ERR "UCB1x00: IRQ probe failed\n"); dev_err(&ucb->dev, "IRQ probe failed\n");
ret = -ENODEV; ret = -ENODEV;
goto err_free; goto err_no_irq;
} }
ucb->gpio.base = -1; ucb->gpio.base = -1;
...@@ -581,25 +587,20 @@ static int ucb1x00_probe(struct mcp *mcp) ...@@ -581,25 +587,20 @@ static int ucb1x00_probe(struct mcp *mcp)
ucb->gpio.direction_output = ucb1x00_gpio_direction_output; ucb->gpio.direction_output = ucb1x00_gpio_direction_output;
ret = gpiochip_add(&ucb->gpio); ret = gpiochip_add(&ucb->gpio);
if (ret) if (ret)
goto err_free; goto err_gpio_add;
} else } else
dev_info(&ucb->dev, "gpio_base not set so no gpiolib support"); dev_info(&ucb->dev, "gpio_base not set so no gpiolib support");
ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING, ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING,
"UCB1x00", ucb); "UCB1x00", ucb);
if (ret) { if (ret) {
printk(KERN_ERR "ucb1x00: unable to grab irq%d: %d\n", dev_err(&ucb->dev, "ucb1x00: unable to grab irq%d: %d\n",
ucb->irq, ret); ucb->irq, ret);
goto err_gpio; goto err_irq;
} }
mcp_set_drvdata(mcp, ucb); mcp_set_drvdata(mcp, ucb);
ret = device_register(&ucb->dev);
if (ret)
goto err_irq;
INIT_LIST_HEAD(&ucb->devs); INIT_LIST_HEAD(&ucb->devs);
mutex_lock(&ucb1x00_mutex); mutex_lock(&ucb1x00_mutex);
list_add(&ucb->node, &ucb1x00_devices); list_add(&ucb->node, &ucb1x00_devices);
...@@ -611,12 +612,13 @@ static int ucb1x00_probe(struct mcp *mcp) ...@@ -611,12 +612,13 @@ static int ucb1x00_probe(struct mcp *mcp)
return ret; return ret;
err_irq: err_irq:
free_irq(ucb->irq, ucb);
err_gpio:
if (ucb->gpio.base != -1) if (ucb->gpio.base != -1)
temp = gpiochip_remove(&ucb->gpio); temp = gpiochip_remove(&ucb->gpio);
err_free: err_gpio_add:
kfree(ucb); err_no_irq:
device_del(&ucb->dev);
err_dev_add:
put_device(&ucb->dev);
err_disable: err_disable:
mcp_disable(mcp); mcp_disable(mcp);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment