All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch v1] netlogic/platform_net: Catch failure to register NETLOGIC_XLR_NET device.
@ 2016-07-11 18:40 Arvind Yadav
  0 siblings, 0 replies; only message in thread
From: Arvind Yadav @ 2016-07-11 18:40 UTC (permalink / raw)
  To: gregkh, ganesanr
  Cc: nevola, julia.lawall, brcnakalin, shraddha.6596, devel,
	linux-kernel, jchandra, Arvind Yadav

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@gmail.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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-07-12  3:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-11 18:40 [Patch v1] netlogic/platform_net: Catch failure to register NETLOGIC_XLR_NET device Arvind Yadav

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.