Commit 5b8db8f6 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Lorenzo Pieralisi

PCI: hv: Use list_for_each_entry()

There are several places where list_for_each_entry() could be
used to simplify the code.
Signed-off-by: default avatarStephen Hemminger <sthemmin@microsoft.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
parent 6708be93
...@@ -1279,7 +1279,6 @@ static u64 get_bar_size(u64 bar_val) ...@@ -1279,7 +1279,6 @@ static u64 get_bar_size(u64 bar_val)
*/ */
static void survey_child_resources(struct hv_pcibus_device *hbus) static void survey_child_resources(struct hv_pcibus_device *hbus)
{ {
struct list_head *iter;
struct hv_pci_dev *hpdev; struct hv_pci_dev *hpdev;
resource_size_t bar_size = 0; resource_size_t bar_size = 0;
unsigned long flags; unsigned long flags;
...@@ -1305,8 +1304,7 @@ static void survey_child_resources(struct hv_pcibus_device *hbus) ...@@ -1305,8 +1304,7 @@ static void survey_child_resources(struct hv_pcibus_device *hbus)
* for a child device are a power of 2 in size and aligned in memory, * for a child device are a power of 2 in size and aligned in memory,
* so it's sufficient to just add them up without tracking alignment. * so it's sufficient to just add them up without tracking alignment.
*/ */
list_for_each(iter, &hbus->children) { list_for_each_entry(hpdev, &hbus->children, list_entry) {
hpdev = container_of(iter, struct hv_pci_dev, list_entry);
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (hpdev->probed_bar[i] & PCI_BASE_ADDRESS_SPACE_IO) if (hpdev->probed_bar[i] & PCI_BASE_ADDRESS_SPACE_IO)
dev_err(&hbus->hdev->device, dev_err(&hbus->hdev->device,
...@@ -1359,7 +1357,6 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus) ...@@ -1359,7 +1357,6 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus)
resource_size_t low_base = 0; resource_size_t low_base = 0;
resource_size_t bar_size; resource_size_t bar_size;
struct hv_pci_dev *hpdev; struct hv_pci_dev *hpdev;
struct list_head *iter;
unsigned long flags; unsigned long flags;
u64 bar_val; u64 bar_val;
u32 command; u32 command;
...@@ -1381,9 +1378,7 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus) ...@@ -1381,9 +1378,7 @@ static void prepopulate_bars(struct hv_pcibus_device *hbus)
/* Pick addresses for the BARs. */ /* Pick addresses for the BARs. */
do { do {
list_for_each(iter, &hbus->children) { list_for_each_entry(hpdev, &hbus->children, list_entry) {
hpdev = container_of(iter, struct hv_pci_dev,
list_entry);
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
bar_val = hpdev->probed_bar[i]; bar_val = hpdev->probed_bar[i];
if (bar_val == 0) if (bar_val == 0)
...@@ -1626,7 +1621,6 @@ static void pci_devices_present_work(struct work_struct *work) ...@@ -1626,7 +1621,6 @@ static void pci_devices_present_work(struct work_struct *work)
{ {
u32 child_no; u32 child_no;
bool found; bool found;
struct list_head *iter;
struct pci_function_description *new_desc; struct pci_function_description *new_desc;
struct hv_pci_dev *hpdev; struct hv_pci_dev *hpdev;
struct hv_pcibus_device *hbus; struct hv_pcibus_device *hbus;
...@@ -1663,9 +1657,7 @@ static void pci_devices_present_work(struct work_struct *work) ...@@ -1663,9 +1657,7 @@ static void pci_devices_present_work(struct work_struct *work)
/* First, mark all existing children as reported missing. */ /* First, mark all existing children as reported missing. */
spin_lock_irqsave(&hbus->device_list_lock, flags); spin_lock_irqsave(&hbus->device_list_lock, flags);
list_for_each(iter, &hbus->children) { list_for_each_entry(hpdev, &hbus->children, list_entry) {
hpdev = container_of(iter, struct hv_pci_dev,
list_entry);
hpdev->reported_missing = true; hpdev->reported_missing = true;
} }
spin_unlock_irqrestore(&hbus->device_list_lock, flags); spin_unlock_irqrestore(&hbus->device_list_lock, flags);
...@@ -1676,11 +1668,8 @@ static void pci_devices_present_work(struct work_struct *work) ...@@ -1676,11 +1668,8 @@ static void pci_devices_present_work(struct work_struct *work)
new_desc = &dr->func[child_no]; new_desc = &dr->func[child_no];
spin_lock_irqsave(&hbus->device_list_lock, flags); spin_lock_irqsave(&hbus->device_list_lock, flags);
list_for_each(iter, &hbus->children) { list_for_each_entry(hpdev, &hbus->children, list_entry) {
hpdev = container_of(iter, struct hv_pci_dev, if ((hpdev->desc.win_slot.slot == new_desc->win_slot.slot) &&
list_entry);
if ((hpdev->desc.win_slot.slot ==
new_desc->win_slot.slot) &&
(hpdev->desc.v_id == new_desc->v_id) && (hpdev->desc.v_id == new_desc->v_id) &&
(hpdev->desc.d_id == new_desc->d_id) && (hpdev->desc.d_id == new_desc->d_id) &&
(hpdev->desc.ser == new_desc->ser)) { (hpdev->desc.ser == new_desc->ser)) {
...@@ -1702,9 +1691,7 @@ static void pci_devices_present_work(struct work_struct *work) ...@@ -1702,9 +1691,7 @@ static void pci_devices_present_work(struct work_struct *work)
spin_lock_irqsave(&hbus->device_list_lock, flags); spin_lock_irqsave(&hbus->device_list_lock, flags);
do { do {
found = false; found = false;
list_for_each(iter, &hbus->children) { list_for_each_entry(hpdev, &hbus->children, list_entry) {
hpdev = container_of(iter, struct hv_pci_dev,
list_entry);
if (hpdev->reported_missing) { if (hpdev->reported_missing) {
found = true; found = true;
put_pcichild(hpdev); put_pcichild(hpdev);
......
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