From: Jiri Slaby <[email-masked]>

Signed-off-by: Jiri Slaby <[email-masked]>
Cc: Greg KH <[email-masked]>
Signed-off-by: Andrew Morton <[email-masked]>
---

 arch/sparc64/kernel/ebus.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff -puN arch/sparc64/kernel/ebus.c~arch-pci_find_device-remove-sparc64-kernel-ebusc arch/sparc64/kernel/ebus.c
--- devel/arch/sparc64/kernel/ebus.c~arch-pci_find_device-remove-sparc64-kernel-ebusc	2005-09-09 23:04:49.000000000 -0700
+++ devel-akpm/arch/sparc64/kernel/ebus.c	2005-09-09 23:04:53.000000000 -0700
@@ -527,18 +527,12 @@ static struct pci_dev *find_next_ebus(st
 {
 	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;
 }
@@ -637,6 +631,7 @@ void __init ebus_init(void)
 		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();
_