2 * Compaq Hot Plug Controller Driver
4 * Copyright (c) 1995,2001 Compaq Computer Corporation
5 * Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (c) 2001 IBM Corp.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * Send feedback to <greg@kroah.com>
29 #include <linux/config.h>
30 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/types.h>
33 #include <linux/proc_fs.h>
34 #include <linux/workqueue.h>
35 #include <linux/pci.h>
39 /* A few routines that create sysfs entries for the hot plug controller */
41 static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf)
49 pdev = container_of (dev, struct pci_dev, dev);
50 bus = pdev->subordinate;
52 out += sprintf(buf, "Free resources: memory\n");
53 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
54 res = bus->resource[index];
55 if (res && (res->flags & IORESOURCE_MEM) &&
56 !(res->flags & IORESOURCE_PREFETCH)) {
57 out += sprintf(out, "start = %8.8lx, length = %8.8lx\n",
58 res->start, (res->end - res->start));
61 out += sprintf(out, "Free resources: prefetchable memory\n");
62 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
63 res = bus->resource[index];
64 if (res && (res->flags & IORESOURCE_MEM) &&
65 (res->flags & IORESOURCE_PREFETCH)) {
66 out += sprintf(out, "start = %8.8lx, length = %8.8lx\n",
67 res->start, (res->end - res->start));
70 out += sprintf(out, "Free resources: IO\n");
71 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
72 res = bus->resource[index];
73 if (res && (res->flags & IORESOURCE_IO)) {
74 out += sprintf(out, "start = %8.8lx, length = %8.8lx\n",
75 res->start, (res->end - res->start));
78 out += sprintf(out, "Free resources: bus numbers\n");
79 for (busnr = bus->secondary; busnr <= bus->subordinate; busnr++) {
80 if (!pci_find_bus(pci_domain_nr(bus), busnr))
83 if (busnr < bus->subordinate)
84 out += sprintf(out, "start = %8.8x, length = %8.8x\n",
85 busnr, (bus->subordinate - busnr));
89 static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL);
91 void shpchp_create_ctrl_files (struct controller *ctrl)
93 device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl);