Commit ce04a6fe authored by David Brownell's avatar David Brownell Committed by Tony Lindgren

provide detailed diagnostics in add_children()

Provide detailed diagnostics in add_children() when DEBUG is
defined ... and fix the non-DEBUG message to include minimal
status, and not appear unless there was actually an error.

Update the IRQ message; have it match what the GPIO subchip
says, and as a precaution, make it only appear if the IRQs
have been initialized.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>

Added a few more diagnostics when platform_device_add() fails.
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 07dae18e
...@@ -672,8 +672,10 @@ static int add_children(struct twl4030_platform_data *pdata) ...@@ -672,8 +672,10 @@ static int add_children(struct twl4030_platform_data *pdata)
twl = &twl4030_modules[TWL4030_SLAVENUM_NUM1]; twl = &twl4030_modules[TWL4030_SLAVENUM_NUM1];
pdev = platform_device_alloc("twl4030_gpio", -1); pdev = platform_device_alloc("twl4030_gpio", -1);
if (!pdev) if (!pdev) {
pr_debug("%s: can't alloc gpio dev\n", DRIVER_NAME);
status = -ENOMEM; status = -ENOMEM;
}
/* more driver model init */ /* more driver model init */
if (status == 0) { if (status == 0) {
...@@ -682,6 +684,12 @@ static int add_children(struct twl4030_platform_data *pdata) ...@@ -682,6 +684,12 @@ static int add_children(struct twl4030_platform_data *pdata)
status = platform_device_add_data(pdev, pdata->gpio, status = platform_device_add_data(pdev, pdata->gpio,
sizeof(*pdata->gpio)); sizeof(*pdata->gpio));
if (status < 0) {
dev_dbg(&twl->client->dev,
"can't add gpio data, %d\n",
status);
goto err;
}
} }
/* GPIO module IRQ */ /* GPIO module IRQ */
...@@ -715,13 +723,21 @@ static int add_children(struct twl4030_platform_data *pdata) ...@@ -715,13 +723,21 @@ static int add_children(struct twl4030_platform_data *pdata)
status = platform_device_add_data(pdev, pdata->keypad, status = platform_device_add_data(pdev, pdata->keypad,
sizeof(*pdata->keypad)); sizeof(*pdata->keypad));
if (status < 0) { if (status < 0) {
dev_dbg(&twl->client->dev,
"can't add keypad data, %d\n",
status);
platform_device_put(pdev); platform_device_put(pdev);
goto err; goto err;
} }
status = platform_device_add(pdev); status = platform_device_add(pdev);
if (status < 0) if (status < 0) {
platform_device_put(pdev); platform_device_put(pdev);
dev_dbg(&twl->client->dev,
"can't create keypad dev, %d\n",
status);
}
} else { } else {
pr_debug("%s: can't alloc keypad dev\n", DRIVER_NAME);
status = -ENOMEM; status = -ENOMEM;
goto err; goto err;
} }
...@@ -737,12 +753,20 @@ static int add_children(struct twl4030_platform_data *pdata) ...@@ -737,12 +753,20 @@ static int add_children(struct twl4030_platform_data *pdata)
sizeof(*pdata->madc)); sizeof(*pdata->madc));
if (status < 0) { if (status < 0) {
platform_device_put(pdev); platform_device_put(pdev);
dev_dbg(&twl->client->dev,
"can't add madc data, %d\n",
status);
goto err; goto err;
} }
status = platform_device_add(pdev); status = platform_device_add(pdev);
if (status < 0) if (status < 0) {
platform_device_put(pdev); platform_device_put(pdev);
dev_dbg(&twl->client->dev,
"can't create madc dev, %d\n",
status);
}
} else { } else {
pr_debug("%s: can't alloc madc dev\n", DRIVER_NAME);
status = -ENOMEM; status = -ENOMEM;
goto err; goto err;
} }
...@@ -770,9 +794,14 @@ static int add_children(struct twl4030_platform_data *pdata) ...@@ -770,9 +794,14 @@ static int add_children(struct twl4030_platform_data *pdata)
*/ */
status = platform_device_add(pdev); status = platform_device_add(pdev);
if (status < 0) if (status < 0) {
platform_device_put(pdev); platform_device_put(pdev);
dev_dbg(&twl->client->dev,
"can't create rtc dev, %d\n",
status);
}
} else { } else {
pr_debug("%s: can't alloc rtc dev\n", DRIVER_NAME);
status = -ENOMEM; status = -ENOMEM;
goto err; goto err;
} }
...@@ -788,19 +817,28 @@ static int add_children(struct twl4030_platform_data *pdata) ...@@ -788,19 +817,28 @@ static int add_children(struct twl4030_platform_data *pdata)
sizeof(*pdata->usb)); sizeof(*pdata->usb));
if (status < 0) { if (status < 0) {
platform_device_put(pdev); platform_device_put(pdev);
dev_dbg(&twl->client->dev,
"can't add usb data, %d\n",
status);
goto err; goto err;
} }
status = platform_device_add(pdev); status = platform_device_add(pdev);
if (status < 0) if (status < 0) {
platform_device_put(pdev); platform_device_put(pdev);
dev_dbg(&twl->client->dev,
"can't create usb dev, %d\n",
status);
}
} else { } else {
pr_debug("%s: can't alloc usb dev\n", DRIVER_NAME);
status = -ENOMEM; status = -ENOMEM;
goto err; goto err;
} }
} }
err: err:
pr_err("failed to add twl4030's children\n"); if (status)
pr_err("failed to add twl4030's children (status %d)\n", status);
return status; return status;
} }
...@@ -1084,13 +1122,12 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -1084,13 +1122,12 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
&& twl4030_irq_base == 0 && twl4030_irq_base == 0
&& client->irq && client->irq
&& pdata->irq_base && pdata->irq_base
&& pdata->irq_end > pdata->irq_base) && pdata->irq_end > pdata->irq_base) {
twl_init_irq(client->irq, pdata->irq_base, pdata->irq_end); twl_init_irq(client->irq, pdata->irq_base, pdata->irq_end);
dev_info(&client->dev, "IRQ %d chains IRQs %d..%d\n",
client->irq, pdata->irq_base, pdata->irq_end - 1);
}
dev_info(&client->dev, "chaining %d irqs\n",
twl4030_irq_base
? (pdata->irq_end - pdata->irq_base)
: 0);
return 0; return 0;
fail: fail:
......
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