Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*
  2  *  pci_bind.c - ACPI PCI Device Binding ($Revision: 2 $)
  3  *
  4  *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  5  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  6  *
  7  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8  *
  9  *  This program is free software; you can redistribute it and/or modify
 10  *  it under the terms of the GNU General Public License as published by
 11  *  the Free Software Foundation; either version 2 of the License, or (at
 12  *  your option) any later version.
 13  *
 14  *  This program is distributed in the hope that it will be useful, but
 15  *  WITHOUT ANY WARRANTY; without even the implied warranty of
 16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17  *  General Public License for more details.
 18  *
 19  *  You should have received a copy of the GNU General Public License along
 20  *  with this program; if not, write to the Free Software Foundation, Inc.,
 21  *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 22  *
 23  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 24  */
 25 
 26 #include <linux/kernel.h>
 27 #include <linux/types.h>
 28 #include <linux/pci.h>
 29 #include <linux/acpi.h>
 30 #include <acpi/acpi_bus.h>
 31 #include <acpi/acpi_drivers.h>
 32 
 33 #define _COMPONENT              ACPI_PCI_COMPONENT
 34 ACPI_MODULE_NAME("pci_bind");
 35 
 36 static int acpi_pci_unbind(struct acpi_device *device)
 37 {
 38         struct pci_dev *dev;
 39 
 40         dev = acpi_get_pci_dev(device->handle);
 41         if (!dev || !dev->subordinate)
 42                 goto out;
 43 
 44         acpi_pci_irq_del_prt(dev->subordinate);
 45 
 46         device->ops.bind = NULL;
 47         device->ops.unbind = NULL;
 48 
 49 out:
 50         pci_dev_put(dev);
 51         return 0;
 52 }
 53 
 54 static int acpi_pci_bind(struct acpi_device *device)
 55 {
 56         acpi_status status;
 57         acpi_handle handle;
 58         struct pci_bus *bus;
 59         struct pci_dev *dev;
 60 
 61         dev = acpi_get_pci_dev(device->handle);
 62         if (!dev)
 63                 return 0;
 64 
 65         /*
 66          * Install the 'bind' function to facilitate callbacks for
 67          * children of the P2P bridge.
 68          */
 69         if (dev->subordinate) {
 70                 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 71                                   "Device %04x:%02x:%02x.%d is a PCI bridge\n",
 72                                   pci_domain_nr(dev->bus), dev->bus->number,
 73                                   PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)));
 74                 device->ops.bind = acpi_pci_bind;
 75                 device->ops.unbind = acpi_pci_unbind;
 76         }
 77 
 78         /*
 79          * Evaluate and parse _PRT, if exists.  This code allows parsing of
 80          * _PRT objects within the scope of non-bridge devices.  Note that
 81          * _PRTs within the scope of a PCI bridge assume the bridge's
 82          * subordinate bus number.
 83          *
 84          * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?
 85          */
 86         status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
 87         if (ACPI_FAILURE(status))
 88                 goto out;
 89 
 90         if (dev->subordinate)
 91                 bus = dev->subordinate;
 92         else
 93                 bus = dev->bus;
 94 
 95         acpi_pci_irq_add_prt(device->handle, bus);
 96 
 97 out:
 98         pci_dev_put(dev);
 99         return 0;
100 }
101 
102 int acpi_pci_bind_root(struct acpi_device *device)
103 {
104         device->ops.bind = acpi_pci_bind;
105         device->ops.unbind = acpi_pci_unbind;
106 
107         return 0;
108 }
109 
  This page was automatically generated by the LXR engine.