]> Pileus Git - ~andy/linux/blobdiff - drivers/misc/hdpuftrs/hdpu_nexus.c
[POWERPC] Sky Cpu and Nexus: check for platform_get_resource retcode
[~andy/linux] / drivers / misc / hdpuftrs / hdpu_nexus.c
index 6a51e99a8079995adfb9183a0af21108eb0705ff..01bc9179603be92e39afdb3473225a46e172afd6 100644 (file)
@@ -18,9 +18,9 @@
 #include <linux/kernel.h>
 #include <linux/proc_fs.h>
 #include <linux/hdpu_features.h>
-#include <linux/pci.h>
 
 #include <linux/platform_device.h>
+#include <asm/io.h>
 
 static int hdpu_nexus_probe(struct platform_device *pdev);
 static int hdpu_nexus_remove(struct platform_device *pdev);
@@ -41,40 +41,48 @@ static struct platform_driver hdpu_nexus_driver = {
 int hdpu_slot_id_read(char *buffer, char **buffer_location, off_t offset,
                      int buffer_length, int *zero, void *ptr)
 {
-
        if (offset > 0)
                return 0;
+
        return sprintf(buffer, "%d\n", slot_id);
 }
 
 int hdpu_chassis_id_read(char *buffer, char **buffer_location, off_t offset,
                         int buffer_length, int *zero, void *ptr)
 {
-
        if (offset > 0)
                return 0;
+
        return sprintf(buffer, "%d\n", chassis_id);
 }
 
 static int hdpu_nexus_probe(struct platform_device *pdev)
 {
        struct resource *res;
+       int *nexus_id_addr;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       int *nexus_id_addr;
-       nexus_id_addr =
-           ioremap(res->start, (unsigned long)(res->end - res->start));
+       if (!res) {
+               printk(KERN_ERR "sky_nexus: "
+                      "Invalid memory resource.\n");
+               return -EINVAL;
+       }
+       nexus_id_addr = ioremap(res->start,
+                               (unsigned long)(res->end - res->start));
        if (nexus_id_addr) {
                slot_id = (*nexus_id_addr >> 8) & 0x1f;
                chassis_id = *nexus_id_addr & 0xff;
                iounmap(nexus_id_addr);
-       } else
-               printk("Could not map slot id\n");
+       } else {
+               printk(KERN_ERR "sky_nexus: Could not map slot id\n");
+       }
+
        hdpu_slot_id = create_proc_entry("sky_slot_id", 0666, &proc_root);
        hdpu_slot_id->read_proc = hdpu_slot_id_read;
 
        hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, &proc_root);
        hdpu_chassis_id->read_proc = hdpu_chassis_id_read;
+
        return 0;
 }
 
@@ -82,18 +90,19 @@ static int hdpu_nexus_remove(struct platform_device *pdev)
 {
        slot_id = -1;
        chassis_id = -1;
+
        remove_proc_entry("sky_slot_id", &proc_root);
        remove_proc_entry("sky_chassis_id", &proc_root);
+
        hdpu_slot_id = 0;
        hdpu_chassis_id = 0;
+
        return 0;
 }
 
 static int __init nexus_init(void)
 {
-       int rc;
-       rc = platform_driver_register(&hdpu_nexus_driver);
-       return rc;
+       return platform_driver_register(&hdpu_nexus_driver);
 }
 
 static void __exit nexus_exit(void)