aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index f3fd55df67db..6e309c8b47df 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -970,6 +970,32 @@ void pcim_pin_device(struct pci_dev *pdev)
970 */ 970 */
971void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {} 971void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {}
972 972
973static void do_pci_disable_device(struct pci_dev *dev)
974{
975 u16 pci_command;
976
977 pci_read_config_word(dev, PCI_COMMAND, &pci_command);
978 if (pci_command & PCI_COMMAND_MASTER) {
979 pci_command &= ~PCI_COMMAND_MASTER;
980 pci_write_config_word(dev, PCI_COMMAND, pci_command);
981 }
982
983 pcibios_disable_device(dev);
984}
985
986/**
987 * pci_disable_enabled_device - Disable device without updating enable_cnt
988 * @dev: PCI device to disable
989 *
990 * NOTE: This function is a backend of PCI power management routines and is
991 * not supposed to be called drivers.
992 */
993void pci_disable_enabled_device(struct pci_dev *dev)
994{
995 if (atomic_read(&dev->enable_cnt))
996 do_pci_disable_device(dev);
997}
998
973/** 999/**
974 * pci_disable_device - Disable PCI device after use 1000 * pci_disable_device - Disable PCI device after use
975 * @dev: PCI device to be disabled 1001 * @dev: PCI device to be disabled
@@ -984,7 +1010,6 @@ void
984pci_disable_device(struct pci_dev *dev) 1010pci_disable_device(struct pci_dev *dev)
985{ 1011{
986 struct pci_devres *dr; 1012 struct pci_devres *dr;
987 u16 pci_command;
988 1013
989 dr = find_pci_dr(dev); 1014 dr = find_pci_dr(dev);
990 if (dr) 1015 if (dr)
@@ -993,14 +1018,9 @@ pci_disable_device(struct pci_dev *dev)
993 if (atomic_sub_return(1, &dev->enable_cnt) != 0) 1018 if (atomic_sub_return(1, &dev->enable_cnt) != 0)
994 return; 1019 return;
995 1020
996 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 1021 do_pci_disable_device(dev);
997 if (pci_command & PCI_COMMAND_MASTER) {
998 pci_command &= ~PCI_COMMAND_MASTER;
999 pci_write_config_word(dev, PCI_COMMAND, pci_command);
1000 }
1001 dev->is_busmaster = 0;
1002 1022
1003 pcibios_disable_device(dev); 1023 dev->is_busmaster = 0;
1004} 1024}
1005 1025
1006/** 1026/**