diff options
-rw-r--r-- | drivers/pci/pci.c | 12 | ||||
-rw-r--r-- | include/linux/pci.h | 5 |
2 files changed, 6 insertions, 11 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6048c0c637a0..d3eab057b2d3 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -551,7 +551,9 @@ static int pci_save_pcie_state(struct pci_dev *dev) | |||
551 | if (pos <= 0) | 551 | if (pos <= 0) |
552 | return 0; | 552 | return 0; |
553 | 553 | ||
554 | save_state = kzalloc(sizeof(*save_state) + sizeof(u16) * 4, GFP_KERNEL); | 554 | save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); |
555 | if (!save_state) | ||
556 | save_state = kzalloc(sizeof(*save_state) + sizeof(u16) * 4, GFP_KERNEL); | ||
555 | if (!save_state) { | 557 | if (!save_state) { |
556 | dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n"); | 558 | dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n"); |
557 | return -ENOMEM; | 559 | return -ENOMEM; |
@@ -582,8 +584,6 @@ static void pci_restore_pcie_state(struct pci_dev *dev) | |||
582 | pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]); | 584 | pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]); |
583 | pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]); | 585 | pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]); |
584 | pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]); | 586 | pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]); |
585 | pci_remove_saved_cap(save_state); | ||
586 | kfree(save_state); | ||
587 | } | 587 | } |
588 | 588 | ||
589 | 589 | ||
@@ -597,7 +597,9 @@ static int pci_save_pcix_state(struct pci_dev *dev) | |||
597 | if (pos <= 0) | 597 | if (pos <= 0) |
598 | return 0; | 598 | return 0; |
599 | 599 | ||
600 | save_state = kzalloc(sizeof(*save_state) + sizeof(u16), GFP_KERNEL); | 600 | save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); |
601 | if (!save_state) | ||
602 | save_state = kzalloc(sizeof(*save_state) + sizeof(u16), GFP_KERNEL); | ||
601 | if (!save_state) { | 603 | if (!save_state) { |
602 | dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n"); | 604 | dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n"); |
603 | return -ENOMEM; | 605 | return -ENOMEM; |
@@ -622,8 +624,6 @@ static void pci_restore_pcix_state(struct pci_dev *dev) | |||
622 | cap = (u16 *)&save_state->data[0]; | 624 | cap = (u16 *)&save_state->data[0]; |
623 | 625 | ||
624 | pci_write_config_word(dev, pos + PCI_X_CMD, cap[i++]); | 626 | pci_write_config_word(dev, pos + PCI_X_CMD, cap[i++]); |
625 | pci_remove_saved_cap(save_state); | ||
626 | kfree(save_state); | ||
627 | } | 627 | } |
628 | 628 | ||
629 | 629 | ||
diff --git a/include/linux/pci.h b/include/linux/pci.h index 78417e421b4c..481ea0663f19 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -209,11 +209,6 @@ static inline void pci_add_saved_cap(struct pci_dev *pci_dev, | |||
209 | hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); | 209 | hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); |
210 | } | 210 | } |
211 | 211 | ||
212 | static inline void pci_remove_saved_cap(struct pci_cap_saved_state *cap) | ||
213 | { | ||
214 | hlist_del(&cap->next); | ||
215 | } | ||
216 | |||
217 | /* | 212 | /* |
218 | * For PCI devices, the region numbers are assigned this way: | 213 | * For PCI devices, the region numbers are assigned this way: |
219 | * | 214 | * |