]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/misc/hdpuftrs/hdpu_nexus.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/shaggy...
[linux-2.6-omap-h63xx.git] / drivers / misc / hdpuftrs / hdpu_nexus.c
index 6a51e99a8079995adfb9183a0af21108eb0705ff..2fa36f7a6eb388ec02db087560ec3dca4c8b2d1d 100644 (file)
 #include <linux/kernel.h>
 #include <linux/proc_fs.h>
 #include <linux/hdpu_features.h>
-#include <linux/pci.h>
-
 #include <linux/platform_device.h>
+#include <linux/seq_file.h>
+#include <asm/io.h>
 
 static int hdpu_nexus_probe(struct platform_device *pdev);
 static int hdpu_nexus_remove(struct platform_device *pdev);
+static int hdpu_slot_id_open(struct inode *inode, struct file *file);
+static int hdpu_slot_id_read(struct seq_file *seq, void *offset);
+static int hdpu_chassis_id_open(struct inode *inode, struct file *file);
+static int hdpu_chassis_id_read(struct seq_file *seq, void *offset);
 
 static struct proc_dir_entry *hdpu_slot_id;
 static struct proc_dir_entry *hdpu_chassis_id;
 static int slot_id = -1;
 static int chassis_id = -1;
 
+static const struct file_operations proc_slot_id = {
+       .open = hdpu_slot_id_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+       .owner = THIS_MODULE,
+};
+
+static const struct file_operations proc_chassis_id = {
+       .open = hdpu_chassis_id_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+       .owner = THIS_MODULE,
+};
+
 static struct platform_driver hdpu_nexus_driver = {
        .probe = hdpu_nexus_probe,
        .remove = hdpu_nexus_remove,
        .driver = {
                .name = HDPU_NEXUS_NAME,
+               .owner = THIS_MODULE,
        },
 };
 
-int hdpu_slot_id_read(char *buffer, char **buffer_location, off_t offset,
-                     int buffer_length, int *zero, void *ptr)
+static int hdpu_slot_id_open(struct inode *inode, struct file *file)
 {
+       return single_open(file, hdpu_slot_id_read, NULL);
+}
 
-       if (offset > 0)
-               return 0;
-       return sprintf(buffer, "%d\n", slot_id);
+static int hdpu_slot_id_read(struct seq_file *seq, void *offset)
+{
+       seq_printf(seq, "%d\n", slot_id);
+       return 0;
 }
 
-int hdpu_chassis_id_read(char *buffer, char **buffer_location, off_t offset,
-                        int buffer_length, int *zero, void *ptr)
+static int hdpu_chassis_id_open(struct inode *inode, struct file *file)
 {
+       return single_open(file, hdpu_chassis_id_read, NULL);
+}
 
-       if (offset > 0)
-               return 0;
-       return sprintf(buffer, "%d\n", chassis_id);
+static int hdpu_chassis_id_read(struct seq_file *seq, void *offset)
+{
+       seq_printf(seq, "%d\n", chassis_id);
+       return 0;
 }
 
 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;
+       if (!hdpu_slot_id) {
+               printk(KERN_WARNING "sky_nexus: "
+                      "Unable to create proc dir entry: sky_slot_id\n");
+       } else {
+               hdpu_slot_id->proc_fops = &proc_slot_id;
+               hdpu_slot_id->owner = THIS_MODULE;
+       }
 
        hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, &proc_root);
-       hdpu_chassis_id->read_proc = hdpu_chassis_id_read;
+       if (!hdpu_chassis_id) {
+               printk(KERN_WARNING "sky_nexus: "
+                      "Unable to create proc dir entry: sky_chassis_id\n");
+       } else {
+               hdpu_chassis_id->proc_fops = &proc_chassis_id;
+               hdpu_chassis_id->owner = THIS_MODULE;
+       }
+
        return 0;
 }
 
@@ -82,18 +127,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)
@@ -106,3 +152,4 @@ module_exit(nexus_exit);
 
 MODULE_AUTHOR("Brian Waite");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:" HDPU_NEXUS_NAME);