Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31975e27 authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller
Browse files

mlx4: sizeof style usage



The kernel coding style is to treat sizeof as a function
(ie. with parenthesis) not as an operator.

Also use kcalloc and kmalloc_array

Signed-off-by: default avatarStephen Hemminger <stephen@networkplumber.org>
Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9d2ee98d
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -2695,7 +2695,7 @@ struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev)
{
{
	struct mlx4_cmd_mailbox *mailbox;
	struct mlx4_cmd_mailbox *mailbox;


	mailbox = kmalloc(sizeof *mailbox, GFP_KERNEL);
	mailbox = kmalloc(sizeof(*mailbox), GFP_KERNEL);
	if (!mailbox)
	if (!mailbox)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);


+1 −1
Original line number Original line Diff line number Diff line
@@ -44,7 +44,7 @@ void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
	struct mlx4_en_dev *mdev = priv->mdev;
	struct mlx4_en_dev *mdev = priv->mdev;
	struct net_device *dev = priv->dev;
	struct net_device *dev = priv->dev;


	memset(context, 0, sizeof *context);
	memset(context, 0, sizeof(*context));
	context->flags = cpu_to_be32(7 << 16 | rss << MLX4_RSS_QPC_FLAG_OFFSET);
	context->flags = cpu_to_be32(7 << 16 | rss << MLX4_RSS_QPC_FLAG_OFFSET);
	context->pd = cpu_to_be32(mdev->priv_pdn);
	context->pd = cpu_to_be32(mdev->priv_pdn);
	context->mtu_msgmax = 0xff;
	context->mtu_msgmax = 0xff;
+1 −1
Original line number Original line Diff line number Diff line
@@ -1056,7 +1056,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
	}
	}
	qp->event = mlx4_en_sqp_event;
	qp->event = mlx4_en_sqp_event;


	memset(context, 0, sizeof *context);
	memset(context, 0, sizeof(*context));
	mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0,
	mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0,
				qpn, ring->cqn, -1, context);
				qpn, ring->cqn, -1, context);
	context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma);
	context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma);
+1 −1
Original line number Original line Diff line number Diff line
@@ -643,7 +643,7 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc,
			     void *fragptr)
			     void *fragptr)
{
{
	struct mlx4_wqe_inline_seg *inl = &tx_desc->inl;
	struct mlx4_wqe_inline_seg *inl = &tx_desc->inl;
	int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof *inl;
	int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof(*inl);
	unsigned int hlen = skb_headlen(skb);
	unsigned int hlen = skb_headlen(skb);


	if (skb->len <= spc) {
	if (skb->len <= spc) {
+10 −10
Original line number Original line Diff line number Diff line
@@ -259,7 +259,7 @@ int mlx4_gen_pkey_eqe(struct mlx4_dev *dev, int slave, u8 port)
	if (!s_slave->active)
	if (!s_slave->active)
		return 0;
		return 0;


	memset(&eqe, 0, sizeof eqe);
	memset(&eqe, 0, sizeof(eqe));


	eqe.type = MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT;
	eqe.type = MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT;
	eqe.subtype = MLX4_DEV_PMC_SUBTYPE_PKEY_TABLE;
	eqe.subtype = MLX4_DEV_PMC_SUBTYPE_PKEY_TABLE;
@@ -276,7 +276,7 @@ int mlx4_gen_guid_change_eqe(struct mlx4_dev *dev, int slave, u8 port)
	/*don't send if we don't have the that slave */
	/*don't send if we don't have the that slave */
	if (dev->persist->num_vfs < slave)
	if (dev->persist->num_vfs < slave)
		return 0;
		return 0;
	memset(&eqe, 0, sizeof eqe);
	memset(&eqe, 0, sizeof(eqe));


	eqe.type = MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT;
	eqe.type = MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT;
	eqe.subtype = MLX4_DEV_PMC_SUBTYPE_GUID_INFO;
	eqe.subtype = MLX4_DEV_PMC_SUBTYPE_GUID_INFO;
@@ -295,7 +295,7 @@ int mlx4_gen_port_state_change_eqe(struct mlx4_dev *dev, int slave, u8 port,
	/*don't send if we don't have the that slave */
	/*don't send if we don't have the that slave */
	if (dev->persist->num_vfs < slave)
	if (dev->persist->num_vfs < slave)
		return 0;
		return 0;
	memset(&eqe, 0, sizeof eqe);
	memset(&eqe, 0, sizeof(eqe));


	eqe.type = MLX4_EVENT_TYPE_PORT_CHANGE;
	eqe.type = MLX4_EVENT_TYPE_PORT_CHANGE;
	eqe.subtype = port_subtype_change;
	eqe.subtype = port_subtype_change;
@@ -432,7 +432,7 @@ int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr)
{
{
	struct mlx4_eqe eqe;
	struct mlx4_eqe eqe;


	memset(&eqe, 0, sizeof eqe);
	memset(&eqe, 0, sizeof(eqe));


	eqe.type = MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT;
	eqe.type = MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT;
	eqe.subtype = MLX4_DEV_PMC_SUBTYPE_PORT_INFO;
	eqe.subtype = MLX4_DEV_PMC_SUBTYPE_PORT_INFO;
@@ -726,7 +726,7 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq)
			}
			}
			memcpy(&priv->mfunc.master.comm_arm_bit_vector,
			memcpy(&priv->mfunc.master.comm_arm_bit_vector,
			       eqe->event.comm_channel_arm.bit_vec,
			       eqe->event.comm_channel_arm.bit_vec,
			       sizeof eqe->event.comm_channel_arm.bit_vec);
			       sizeof(eqe)->event.comm_channel_arm.bit_vec);
			queue_work(priv->mfunc.master.comm_wq,
			queue_work(priv->mfunc.master.comm_wq,
				   &priv->mfunc.master.comm_work);
				   &priv->mfunc.master.comm_work);
			break;
			break;
@@ -984,7 +984,7 @@ static int mlx4_create_eq(struct mlx4_dev *dev, int nent,
	 */
	 */
	npages = PAGE_ALIGN(eq->nent * dev->caps.eqe_size) / PAGE_SIZE;
	npages = PAGE_ALIGN(eq->nent * dev->caps.eqe_size) / PAGE_SIZE;


	eq->page_list = kmalloc(npages * sizeof *eq->page_list,
	eq->page_list = kmalloc_array(npages, sizeof(*eq->page_list),
				      GFP_KERNEL);
				      GFP_KERNEL);
	if (!eq->page_list)
	if (!eq->page_list)
		goto err_out;
		goto err_out;
@@ -992,7 +992,7 @@ static int mlx4_create_eq(struct mlx4_dev *dev, int nent,
	for (i = 0; i < npages; ++i)
	for (i = 0; i < npages; ++i)
		eq->page_list[i].buf = NULL;
		eq->page_list[i].buf = NULL;


	dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
	dma_list = kmalloc_array(npages, sizeof(*dma_list), GFP_KERNEL);
	if (!dma_list)
	if (!dma_list)
		goto err_out_free;
		goto err_out_free;


@@ -1161,7 +1161,7 @@ int mlx4_alloc_eq_table(struct mlx4_dev *dev)
	struct mlx4_priv *priv = mlx4_priv(dev);
	struct mlx4_priv *priv = mlx4_priv(dev);


	priv->eq_table.eq = kcalloc(dev->caps.num_eqs - dev->caps.reserved_eqs,
	priv->eq_table.eq = kcalloc(dev->caps.num_eqs - dev->caps.reserved_eqs,
				    sizeof *priv->eq_table.eq, GFP_KERNEL);
				    sizeof(*priv->eq_table.eq), GFP_KERNEL);
	if (!priv->eq_table.eq)
	if (!priv->eq_table.eq)
		return -ENOMEM;
		return -ENOMEM;


@@ -1180,7 +1180,7 @@ int mlx4_init_eq_table(struct mlx4_dev *dev)
	int i;
	int i;


	priv->eq_table.uar_map = kcalloc(mlx4_num_eq_uar(dev),
	priv->eq_table.uar_map = kcalloc(mlx4_num_eq_uar(dev),
					 sizeof *priv->eq_table.uar_map,
					 sizeof(*priv->eq_table.uar_map),
					 GFP_KERNEL);
					 GFP_KERNEL);
	if (!priv->eq_table.uar_map) {
	if (!priv->eq_table.uar_map) {
		err = -ENOMEM;
		err = -ENOMEM;
Loading