PCI: Merge multi-line quoted strings
[deliverable/linux.git] / drivers / pci / hotplug / shpchp_pci.c
CommitLineData
1da177e4
LT
1/*
2 * Standard Hot Plug Controller Driver
3 *
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
8 *
9 * All rights reserved.
10 *
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.
15 *
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.
21 *
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.
25 *
8cf4c195 26 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
1da177e4
LT
27 *
28 */
29
1da177e4
LT
30#include <linux/module.h>
31#include <linux/kernel.h>
32#include <linux/types.h>
1da177e4
LT
33#include <linux/pci.h>
34#include "../pci.h"
35#include "shpchp.h"
1da177e4 36
10874f5a 37int shpchp_configure_device(struct slot *p_slot)
1da177e4 38{
dbd7a788 39 struct pci_dev *dev;
f98ca311 40 struct controller *ctrl = p_slot->ctrl;
7d01f70a
YL
41 struct pci_dev *bridge = ctrl->pci_dev;
42 struct pci_bus *parent = bridge->subordinate;
c4ec84c7
RW
43 int num, ret = 0;
44
45 pci_lock_rescan_remove();
dbd7a788 46
e00e57ef 47 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0));
dbd7a788 48 if (dev) {
227f0647
RD
49 ctrl_err(ctrl, "Device %s already exists at %04x:%02x:%02x, cannot hot-add\n",
50 pci_name(dev), pci_domain_nr(parent),
51 p_slot->bus, p_slot->device);
e00e57ef 52 pci_dev_put(dev);
c4ec84c7
RW
53 ret = -EINVAL;
54 goto out;
1da177e4
LT
55 }
56
dbd7a788 57 num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0));
58 if (num == 0) {
f98ca311 59 ctrl_err(ctrl, "No new device found\n");
c4ec84c7
RW
60 ret = -ENODEV;
61 goto out;
dbd7a788 62 }
1da177e4 63
fcbed0bc
YW
64 list_for_each_entry(dev, &parent->devices, bus_list) {
65 if (PCI_SLOT(dev->devfn) != p_slot->device)
dbd7a788 66 continue;
087cfa93 67 if (pci_is_bridge(dev))
7d01f70a 68 pci_hp_add_bridge(dev);
7d01f70a
YL
69 }
70
71 pci_assign_unassigned_bridge_resources(bridge);
72
fcbed0bc
YW
73 list_for_each_entry(dev, &parent->devices, bus_list) {
74 if (PCI_SLOT(dev->devfn) != p_slot->device)
7d01f70a 75 continue;
11876e52 76 pci_configure_slot(dev);
1da177e4
LT
77 }
78
dbd7a788 79 pci_bus_add_devices(parent);
7d01f70a 80
c4ec84c7
RW
81 out:
82 pci_unlock_rescan_remove();
83 return ret;
1da177e4
LT
84}
85
2178bfad 86int shpchp_unconfigure_device(struct slot *p_slot)
1da177e4
LT
87{
88 int rc = 0;
2178bfad 89 u8 bctl = 0;
e00e57ef 90 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
fcbed0bc 91 struct pci_dev *dev, *temp;
f98ca311 92 struct controller *ctrl = p_slot->ctrl;
e00e57ef 93
be7bce25
TI
94 ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:%02x\n",
95 __func__, pci_domain_nr(parent), p_slot->bus, p_slot->device);
1da177e4 96
c4ec84c7
RW
97 pci_lock_rescan_remove();
98
fcbed0bc
YW
99 list_for_each_entry_safe(dev, temp, &parent->devices, bus_list) {
100 if (PCI_SLOT(dev->devfn) != p_slot->device)
2178bfad 101 continue;
fcbed0bc
YW
102
103 pci_dev_get(dev);
104 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
105 pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl);
2178bfad 106 if (bctl & PCI_BRIDGE_CTL_VGA) {
f98ca311
TI
107 ctrl_err(ctrl,
108 "Cannot remove display device %s\n",
fcbed0bc
YW
109 pci_name(dev));
110 pci_dev_put(dev);
0ba10bc7
PK
111 rc = -EINVAL;
112 break;
2178bfad 113 }
1da177e4 114 }
fcbed0bc
YW
115 pci_stop_and_remove_bus_device(dev);
116 pci_dev_put(dev);
1da177e4 117 }
c4ec84c7
RW
118
119 pci_unlock_rescan_remove();
1da177e4
LT
120 return rc;
121}
122
This page took 0.835914 seconds and 5 git commands to generate.