staging/rts_pstor: remove braces {} in rtsx_transport.c
[linux-2.6.git] / drivers / pci / hotplug / shpchp_pci.c
blobc627ed9957d1c32fc1768b6a7e51e5cf18a9cb6f
1 /*
2 * Standard Hot Plug Controller Driver
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
9 * All rights reserved.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
20 * details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
30 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/types.h>
33 #include <linux/pci.h>
34 #include "../pci.h"
35 #include "shpchp.h"
37 int __ref shpchp_configure_device(struct slot *p_slot)
39 struct pci_dev *dev;
40 struct controller *ctrl = p_slot->ctrl;
41 struct pci_dev *bridge = ctrl->pci_dev;
42 struct pci_bus *parent = bridge->subordinate;
43 int num, fn;
45 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0));
46 if (dev) {
47 ctrl_err(ctrl, "Device %s already exists "
48 "at %04x:%02x:%02x, cannot hot-add\n", pci_name(dev),
49 pci_domain_nr(parent), p_slot->bus, p_slot->device);
50 pci_dev_put(dev);
51 return -EINVAL;
54 num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0));
55 if (num == 0) {
56 ctrl_err(ctrl, "No new device found\n");
57 return -ENODEV;
60 for (fn = 0; fn < 8; fn++) {
61 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn));
62 if (!dev)
63 continue;
64 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
65 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
66 pci_hp_add_bridge(dev);
67 pci_dev_put(dev);
70 pci_assign_unassigned_bridge_resources(bridge);
72 for (fn = 0; fn < 8; fn++) {
73 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn));
74 if (!dev)
75 continue;
76 pci_configure_slot(dev);
77 pci_dev_put(dev);
80 pci_bus_add_devices(parent);
82 return 0;
85 int shpchp_unconfigure_device(struct slot *p_slot)
87 int rc = 0;
88 int j;
89 u8 bctl = 0;
90 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
91 struct controller *ctrl = p_slot->ctrl;
93 ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:%02x\n",
94 __func__, pci_domain_nr(parent), p_slot->bus, p_slot->device);
96 for (j = 0; j < 8 ; j++) {
97 struct pci_dev *temp = pci_get_slot(parent,
98 (p_slot->device << 3) | j);
99 if (!temp)
100 continue;
101 if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
102 pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl);
103 if (bctl & PCI_BRIDGE_CTL_VGA) {
104 ctrl_err(ctrl,
105 "Cannot remove display device %s\n",
106 pci_name(temp));
107 pci_dev_put(temp);
108 rc = -EINVAL;
109 break;
112 pci_stop_and_remove_bus_device(temp);
113 pci_dev_put(temp);
115 return rc;