[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1468262421-8719-1-git-send-email-arvind.yadav.cs@gmail.com>
Date: Tue, 12 Jul 2016 00:10:21 +0530
From: Arvind Yadav <arvind.yadav.cs@...il.com>
To: gregkh@...uxfoundation.org, ganesanr@...adcom.com
Cc: nevola@...il.com, julia.lawall@...6.fr, brcnakalin@...il.com,
shraddha.6596@...il.com, devel@...verdev.osuosl.org,
linux-kernel@...r.kernel.org, jchandra@...adcom.com,
Arvind Yadav <arvind.yadav.cs@...il.com>
Subject: [Patch v1] netlogic/platform_net: Catch failure to register NETLOGIC_XLR_NET device.
This driver Kconfig is depend on CPU_XLR. If default Kconfig
NETLOGIC_XLR_NET value are used with CPU_XLR then you end up
with a resource. This causes __request_resource to return a
conflict which then returns an -EBUSY error code. The driver
netlogic/platform_net.c assumes that the platfom_device_register
will always succeed.
Catch this failure during xlr_net_init. Driver should not ignore
return value of platform_device_register.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
---
drivers/staging/netlogic/platform_net.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/netlogic/platform_net.c b/drivers/staging/netlogic/platform_net.c
index abf4c71..d8ce50d 100644
--- a/drivers/staging/netlogic/platform_net.c
+++ b/drivers/staging/netlogic/platform_net.c
@@ -130,9 +130,10 @@ static struct platform_device *gmac_controller2_init(void *gmac0_addr)
return &xlr_net_dev1;
}
-static void xls_gmac_init(void)
+static int xls_gmac_init(void)
{
int mac;
+ int ret;
struct platform_device *xlr_net_dev1;
void __iomem *gmac0_addr = ioremap(CPHYSADDR(
nlm_mmio_base(NETLOGIC_IO_GMAC_0_OFFSET)), 0xfff);
@@ -171,7 +172,7 @@ static void xls_gmac_init(void)
xlr_resource_init(&xlr_net0_res[0], xlr_gmac_offsets[0],
xlr_gmac_irqs[0]);
- platform_device_register(&xlr_net_dev0);
+ ret = platform_device_register(&xlr_net_dev0);
/* second block is XAUI, not supported yet */
break;
@@ -187,14 +188,20 @@ static void xls_gmac_init(void)
xlr_gmac_irqs[mac]);
}
xlr_net_dev0.num_resources = 8;
- platform_device_register(&xlr_net_dev0);
+ ret = platform_device_register(&xlr_net_dev0);
xlr_net_dev1 = gmac_controller2_init(gmac0_addr);
- platform_device_register(xlr_net_dev1);
+ if (ret == 0) {
+ ret = platform_device_register(xlr_net_dev1);
+ if (ret)
+ platform_driver_unregister(&xlr_net_dev0);
+ }
+
}
+ return ret;
}
-static void xlr_gmac_init(void)
+static int xlr_gmac_init(void)
{
int mac;
@@ -228,17 +235,18 @@ static void xlr_gmac_init(void)
xlr_net_dev0.num_resources = 8;
xlr_net_dev0.resource = xlr_net0_res;
- platform_device_register(&xlr_net_dev0);
+ return platform_device_register(&xlr_net_dev0);
}
static int __init xlr_net_init(void)
{
+ int ret;
if (nlm_chip_is_xls())
- xls_gmac_init();
+ ret = xls_gmac_init();
else
- xlr_gmac_init();
+ ret = xlr_gmac_init();
- return 0;
+ return ret;
}
arch_initcall(xlr_net_init);
--
1.9.1
Powered by blists - more mailing lists