linux-mips
[Top] [All Lists]

Re: [PATCH 2/4] MIPS: lantiq: adds minimal dcdc driver

To: Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH 2/4] MIPS: lantiq: adds minimal dcdc driver
From: Lars-Peter Clausen <lars@metafoo.de>
Date: Thu, 08 Aug 2013 13:50:01 +0200
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>, John Crispin <blogic@openwrt.org>, Ralf Baechle <ralf@linux-mips.org>, Linux-MIPS <linux-mips@linux-mips.org>
In-reply-to: <CAGVrzcY8NAu0BZBNXVC-sJk7_=40GmepG30ff4+wJQPr4A8J6w@mail.gmail.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1375952846-25812-1-git-send-email-blogic@openwrt.org> <1375952846-25812-2-git-send-email-blogic@openwrt.org> <520379D4.9040903@cogentembedded.com> <CAGVrzcY8NAu0BZBNXVC-sJk7_=40GmepG30ff4+wJQPr4A8J6w@mail.gmail.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130704 Icedove/17.0.7
On 08/08/2013 01:17 PM, Florian Fainelli wrote:
2013/8/8 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>:
Hello.


On 08-08-2013 13:07, John Crispin wrote:

This driver so far only reads the core voltage.


Signed-off-by: John Crispin <blogic@openwrt.org>

[...]


diff --git a/arch/mips/lantiq/xway/dcdc.c b/arch/mips/lantiq/xway/dcdc.c
new file mode 100644
index 0000000..6361c30
--- /dev/null
+++ b/arch/mips/lantiq/xway/dcdc.c
@@ -0,0 +1,75 @@

[...]

+static int dcdc_probe(struct platform_device *pdev)
+{
+       struct resource *res;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res) {
+               dev_err(&pdev->dev, "Failed to get resource\n");
+               return -ENOMEM;
+       }


    You do not need to check this with devm_request_and_ioremap() or
devm_ioremap_resource().


+
+       /* remap dcdc register range */
+       dcdc_membase = devm_request_and_ioremap(&pdev->dev, res);


    Use devm_ioremap_resource().


+       if (!dcdc_membase) {
+               dev_err(&pdev->dev, "Failed to remap resource\n");


    Error messages are already printed by devm_request_and_ioremap()
ordevm_ioremap_resource().

+               return -ENOMEM;


    -EADDRNOTAVAIL is the right code for devm_request_and_ioremap().

This is the first time that I read this, lib/devres.c internal returns
-ENOMEM when an ioremap() call fails (see devm_ioremap_resource),
-EADDRNOTAVAIL really is for networking matter, this is not.


You shouldn't need worry about the return code in this case anyway. This is the correct pattern for situations like this:

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(base))
        return PTR_ERR(base);

- Lars

<Prev in Thread] Current Thread [Next in Thread>