Skip to content

Commit 16d79cd

Browse files
lucvoobjorn-helgaas
authored andcommitted
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/[email protected] https://lore.kernel.org/r/[email protected]] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Luc Van Oostenryck <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent b3a9e3b commit 16d79cd

File tree

18 files changed

+24
-24
lines changed

18 files changed

+24
-24
lines changed

Documentation/PCI/pci-error-recovery.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ This structure has the form::
7979

8080
struct pci_error_handlers
8181
{
82-
int (*error_detected)(struct pci_dev *dev, enum pci_channel_state);
82+
int (*error_detected)(struct pci_dev *dev, pci_channel_state_t);
8383
int (*mmio_enabled)(struct pci_dev *dev);
8484
int (*slot_reset)(struct pci_dev *dev);
8585
void (*resume)(struct pci_dev *dev);
8686
};
8787

8888
The possible channel states are::
8989

90-
enum pci_channel_state {
90+
typedef enum {
9191
pci_channel_io_normal, /* I/O channel is in normal state */
9292
pci_channel_io_frozen, /* I/O to channel is blocked */
9393
pci_channel_io_perm_failure, /* PCI card is dead */
94-
};
94+
} pci_channel_state_t;
9595

9696
Possible return values are::
9797

@@ -348,7 +348,7 @@ STEP 6: Permanent Failure
348348
-------------------------
349349
A "permanent failure" has occurred, and the platform cannot recover
350350
the device. The platform will call error_detected() with a
351-
pci_channel_state value of pci_channel_io_perm_failure.
351+
pci_channel_state_t value of pci_channel_io_perm_failure.
352352

353353
The device driver should, at this point, assume the worst. It should
354354
cancel all pending I/O, refuse all new I/O, returning -EIO to

arch/powerpc/kernel/eeh_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static void eeh_dev_save_state(struct eeh_dev *edev, void *userdata)
214214
pci_save_state(pdev);
215215
}
216216

217-
static void eeh_set_channel_state(struct eeh_pe *root, enum pci_channel_state s)
217+
static void eeh_set_channel_state(struct eeh_pe *root, pci_channel_state_t s)
218218
{
219219
struct eeh_pe *pe;
220220
struct eeh_dev *edev, *tmp;

drivers/block/rsxx/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ static int rsxx_eeh_fifo_flush_poll(struct rsxx_cardinfo *card)
625625
}
626626

627627
static pci_ers_result_t rsxx_error_detected(struct pci_dev *dev,
628-
enum pci_channel_state error)
628+
pci_channel_state_t error)
629629
{
630630
int st;
631631

drivers/dma/ioat/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ static void ioat_resume(struct ioatdma_device *ioat_dma)
12671267
#define DRV_NAME "ioatdma"
12681268

12691269
static pci_ers_result_t ioat_pcie_error_detected(struct pci_dev *pdev,
1270-
enum pci_channel_state error)
1270+
pci_channel_state_t error)
12711271
{
12721272
dev_dbg(&pdev->dev, "%s: PCIe AER error %d\n", DRV_NAME, error);
12731273

drivers/media/pci/ngene/ngene-cards.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ MODULE_DEVICE_TABLE(pci, ngene_id_tbl);
11861186
/****************************************************************************/
11871187

11881188
static pci_ers_result_t ngene_error_detected(struct pci_dev *dev,
1189-
enum pci_channel_state state)
1189+
pci_channel_state_t state)
11901190
{
11911191
dev_err(&dev->dev, "PCI error\n");
11921192
if (state == pci_channel_io_perm_failure)

drivers/misc/genwqe/card_base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ static void genwqe_remove(struct pci_dev *pci_dev)
12401240
* error is detected.
12411241
*/
12421242
static pci_ers_result_t genwqe_err_error_detected(struct pci_dev *pci_dev,
1243-
enum pci_channel_state state)
1243+
pci_channel_state_t state)
12441244
{
12451245
struct genwqe_dev *cd;
12461246

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15465,7 +15465,7 @@ static void i40e_remove(struct pci_dev *pdev)
1546515465
* remediation.
1546615466
**/
1546715467
static pci_ers_result_t i40e_pci_error_detected(struct pci_dev *pdev,
15468-
enum pci_channel_state error)
15468+
pci_channel_state_t error)
1546915469
{
1547015470
struct i40e_pf *pf = pci_get_drvdata(pdev);
1547115471

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3586,7 +3586,7 @@ static void ice_remove(struct pci_dev *pdev)
35863586
* is in progress. Allows the driver to gracefully prepare/handle PCI errors.
35873587
*/
35883588
static pci_ers_result_t
3589-
ice_pci_err_detected(struct pci_dev *pdev, enum pci_channel_state err)
3589+
ice_pci_err_detected(struct pci_dev *pdev, pci_channel_state_t err)
35903590
{
35913591
struct ice_pf *pf = pci_get_drvdata(pdev);
35923592

drivers/net/ethernet/intel/ixgb/ixgb_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int ixgb_vlan_rx_kill_vid(struct net_device *netdev,
8282
static void ixgb_restore_vlan(struct ixgb_adapter *adapter);
8383

8484
static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev,
85-
enum pci_channel_state state);
85+
pci_channel_state_t state);
8686
static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev);
8787
static void ixgb_io_resume (struct pci_dev *pdev);
8888

@@ -2194,7 +2194,7 @@ ixgb_restore_vlan(struct ixgb_adapter *adapter)
21942194
* a PCI bus error is detected.
21952195
*/
21962196
static pci_ers_result_t ixgb_io_error_detected(struct pci_dev *pdev,
2197-
enum pci_channel_state state)
2197+
pci_channel_state_t state)
21982198
{
21992199
struct net_device *netdev = pci_get_drvdata(pdev);
22002200
struct ixgb_adapter *adapter = netdev_priv(netdev);

drivers/net/ethernet/sfc/efx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ static const struct dev_pm_ops efx_pm_ops = {
15191519
* Stop the software path and request a slot reset.
15201520
*/
15211521
static pci_ers_result_t efx_io_error_detected(struct pci_dev *pdev,
1522-
enum pci_channel_state state)
1522+
pci_channel_state_t state)
15231523
{
15241524
pci_ers_result_t status = PCI_ERS_RESULT_RECOVERED;
15251525
struct efx_nic *efx = pci_get_drvdata(pdev);

0 commit comments

Comments
 (0)