From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 01/10] ata: platform_ide: cleanup resource requesting
Date: Fri, 12 Sep 2014 12:13:41 +0200 [thread overview]
Message-ID: <1410516830-9403-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1410516830-9403-1-git-send-email-s.hauer@pengutronix.de>
- use dev_request_mem_region to simplify code
- check return values and bail out
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/ata/intf_platform_ide.c | 47 +++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 25 deletions(-)
diff --git a/drivers/ata/intf_platform_ide.c b/drivers/ata/intf_platform_ide.c
index ecc2546..b3faf47 100644
--- a/drivers/ata/intf_platform_ide.c
+++ b/drivers/ata/intf_platform_ide.c
@@ -81,7 +81,7 @@ static int platform_ide_probe(struct device_d *dev)
int rc;
struct ide_port_info *pdata = dev->platform_data;
struct ide_port *ide;
- void *reg_base, *alt_base;
+ void *reg_base, *alt_base = NULL;
struct resource *reg, *alt;
int mmio;
@@ -90,35 +90,32 @@ static int platform_ide_probe(struct device_d *dev)
return -EINVAL;
}
- alt = NULL;
- reg = dev_get_resource(dev, IORESOURCE_MEM, 0);
- mmio = (reg != NULL);
- if (reg != NULL) {
- reg = request_iomem_region(dev_name(dev), reg->start,
- reg->end);
- alt = dev_get_resource(dev, IORESOURCE_MEM, 1);
- if (alt != NULL)
- alt = request_iomem_region(dev_name(dev), alt->start,
- alt->end);
+ reg_base = dev_request_mem_region(dev, 0);
+ mmio = (reg_base != NULL);
+ if (mmio) {
+ alt_base = dev_request_mem_region(dev, 1);
} else {
reg = dev_get_resource(dev, IORESOURCE_IO, 0);
- if (reg != NULL) {
- reg = request_ioport_region(dev_name(dev), reg->start,
- reg->end);
- alt = dev_get_resource(dev, IORESOURCE_IO, 1);
- if (alt != NULL)
- alt = request_ioport_region(dev_name(dev),
- alt->start,
- alt->end);
+ if (!reg)
+ return -ENODEV;
+
+ reg = request_ioport_region(dev_name(dev), reg->start,
+ reg->end);
+ if (!reg)
+ return -ENODEV;
+
+ reg_base = (void __force __iomem *) reg->start;
+
+ alt = dev_get_resource(dev, IORESOURCE_IO, 1);
+ if (alt) {
+ alt = request_ioport_region(dev_name(dev),
+ alt->start,
+ alt->end);
+ if (!alt)
+ return -ENODEV;
}
}
- reg_base = (reg != NULL ? (void __force __iomem *) reg->start : NULL);
- alt_base = (alt != NULL ? (void __force __iomem *) alt->start : NULL);
-
- if (!reg_base)
- return -ENODEV;
-
ide = xzalloc(sizeof(*ide));
ide->io.mmio = mmio;
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-09-12 10:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-12 10:13 Return error pointers from resource handling functions Sascha Hauer
2014-09-12 10:13 ` Sascha Hauer [this message]
2014-09-12 10:13 ` [PATCH 02/10] resource: Let dev_get_resource_by_name return an error pointer Sascha Hauer
2014-09-12 10:13 ` [PATCH 03/10] resource: Let dev_get_mem_region_by_name " Sascha Hauer
2014-09-12 10:13 ` [PATCH 04/10] resource: Let __request_region " Sascha Hauer
2014-09-12 10:13 ` [PATCH 05/10] resource: Let request_iomem_region " Sascha Hauer
2014-09-12 10:13 ` [PATCH 06/10] resource: Let dev_get_resource " Sascha Hauer
2014-09-12 10:13 ` [PATCH 07/10] resource: Let dev_get_mem_region " Sascha Hauer
2014-09-12 15:20 ` Sebastian Hesselbarth
2014-09-12 10:13 ` [PATCH 08/10] resource: Let dev_request_mem_region_by_name " Sascha Hauer
2014-09-12 10:13 ` [PATCH 09/10] resource: Let dev_request_mem_region " Sascha Hauer
2014-09-12 11:48 ` Baruch Siach
2014-09-15 5:21 ` Sascha Hauer
2014-09-12 10:13 ` [PATCH 10/10] resource: Let request_ioport_region " Sascha Hauer
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=1410516830-9403-2-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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