[PATCH] x86/intel-mid: Add pr_warn when platform_device_add() fails
From: Aditya Pakki
Date: Mon Dec 24 2018 - 11:48:09 EST
platform_device_add() may fail in intel_scu_devices_create and
sfi_handle_ipc_dev. The fix checks for the return value in these cases
and displays the failed device.
Signed-off-by: Aditya Pakki <pakki001@xxxxxxx>
---
arch/x86/platform/intel-mid/sfi.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c
index 7be1e1fe9ae3..e69511bafec5 100644
--- a/arch/x86/platform/intel-mid/sfi.c
+++ b/arch/x86/platform/intel-mid/sfi.c
@@ -278,9 +278,13 @@ static void __init intel_scu_i2c_device_register(int bus,
void intel_scu_devices_create(void)
{
int i;
+ int ret;
- for (i = 0; i < ipc_next_dev; i++)
- platform_device_add(ipc_devs[i]);
+ for (i = 0; i < ipc_next_dev; i++) {
+ ret = platform_device_add(ipc_devs[i]);
+ if (ret)
+ pr_warn("can't add device %s\n", ipc_devs[i]);
+ }
for (i = 0; i < spi_next_dev; i++)
spi_register_board_info(spi_devs[i], 1);
@@ -330,6 +334,7 @@ static void __init sfi_handle_ipc_dev(struct sfi_device_table_entry *pentry,
{
struct platform_device *pdev;
void *pdata = NULL;
+ int ret;
pr_debug("IPC bus, name = %16.16s, irq = 0x%2x\n",
pentry->name, pentry->irq);
@@ -360,8 +365,11 @@ static void __init sfi_handle_ipc_dev(struct sfi_device_table_entry *pentry,
pdev->dev.platform_data = pdata;
if (dev->delay)
intel_scu_ipc_device_register(pdev);
- else
- platform_device_add(pdev);
+ else {
+ ret = platform_device_add(pdev);
+ if (ret)
+ pr_warn("can't add device %s\n", pdev);
+ }
}
static void __init sfi_handle_spi_dev(struct sfi_device_table_entry *pentry,
--
2.17.1