On 08/08/2013 01:17 PM, Florian Fainelli wrote:
2013/8/8 Sergei Shtylyov <sergei.shtylyov@xxxxxxxxxxxxxxxxxx>:
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@xxxxxxxxxxx>
[...]
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