Commit 9fb625c3 authored by Hidetoshi Seto's avatar Hidetoshi Seto Committed by Greg Kroah-Hartman

PCI : Move pci_fixup_device and is_enabled (originally intended change)

Original patch was posted as "PCI : Move pci_fixup_device and is_enabled".
This 2 of 3 patches does:

  - Move pci_fixup_device and enable_cnt
    (originally intended change)

  - relocate pci_fixup_device
    (recover latter change of 1st patch)
Signed-off-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: default avatarHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 924b08f3
...@@ -682,22 +682,28 @@ pci_restore_state(struct pci_dev *dev) ...@@ -682,22 +682,28 @@ pci_restore_state(struct pci_dev *dev)
* @bars: bitmask of BAR's that must be configured * @bars: bitmask of BAR's that must be configured
* *
* Initialize device before it's used by a driver. Ask low-level code * Initialize device before it's used by a driver. Ask low-level code
* to enable selected I/O and memory resources. Wake up the device if it * to enable selected I/O and memory resources. Wake up the device if it
* was suspended. Beware, this function can fail. * was suspended. Beware, this function can fail.
*/ */
int int
pci_enable_device_bars(struct pci_dev *dev, int bars) pci_enable_device_bars(struct pci_dev *dev, int bars)
{ {
int err; int err;
if (atomic_add_return(1, &dev->enable_cnt) > 1)
return 0; /* already enabled */
err = pci_set_power_state(dev, PCI_D0); err = pci_set_power_state(dev, PCI_D0);
if (err < 0 && err != -EIO) if (err < 0 && err != -EIO)
return err; goto err_out;
err = pcibios_enable_device(dev, bars); err = pcibios_enable_device(dev, bars);
if (err < 0) if (err < 0)
return err; goto err_out;
return 0; pci_fixup_device(pci_fixup_enable, dev);
err_out:
atomic_dec(&dev->enable_cnt);
return err;
} }
/** /**
...@@ -713,13 +719,7 @@ pci_enable_device_bars(struct pci_dev *dev, int bars) ...@@ -713,13 +719,7 @@ pci_enable_device_bars(struct pci_dev *dev, int bars)
*/ */
int pci_enable_device(struct pci_dev *dev) int pci_enable_device(struct pci_dev *dev)
{ {
int result; return pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
if (atomic_add_return(1, &dev->enable_cnt) > 1)
return 0; /* already enabled */
result = __pci_enable_device(dev);
if (result < 0)
atomic_dec(&dev->enable_cnt);
return result;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment