Commit 9cc91173 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by David S. Miller

net: hinic: Use devm_kasprintf()

Use devm_kasprintf() instead of hand writing it.
This is less verbose and less error prone.
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7e6cadf5
...@@ -861,7 +861,7 @@ int hinic_init_txq(struct hinic_txq *txq, struct hinic_sq *sq, ...@@ -861,7 +861,7 @@ int hinic_init_txq(struct hinic_txq *txq, struct hinic_sq *sq,
struct hinic_qp *qp = container_of(sq, struct hinic_qp, sq); struct hinic_qp *qp = container_of(sq, struct hinic_qp, sq);
struct hinic_dev *nic_dev = netdev_priv(netdev); struct hinic_dev *nic_dev = netdev_priv(netdev);
struct hinic_hwdev *hwdev = nic_dev->hwdev; struct hinic_hwdev *hwdev = nic_dev->hwdev;
int err, irqname_len; int err;
txq->netdev = netdev; txq->netdev = netdev;
txq->sq = sq; txq->sq = sq;
...@@ -882,15 +882,13 @@ int hinic_init_txq(struct hinic_txq *txq, struct hinic_sq *sq, ...@@ -882,15 +882,13 @@ int hinic_init_txq(struct hinic_txq *txq, struct hinic_sq *sq,
goto err_alloc_free_sges; goto err_alloc_free_sges;
} }
irqname_len = snprintf(NULL, 0, "%s_txq%d", netdev->name, qp->q_id) + 1; txq->irq_name = devm_kasprintf(&netdev->dev, GFP_KERNEL, "%s_txq%d",
txq->irq_name = devm_kzalloc(&netdev->dev, irqname_len, GFP_KERNEL); netdev->name, qp->q_id);
if (!txq->irq_name) { if (!txq->irq_name) {
err = -ENOMEM; err = -ENOMEM;
goto err_alloc_irqname; goto err_alloc_irqname;
} }
sprintf(txq->irq_name, "%s_txq%d", netdev->name, qp->q_id);
err = hinic_hwdev_hw_ci_addr_set(hwdev, sq, CI_UPDATE_NO_PENDING, err = hinic_hwdev_hw_ci_addr_set(hwdev, sq, CI_UPDATE_NO_PENDING,
CI_UPDATE_NO_COALESC); CI_UPDATE_NO_COALESC);
if (err) if (err)
......
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