Message ID | 20200927032829.11321-5-haifeng.zhao@intel.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | Fix DPC hotplug race and enhance error handling | expand |
On Sat, 2020-09-26 at 23:28 -0400, Ethan Zhao wrote: > simplify the pci_dev_set_io_state() function to only return true > when dev->error_state is changed. [] > diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h [] > @@ -362,35 +362,11 @@ static inline bool pci_dev_set_io_state(struct pci_dev *dev, > bool changed = false; [] > + if (dev->error_state == new) > + return changed; > + > + dev->error_state = new; > + changed = true; > return changed; > } This would be simpler removing the unnecessary changed automatic ... if (dev->error_state == new) return false; dev->error_state = new; return true; }
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index fa12f7cbc1a0..387f891ce6a1 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -362,35 +362,11 @@ static inline bool pci_dev_set_io_state(struct pci_dev *dev, bool changed = false; device_lock_assert(&dev->dev); - switch (new) { - case pci_channel_io_perm_failure: - switch (dev->error_state) { - case pci_channel_io_frozen: - case pci_channel_io_normal: - case pci_channel_io_perm_failure: - changed = true; - break; - } - break; - case pci_channel_io_frozen: - switch (dev->error_state) { - case pci_channel_io_frozen: - case pci_channel_io_normal: - changed = true; - break; - } - break; - case pci_channel_io_normal: - switch (dev->error_state) { - case pci_channel_io_frozen: - case pci_channel_io_normal: - changed = true; - break; - } - break; - } - if (changed) - dev->error_state = new; + if (dev->error_state == new) + return changed; + + dev->error_state = new; + changed = true; return changed; }