Commit 956a2066 authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

vxge: make function table const

All tables of function pointers should be const.
The pre-existing code has lots of needless indirection...

Inspired by similar change in PAX.
Compile tested only.
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d91d25d5
...@@ -1342,9 +1342,7 @@ vxge_hw_device_initialize( ...@@ -1342,9 +1342,7 @@ vxge_hw_device_initialize(
hldev->bar0 = attr->bar0; hldev->bar0 = attr->bar0;
hldev->pdev = attr->pdev; hldev->pdev = attr->pdev;
hldev->uld_callbacks.link_up = attr->uld_callbacks.link_up; hldev->uld_callbacks = attr->uld_callbacks;
hldev->uld_callbacks.link_down = attr->uld_callbacks.link_down;
hldev->uld_callbacks.crit_err = attr->uld_callbacks.crit_err;
__vxge_hw_device_pci_e_init(hldev); __vxge_hw_device_pci_e_init(hldev);
...@@ -2633,7 +2631,7 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, ...@@ -2633,7 +2631,7 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh,
u32 items_priv_size, u32 items_priv_size,
u32 items_initial, u32 items_initial,
u32 items_max, u32 items_max,
struct vxge_hw_mempool_cbs *mp_callback, const struct vxge_hw_mempool_cbs *mp_callback,
void *userdata) void *userdata)
{ {
enum vxge_hw_status status = VXGE_HW_OK; enum vxge_hw_status status = VXGE_HW_OK;
...@@ -2817,7 +2815,9 @@ __vxge_hw_ring_create(struct __vxge_hw_vpath_handle *vp, ...@@ -2817,7 +2815,9 @@ __vxge_hw_ring_create(struct __vxge_hw_vpath_handle *vp,
struct vxge_hw_ring_config *config; struct vxge_hw_ring_config *config;
struct __vxge_hw_device *hldev; struct __vxge_hw_device *hldev;
u32 vp_id; u32 vp_id;
struct vxge_hw_mempool_cbs ring_mp_callback; static const struct vxge_hw_mempool_cbs ring_mp_callback = {
.item_func_alloc = __vxge_hw_ring_mempool_item_alloc,
};
if ((vp == NULL) || (attr == NULL)) { if ((vp == NULL) || (attr == NULL)) {
status = VXGE_HW_FAIL; status = VXGE_HW_FAIL;
...@@ -2872,7 +2872,6 @@ __vxge_hw_ring_create(struct __vxge_hw_vpath_handle *vp, ...@@ -2872,7 +2872,6 @@ __vxge_hw_ring_create(struct __vxge_hw_vpath_handle *vp,
/* calculate actual RxD block private size */ /* calculate actual RxD block private size */
ring->rxdblock_priv_size = ring->rxd_priv_size * ring->rxds_per_block; ring->rxdblock_priv_size = ring->rxd_priv_size * ring->rxds_per_block;
ring_mp_callback.item_func_alloc = __vxge_hw_ring_mempool_item_alloc;
ring->mempool = __vxge_hw_mempool_create(hldev, ring->mempool = __vxge_hw_mempool_create(hldev,
VXGE_HW_BLOCK_SIZE, VXGE_HW_BLOCK_SIZE,
VXGE_HW_BLOCK_SIZE, VXGE_HW_BLOCK_SIZE,
......
...@@ -740,7 +740,7 @@ struct __vxge_hw_device { ...@@ -740,7 +740,7 @@ struct __vxge_hw_device {
struct vxge_hw_device_config config; struct vxge_hw_device_config config;
enum vxge_hw_device_link_state link_state; enum vxge_hw_device_link_state link_state;
struct vxge_hw_uld_cbs uld_callbacks; const struct vxge_hw_uld_cbs *uld_callbacks;
u32 host_type; u32 host_type;
u32 func_id; u32 func_id;
...@@ -840,7 +840,7 @@ struct vxge_hw_device_hw_info { ...@@ -840,7 +840,7 @@ struct vxge_hw_device_hw_info {
struct vxge_hw_device_attr { struct vxge_hw_device_attr {
void __iomem *bar0; void __iomem *bar0;
struct pci_dev *pdev; struct pci_dev *pdev;
struct vxge_hw_uld_cbs uld_callbacks; const struct vxge_hw_uld_cbs *uld_callbacks;
}; };
#define VXGE_HW_DEVICE_LINK_STATE_SET(hldev, ls) (hldev->link_state = ls) #define VXGE_HW_DEVICE_LINK_STATE_SET(hldev, ls) (hldev->link_state = ls)
......
...@@ -4284,6 +4284,12 @@ static int __devinit is_sriov_initialized(struct pci_dev *pdev) ...@@ -4284,6 +4284,12 @@ static int __devinit is_sriov_initialized(struct pci_dev *pdev)
return 0; return 0;
} }
static const struct vxge_hw_uld_cbs vxge_callbacks = {
.link_up = vxge_callback_link_up,
.link_down = vxge_callback_link_down,
.crit_err = vxge_callback_crit_err,
};
/** /**
* vxge_probe * vxge_probe
* @pdev : structure containing the PCI related information of the device. * @pdev : structure containing the PCI related information of the device.
...@@ -4494,9 +4500,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) ...@@ -4494,9 +4500,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
} }
/* Setting driver callbacks */ /* Setting driver callbacks */
attr.uld_callbacks.link_up = vxge_callback_link_up; attr.uld_callbacks = &vxge_callbacks;
attr.uld_callbacks.link_down = vxge_callback_link_down;
attr.uld_callbacks.crit_err = vxge_callback_crit_err;
status = vxge_hw_device_initialize(&hldev, &attr, device_config); status = vxge_hw_device_initialize(&hldev, &attr, device_config);
if (status != VXGE_HW_OK) { if (status != VXGE_HW_OK) {
......
...@@ -532,8 +532,8 @@ __vxge_hw_device_handle_error(struct __vxge_hw_device *hldev, u32 vp_id, ...@@ -532,8 +532,8 @@ __vxge_hw_device_handle_error(struct __vxge_hw_device *hldev, u32 vp_id,
} }
/* notify driver */ /* notify driver */
if (hldev->uld_callbacks.crit_err) if (hldev->uld_callbacks->crit_err)
hldev->uld_callbacks.crit_err( hldev->uld_callbacks->crit_err(
(struct __vxge_hw_device *)hldev, (struct __vxge_hw_device *)hldev,
type, vp_id); type, vp_id);
out: out:
...@@ -560,8 +560,8 @@ __vxge_hw_device_handle_link_down_ind(struct __vxge_hw_device *hldev) ...@@ -560,8 +560,8 @@ __vxge_hw_device_handle_link_down_ind(struct __vxge_hw_device *hldev)
hldev->link_state = VXGE_HW_LINK_DOWN; hldev->link_state = VXGE_HW_LINK_DOWN;
/* notify driver */ /* notify driver */
if (hldev->uld_callbacks.link_down) if (hldev->uld_callbacks->link_down)
hldev->uld_callbacks.link_down(hldev); hldev->uld_callbacks->link_down(hldev);
exit: exit:
return VXGE_HW_OK; return VXGE_HW_OK;
} }
...@@ -585,8 +585,8 @@ __vxge_hw_device_handle_link_up_ind(struct __vxge_hw_device *hldev) ...@@ -585,8 +585,8 @@ __vxge_hw_device_handle_link_up_ind(struct __vxge_hw_device *hldev)
hldev->link_state = VXGE_HW_LINK_UP; hldev->link_state = VXGE_HW_LINK_UP;
/* notify driver */ /* notify driver */
if (hldev->uld_callbacks.link_up) if (hldev->uld_callbacks->link_up)
hldev->uld_callbacks.link_up(hldev); hldev->uld_callbacks->link_up(hldev);
exit: exit:
return VXGE_HW_OK; return VXGE_HW_OK;
} }
......
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