From patchwork Tue May 14 16:52:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2567971 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 AC871E00E5 for ; Tue, 14 May 2013 16:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758338Ab3ENQyD (ORCPT ); Tue, 14 May 2013 12:54:03 -0400 Received: from mail-da0-f41.google.com ([209.85.210.41]:48594 "EHLO mail-da0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758329Ab3ENQx7 (ORCPT ); Tue, 14 May 2013 12:53:59 -0400 Received: by mail-da0-f41.google.com with SMTP id y19so421275dan.28 for ; Tue, 14 May 2013 09:53:58 -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=31x9Rw6Eso07q6E8J9DhAW5oo2o2GxAa2SubfjbZfEk=; b=lwXUyE7fRVi2ppHfdZH3nKanQOv66MB0JHVZF8CT7uiG+ARe6qEQzcPkdixqoX4glu W4wD5zUEXAxxBqB+9c4npPhCzNs6XgAOk5JEEIoteTaJqfn+4yq9do8BciLC0i4iTf3n 1/2zxKXZDvzZ5Ghr89/M7ErjxJa6jNFFcpVXQWUokzYZA3C82YTdglmmYWXG31sg4lAp GRDnByci1Hw/TXMiSF9hs8gtmY2M9m/eA/TsFXjybxame8uAUXlLJ6WSvNL8uAzoKXiU AaSuMw3gTV/wF/DCupiWIfvzXOypAGD4Il4m1ri9ICE5fv6dSG46AWsvawGW/NVIv76i 0BXw== X-Received: by 10.68.78.37 with SMTP id y5mr34626433pbw.28.1368550438682; Tue, 14 May 2013 09:53:58 -0700 (PDT) Received: from localhost.localdomain ([120.196.98.100]) by mx.google.com with ESMTPSA id v5sm18919924pbz.4.2013.05.14.09.53.53 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 May 2013 09:53:57 -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, Corentin Chary , Matthew Garrett , acpi4asus-user@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [RFC PATCH v2, part 2 18/18] PCI, asus-wmi: use hotplug-safe iterators to walk PCI buses Date: Wed, 15 May 2013 00:52:02 +0800 Message-Id: <1368550322-1045-18-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 asus-wmi drvier to use hotplug-safe iterators to walk PCI buses. Signed-off-by: Jiang Liu Cc: Corentin Chary Cc: Matthew Garrett Cc: acpi4asus-user@lists.sourceforge.net Cc: platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/platform/x86/asus-wmi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index c11b242..f92db4c 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -596,7 +596,7 @@ static bool asus_wlan_rfkill_blocked(struct asus_wmi *asus) static void asus_rfkill_hotplug(struct asus_wmi *asus) { struct pci_dev *dev; - struct pci_bus *bus; + struct pci_bus *bus = NULL; bool blocked; bool absent; u32 l; @@ -611,7 +611,7 @@ static void asus_rfkill_hotplug(struct asus_wmi *asus) rfkill_set_sw_state(asus->wlan.rfkill, blocked); if (asus->hotplug_slot) { - bus = pci_find_bus(0, 1); + bus = pci_get_bus(0, 1); if (!bus) { pr_warn("Unable to find PCI bus 1?\n"); goto out_unlock; @@ -657,6 +657,7 @@ static void asus_rfkill_hotplug(struct asus_wmi *asus) out_unlock: mutex_unlock(&asus->hotplug_lock); + pci_bus_put(bus); } static void asus_rfkill_notify(acpi_handle handle, u32 event, void *data) @@ -748,7 +749,7 @@ static void asus_hotplug_work(struct work_struct *work) static int asus_setup_pci_hotplug(struct asus_wmi *asus) { int ret = -ENOMEM; - struct pci_bus *bus = pci_find_bus(0, 1); + struct pci_bus *bus = pci_get_bus(0, 1); if (!bus) { pr_err("Unable to find wifi PCI bus\n"); @@ -782,6 +783,7 @@ static int asus_setup_pci_hotplug(struct asus_wmi *asus) pr_err("Unable to register hotplug slot - %d\n", ret); goto error_register; } + pci_bus_put(bus); return 0; @@ -793,6 +795,7 @@ error_info: error_slot: destroy_workqueue(asus->hotplug_workqueue); error_workqueue: + pci_bus_put(bus); return ret; }