From: Ladislav Michl <ladis@linux-mips.org>
To: Bjorn Helgaas <bhelgaas@google.com>,
Wei Yongjun <weiyongjun1@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
Dmitry Torokhov <dmitry.torokhov@gmail.com>
Subject: [PATCH 5/5] mtd: nand: davinci: Use devm_ioremap_shared_resource()
Date: Sun, 21 Jan 2018 22:17:01 +0100 [thread overview]
Message-ID: <20180121211701.GF15151@lenoch> (raw)
In-Reply-To: <20180121211432.GA15151@lenoch>
Simplify error handling by using devm_ioremap_shared_resource().
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
drivers/mtd/nand/davinci_nand.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index ccc8c43abcff..9b6f06b177b9 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -612,10 +612,8 @@ static int nand_davinci_probe(struct platform_device *pdev)
{
struct davinci_nand_pdata *pdata;
struct davinci_nand_info *info;
- struct resource *res1;
- struct resource *res2;
+ struct resource *res;
void __iomem *vaddr;
- void __iomem *base;
int ret;
uint32_t val;
struct mtd_info *mtd;
@@ -638,14 +636,8 @@ static int nand_davinci_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, info);
- res1 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (!res1 || !res2) {
- dev_err(&pdev->dev, "resource missing\n");
- return -EINVAL;
- }
-
- vaddr = devm_ioremap_resource(&pdev->dev, res1);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ vaddr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(vaddr))
return PTR_ERR(vaddr);
@@ -655,14 +647,12 @@ static int nand_davinci_probe(struct platform_device *pdev)
* by AEMIF, so we cannot request it twice, just ioremap.
* The AEMIF and NAND drivers not use the same registers in this range.
*/
- base = devm_ioremap(&pdev->dev, res2->start, resource_size(res2));
- if (!base) {
- dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res2);
- return -EADDRNOTAVAIL;
- }
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ info->base = devm_ioremap_shared_resource(&pdev->dev, res);
+ if (IS_ERR(info->base))
+ return PTR_ERR(info->base);
info->dev = &pdev->dev;
- info->base = base;
info->vaddr = vaddr;
mtd = nand_to_mtd(&info->chip);
--
2.15.1
prev parent reply other threads:[~2018-01-21 21:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-21 21:14 [RFC 0/5] Add managed ioremap function for shared resources Ladislav Michl
2018-01-21 21:15 ` [PATCH 1/5] devres: Move managed io function declarations into device.h Ladislav Michl
2018-01-22 9:30 ` kbuild test robot
2018-01-22 11:50 ` Ladislav Michl
2018-01-22 12:32 ` Linus Walleij
2018-01-22 10:08 ` kbuild test robot
2018-01-22 12:58 ` Ladislav Michl
2018-01-22 17:49 ` Dmitry Torokhov
2018-01-22 21:50 ` Ladislav Michl
2018-01-22 23:21 ` Dmitry Torokhov
2018-01-21 21:15 ` [PATCH 2/5] PCI: Move managed resource alloc to devres Ladislav Michl
2018-01-22 23:33 ` Dmitry Torokhov
2018-01-23 6:58 ` Ladislav Michl
2018-01-21 21:16 ` [PATCH 3/5] devres: Make devm_ioremap_release() static Ladislav Michl
2018-01-21 21:16 ` [PATCH 4/5] devres: Add devm_ioremap_shared_resource() Ladislav Michl
2018-01-21 21:17 ` Ladislav Michl [this message]
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=20180121211701.GF15151@lenoch \
--to=ladis@linux-mips.org \
--cc=bhelgaas@google.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=weiyongjun1@huawei.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;
as well as URLs for NNTP newsgroup(s).