From patchwork Tue May 14 16:51:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2567881 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 34A3AE00E6 for ; Tue, 14 May 2013 16:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756262Ab3ENQxn (ORCPT ); Tue, 14 May 2013 12:53:43 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:49323 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758263Ab3ENQxl (ORCPT ); Tue, 14 May 2013 12:53:41 -0400 Received: by mail-pa0-f47.google.com with SMTP id kl13so690046pab.34 for ; Tue, 14 May 2013 09:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=FO5lG7/Sh7ieCgjqp9J0wc08ZVHG5OEU3sNBwZZ9J6c=; b=P8ulhOssNsoUy81VUkxCt/tlYglto969KBBPirH7XVHfrd+mvn75KTqeIY4rxQbtxR BJQveUwUv2dd2vY8XPApmWREShQpMGhQNO2EBVou+7uJgx4BQXp/qvVGEzQqjbPbJ4f5 sKMis+RGBAsDrfFXYAbYX0ByqEnxVivAM41y2Zgnk4ryy27GJnwsCgFxHpxuicyUpy8n bMUlBhXqFCjerQKFk51q9R2pHpVryYHkFG2YUxu8ZDRW/wH6G7JK/+1VNPUUtLWY9wlL z0jMgixnle3UIrOjNXiwjcN3c8LY/cyigXXi866VxCFDMQpGY6Jz2xPfuGoyFpHCLScD bUCw== X-Received: by 10.66.248.163 with SMTP id yn3mr35288367pac.39.1368550420835; Tue, 14 May 2013 09:53:40 -0700 (PDT) Received: from localhost.localdomain ([120.196.98.100]) by mx.google.com with ESMTPSA id v5sm18919924pbz.4.2013.05.14.09.53.35 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 May 2013 09:53:39 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Yinghai Lu Cc: Jiang Liu , "Rafael J . Wysocki" , Greg Kroah-Hartman , Gu Zheng , Toshi Kani , Myron Stowe , Yijing Wang , Jiang Liu , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Daniel Drake , Jonathan Corbet , Javier Martin , linux-media@vger.kernel.org Subject: [RFC PATCH v2, part 2 15/18] PCI, via-camera: use hotplug-safe iterators to walk PCI buses Date: Wed, 15 May 2013 00:51:59 +0800 Message-Id: <1368550322-1045-15-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1368550322-1045-1-git-send-email-jiang.liu@huawei.com> References: <1368550322-1045-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Enhance via-camera drviers to use hotplug-safe iterators to walk PCI buses. Signed-off-by: Jiang Liu Cc: Mauro Carvalho Chehab Cc: Daniel Drake Cc: Jonathan Corbet Cc: Javier Martin 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 --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 = {