Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
[pandora-kernel.git] / arch / parisc / kernel / drivers.c
index d016d67..2ca654b 100644 (file)
@@ -39,7 +39,7 @@
 #include <asm/parisc-device.h>
 
 /* See comments in include/asm-parisc/pci.h */
-struct hppa_dma_ops *hppa_dma_ops;
+struct hppa_dma_ops *hppa_dma_ops __read_mostly;
 EXPORT_SYMBOL(hppa_dma_ops);
 
 static struct device root = {
@@ -173,8 +173,6 @@ int register_parisc_driver(struct parisc_driver *driver)
        WARN_ON(driver->drv.probe != NULL);
        WARN_ON(driver->drv.remove != NULL);
 
-       driver->drv.probe = parisc_driver_probe;
-       driver->drv.remove = parisc_driver_remove;
        driver->drv.name = driver->name;
 
        return driver_register(&driver->drv);
@@ -410,11 +408,10 @@ static void setup_bus_id(struct parisc_device *padev)
 
 struct parisc_device * create_tree_node(char id, struct device *parent)
 {
-       struct parisc_device *dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+       struct parisc_device *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev)
                return NULL;
 
-       memset(dev, 0, sizeof(*dev));
        dev->hw_path = id;
        dev->id.hw_type = HPHW_FAULTY;
 
@@ -427,7 +424,10 @@ struct parisc_device * create_tree_node(char id, struct device *parent)
        /* make the generic dma mask a pointer to the parisc one */
        dev->dev.dma_mask = &dev->dma_mask;
        dev->dev.coherent_dma_mask = dev->dma_mask;
-       device_register(&dev->dev);
+       if (device_register(&dev->dev)) {
+               kfree(dev);
+               return NULL;
+       }
 
        return dev;
 }
@@ -515,8 +515,13 @@ alloc_pa_dev(unsigned long hpa, struct hardware_path *mod_path)
                        (iodc_data[5] << 8) | iodc_data[6];
        dev->hpa.name = parisc_pathname(dev);
        dev->hpa.start = hpa;
-       if (hpa == 0xf4000000 || hpa == 0xf6000000 ||
-           hpa == 0xf8000000 || hpa == 0xfa000000) {
+       /* This is awkward.  The STI spec says that gfx devices may occupy
+        * 32MB or 64MB.  Unfortunately, we don't know how to tell whether
+        * it's the former or the latter.  Assumptions either way can hurt us.
+        */
+       if (hpa == 0xf4000000 || hpa == 0xf8000000) {
+               dev->hpa.end = hpa + 0x03ffffff;
+       } else if (hpa == 0xf6000000 || hpa == 0xfa000000) {
                dev->hpa.end = hpa + 0x01ffffff;
        } else {
                dev->hpa.end = hpa + 0xfff;
@@ -557,12 +562,23 @@ pa_dev_attr(rev, id.hversion_rev, "0x%x\n");
 pa_dev_attr_id(hversion, "0x%03x\n");
 pa_dev_attr_id(sversion, "0x%05x\n");
 
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct parisc_device *padev = to_parisc_device(dev);
+       struct parisc_device_id *id = &padev->id;
+
+       return sprintf(buf, "parisc:t%02Xhv%04Xrev%02Xsv%08X\n",
+               (u8)id->hw_type, (u16)id->hversion, (u8)id->hversion_rev,
+               (u32)id->sversion);
+}
+
 static struct device_attribute parisc_device_attrs[] = {
        __ATTR_RO(irq),
        __ATTR_RO(hw_type),
        __ATTR_RO(rev),
        __ATTR_RO(hversion),
        __ATTR_RO(sversion),
+       __ATTR_RO(modalias),
        __ATTR_NULL,
 };
 
@@ -570,6 +586,8 @@ struct bus_type parisc_bus_type = {
        .name = "parisc",
        .match = parisc_generic_match,
        .dev_attrs = parisc_device_attrs,
+       .probe = parisc_driver_probe,
+       .remove = parisc_driver_remove,
 };
 
 /**
@@ -682,7 +700,9 @@ parse_tree_node(struct device *parent, int index, struct hardware_path *modpath)
                .fn     = check_parent,
        };
 
-       device_for_each_child(parent, &recurse_data, descend_children);
+       if (device_for_each_child(parent, &recurse_data, descend_children))
+               /* nothing */;
+
        return d.dev;
 }
 
@@ -828,13 +848,13 @@ static void print_parisc_device(struct parisc_device *dev)
        static int count;
 
        print_pa_hwpath(dev, hw_path);
-       printk(KERN_INFO "%d. %s at 0x%lx [%s] { %d, 0x%x, 0x%.3x, 0x%.5x }",
-               ++count, dev->name, dev->hpa.start, hw_path, dev->id.hw_type,
+       printk(KERN_INFO "%d. %s at 0x%p [%s] { %d, 0x%x, 0x%.3x, 0x%.5x }",
+               ++count, dev->name, (void*) dev->hpa.start, hw_path, dev->id.hw_type,
                dev->id.hversion_rev, dev->id.hversion, dev->id.sversion);
 
        if (dev->num_addrs) {
                int k;
-               printk(",  additional addresses: ");
+               printk(", additional addresses: ");
                for (k = 0; k < dev->num_addrs; k++)
                        printk("0x%lx ", dev->addr[k]);
        }
@@ -846,8 +866,10 @@ static void print_parisc_device(struct parisc_device *dev)
  */
 void init_parisc_bus(void)
 {
-       bus_register(&parisc_bus_type);
-       device_register(&root);
+       if (bus_register(&parisc_bus_type))
+               panic("Could not register PA-RISC bus type\n");
+       if (device_register(&root))
+               panic("Could not register PA-RISC root device\n");
        get_device(&root);
 }