diff mbox

[RFC,v2,part,2,15/18] PCI, via-camera: use hotplug-safe iterators to walk PCI buses

Message ID 1368550322-1045-15-git-send-email-jiang.liu@huawei.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Jiang Liu May 14, 2013, 4:51 p.m. UTC
Enhance via-camera drviers to use hotplug-safe iterators to walk
PCI buses.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Daniel Drake <dsd@laptop.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Javier Martin <javier.martin@vista-silicon.com>
Cc: linux-media@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/media/platform/via-camera.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/drivers/media/platform/via-camera.c b/drivers/media/platform/via-camera.c
index b051c4a..ef10136 100644
--- a/drivers/media/platform/via-camera.c
+++ b/drivers/media/platform/via-camera.c
@@ -1284,7 +1284,8 @@  static struct video_device viacam_v4l_template = {
 
 static bool viacam_serial_is_enabled(void)
 {
-	struct pci_bus *pbus = pci_find_bus(0, 0);
+	struct pci_bus *pbus = pci_get_bus(0, 0);
+	bool ret = false;
 	u8 cbyte;
 
 	if (!pbus)
@@ -1292,18 +1293,21 @@  static bool viacam_serial_is_enabled(void)
 	pci_bus_read_config_byte(pbus, VIACAM_SERIAL_DEVFN,
 			VIACAM_SERIAL_CREG, &cbyte);
 	if ((cbyte & VIACAM_SERIAL_BIT) == 0)
-		return false; /* Not enabled */
+		goto out; /* Not enabled */
 	if (override_serial == 0) {
 		printk(KERN_NOTICE "Via camera: serial port is enabled, " \
 				"refusing to load.\n");
 		printk(KERN_NOTICE "Specify override_serial=1 to force " \
 				"module loading.\n");
-		return true;
+		ret = true;
+		goto out;
 	}
 	printk(KERN_NOTICE "Via camera: overriding serial port\n");
 	pci_bus_write_config_byte(pbus, VIACAM_SERIAL_DEVFN,
 			VIACAM_SERIAL_CREG, cbyte & ~VIACAM_SERIAL_BIT);
-	return false;
+out:
+	pci_bus_put(pbus);
+	return ret;
 }
 
 static struct ov7670_config sensor_cfg = {