mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arvind Yadav <arvind.yadav.cs@gmail.com>
To: gregkh@linuxfoundation.org, ganesanr@broadcom.com
Cc: nevola@gmail.com, julia.lawall@lip6.fr, brcnakalin@gmail.com,
	shraddha.6596@gmail.com, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, jchandra@broadcom.com,
	Arvind Yadav <arvind.yadav.cs@gmail.com>
Subject: [Patch v1] netlogic/platform_net: Catch failure to register NETLOGIC_XLR_NET device.
Date: Tue, 12 Jul 2016 00:10:21 +0530	[thread overview]
Message-ID: <1468262421-8719-1-git-send-email-arvind.yadav.cs@gmail.com> (raw)

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

                 reply	other threads:[~2016-07-12  3:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468262421-8719-1-git-send-email-arvind.yadav.cs@gmail.com \
    --to=arvind.yadav.cs@gmail.com \
    --cc=brcnakalin@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=ganesanr@broadcom.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jchandra@broadcom.com \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nevola@gmail.com \
    --cc=shraddha.6596@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®