History

PCI: Use 'pci_channel_state_t' instead of 'enum pci_channel_state'

The method struct pci_error_handlers.error_detected() is defined and documented as taking an 'enum pci_channel_state' for the second argument, but most drivers use 'pci_channel_state_t' instead. This 'pci_channel_state_t' is not a typedef for the enum but a typedef for a bitwise type in order to have better/stricter typechecking. Consolidate everything by using 'pci_channel_state_t' in the method's definition, in the related helpers and in the drivers. Enforce use of 'pci_channel_state_t' by replacing 'enum pci_channel_state' with an anonymous 'enum'. Note: Currently, from a typechecking point of view this patch changes nothing because only the constants defined by the enum are bitwise, not the enum itself (sparse doesn't have the notion of 'bitwise enum'). This may change in some not too far future, hence the patch. [bhelgaas: squash in https://lore.kernel.org/r/20200702162651.49526-3-luc.vanoostenryck@gmail.com https://lore.kernel.org/r/20200702162651.49526-4-luc.vanoostenryck@gmail.com] Link: https://lore.kernel.org/r/20200702162651.49526-2-luc.vanoostenryck@gmail.com Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Luc Van Oostenryck committed 6 years ago

Commit 16d79cd1 parent b3a9e3b18 files · +24 −24Browse files

Showing the changes to include/linux (1 of 18 files). Show all

Unified · Split

include/linux/pci.h+2−2
@@ -179,7 +179,7 @@ static inline const char *pci_power_name(pci_power_t state) · 178 unmodified lines
179179 */
180180 typedef unsigned int __bitwise pci_channel_state_t;
181181
182−enum pci_channel_state {
182+enum {
183183 /* I/O channel is in normal state */
184184 pci_channel_io_normal = (__force pci_channel_state_t) 1,
185185
@@ -785,7 +785,7 @@ enum pci_ers_result { · 599 unmodified lines
785785 struct pci_error_handlers {
786786 /* PCI bus error detected on this device */
787787 pci_ers_result_t (*error_detected)(struct pci_dev *dev,
788− enum pci_channel_state error);
788+ pci_channel_state_t error);
789789
790790 /* MMIO has been re-enabled, but not DMA */
791791 pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev);