Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mlx4_core: Fix confusion between mlx4_event and mlx4_dev_event enums

The struct mlx4_interface.event() method was supposed to get an enum
mlx4_dev_event, but the driver code was actually passing in the
hardware enum mlx4_event values. Fix up the callers of
mlx4_dispatch_event() so that they pass in the right type of value,
and fix up the event method in mlx4_ib so that it can handle the enum
mlx4_dev_event values.

This eliminates the need for the subtype parameter to the event
method, so remove it.

This also fixes the sparse warning

drivers/net/mlx4/intf.c:127:48: warning: mixing different enum types
drivers/net/mlx4/intf.c:127:48: int enum mlx4_event versus
drivers/net/mlx4/intf.c:127:48: int enum mlx4_dev_event

Signed-off-by: Roland Dreier <rolandd@cisco.com>

+18 -18
+8 -6
drivers/infiniband/hw/mlx4/main.c
··· 675 675 } 676 676 677 677 static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr, 678 - enum mlx4_dev_event event, int subtype, 679 - int port) 678 + enum mlx4_dev_event event, int port) 680 679 { 681 680 struct ib_event ibev; 682 681 683 682 switch (event) { 684 - case MLX4_EVENT_TYPE_PORT_CHANGE: 685 - ibev.event = subtype == MLX4_PORT_CHANGE_SUBTYPE_ACTIVE ? 686 - IB_EVENT_PORT_ACTIVE : IB_EVENT_PORT_ERR; 683 + case MLX4_DEV_EVENT_PORT_UP: 684 + ibev.event = IB_EVENT_PORT_ACTIVE; 687 685 break; 688 686 689 - case MLX4_EVENT_TYPE_LOCAL_CATAS_ERROR: 687 + case MLX4_DEV_EVENT_PORT_DOWN: 688 + ibev.event = IB_EVENT_PORT_ERR; 689 + break; 690 + 691 + case MLX4_DEV_EVENT_CATASTROPHIC_ERROR: 690 692 ibev.event = IB_EVENT_DEVICE_FATAL; 691 693 break; 692 694
+1 -1
drivers/net/mlx4/catas.c
··· 69 69 if (readl(priv->catas_err.map)) { 70 70 dump_err_buf(dev); 71 71 72 - mlx4_dispatch_event(dev, MLX4_EVENT_TYPE_LOCAL_CATAS_ERROR, 0, 0); 72 + mlx4_dispatch_event(dev, MLX4_DEV_EVENT_CATASTROPHIC_ERROR, 0); 73 73 74 74 if (internal_err_reset) { 75 75 spin_lock(&catas_lock);
+4 -1
drivers/net/mlx4/eq.c
··· 202 202 break; 203 203 204 204 case MLX4_EVENT_TYPE_PORT_CHANGE: 205 - mlx4_dispatch_event(dev, eqe->type, eqe->subtype, 205 + mlx4_dispatch_event(dev, 206 + eqe->subtype == MLX4_PORT_CHANGE_SUBTYPE_ACTIVE ? 207 + MLX4_DEV_EVENT_PORT_UP : 208 + MLX4_DEV_EVENT_PORT_DOWN, 206 209 be32_to_cpu(eqe->event.port_change.port) >> 28); 207 210 break; 208 211
+2 -6
drivers/net/mlx4/intf.c
··· 30 30 * SOFTWARE. 31 31 */ 32 32 33 - #include <linux/mlx4/driver.h> 34 - 35 33 #include "mlx4.h" 36 34 37 35 struct mlx4_device_context { ··· 111 113 } 112 114 EXPORT_SYMBOL_GPL(mlx4_unregister_interface); 113 115 114 - void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_event type, 115 - int subtype, int port) 116 + void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type, int port) 116 117 { 117 118 struct mlx4_priv *priv = mlx4_priv(dev); 118 119 struct mlx4_device_context *dev_ctx; ··· 121 124 122 125 list_for_each_entry(dev_ctx, &priv->ctx_list, list) 123 126 if (dev_ctx->intf->event) 124 - dev_ctx->intf->event(dev, dev_ctx->context, type, 125 - subtype, port); 127 + dev_ctx->intf->event(dev, dev_ctx->context, type, port); 126 128 127 129 spin_unlock_irqrestore(&priv->ctx_lock, flags); 128 130 }
+2 -2
drivers/net/mlx4/mlx4.h
··· 42 42 #include <linux/timer.h> 43 43 44 44 #include <linux/mlx4/device.h> 45 + #include <linux/mlx4/driver.h> 45 46 #include <linux/mlx4/doorbell.h> 46 47 47 48 #define DRV_NAME "mlx4_core" ··· 314 313 int mlx4_restart_one(struct pci_dev *pdev); 315 314 int mlx4_register_device(struct mlx4_dev *dev); 316 315 void mlx4_unregister_device(struct mlx4_dev *dev); 317 - void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_event type, 318 - int subtype, int port); 316 + void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type, int port); 319 317 320 318 struct mlx4_dev_cap; 321 319 struct mlx4_init_hca_param;
+1 -2
include/linux/mlx4/driver.h
··· 48 48 void * (*add) (struct mlx4_dev *dev); 49 49 void (*remove)(struct mlx4_dev *dev, void *context); 50 50 void (*event) (struct mlx4_dev *dev, void *context, 51 - enum mlx4_dev_event event, int subtype, 52 - int port); 51 + enum mlx4_dev_event event, int port); 53 52 struct list_head list; 54 53 }; 55 54