Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / sparc64 / kernel / ebus.c
index 044b858..c69504a 100644 (file)
@@ -267,7 +267,7 @@ void ebus_dma_enable(struct ebus_dma_info *p, int on)
 }
 EXPORT_SYMBOL(ebus_dma_enable);
 
-struct linux_ebus *ebus_chain = 0;
+struct linux_ebus *ebus_chain = NULL;
 
 #ifdef CONFIG_SUN_AUXIO
 extern void auxio_probe(void);
@@ -277,10 +277,9 @@ static inline void *ebus_alloc(size_t size)
 {
        void *mem;
 
-       mem = kmalloc(size, GFP_ATOMIC);
+       mem = kzalloc(size, GFP_ATOMIC);
        if (!mem)
                panic("ebus_alloc: out of memory");
-       memset((char *)mem, 0, size);
        return mem;
 }
 
@@ -503,7 +502,7 @@ probe_interrupts:
                dev->children = ebus_alloc(sizeof(struct linux_ebus_child));
 
                child = dev->children;
-               child->next = 0;
+               child->next = NULL;
                child->parent = dev;
                child->bus = dev->bus;
                fill_ebus_child(node, &regs[0],
@@ -513,7 +512,7 @@ probe_interrupts:
                        child->next = ebus_alloc(sizeof(struct linux_ebus_child));
 
                        child = child->next;
-                       child->next = 0;
+                       child->next = NULL;
                        child->parent = dev;
                        child->bus = dev->bus;
                        fill_ebus_child(node, &regs[0],
@@ -527,18 +526,12 @@ static struct pci_dev *find_next_ebus(struct pci_dev *start, int *is_rio_p)
 {
        struct pci_dev *pdev = start;
 
-       do {
-               pdev = pci_find_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev);
-               if (pdev &&
-                   (pdev->device == PCI_DEVICE_ID_SUN_EBUS ||
-                    pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS))
+       while ((pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev)))
+               if (pdev->device == PCI_DEVICE_ID_SUN_EBUS ||
+                       pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS)
                        break;
-       } while (pdev != NULL);
 
-       if (pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS))
-               *is_rio_p = 1;
-       else
-               *is_rio_p = 0;
+       *is_rio_p = !!(pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS));
 
        return pdev;
 }
@@ -563,7 +556,7 @@ void __init ebus_init(void)
        ebusnd = cookie->prom_node;
 
        ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus));
-       ebus->next = 0;
+       ebus->next = NULL;
        ebus->is_rio = is_rio;
 
        while (ebusnd) {
@@ -606,8 +599,8 @@ void __init ebus_init(void)
                ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device));
 
                dev = ebus->devices;
-               dev->next = 0;
-               dev->children = 0;
+               dev->next = NULL;
+               dev->children = NULL;
                dev->bus = ebus;
                fill_ebus_device(nd, dev);
 
@@ -615,8 +608,8 @@ void __init ebus_init(void)
                        dev->next = ebus_alloc(sizeof(struct linux_ebus_device));
 
                        dev = dev->next;
-                       dev->next = 0;
-                       dev->children = 0;
+                       dev->next = NULL;
+                       dev->children = NULL;
                        dev->bus = ebus;
                        fill_ebus_device(nd, dev);
                }
@@ -633,10 +626,11 @@ void __init ebus_init(void)
 
                ebus->next = ebus_alloc(sizeof(struct linux_ebus));
                ebus = ebus->next;
-               ebus->next = 0;
+               ebus->next = NULL;
                ebus->is_rio = is_rio;
                ++num_ebus;
        }
+       pci_dev_put(pdev); /* XXX for the case, when ebusnd is 0, is it OK? */
 
 #ifdef CONFIG_SUN_AUXIO
        auxio_probe();