diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2019-06-13 22:54:12 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-06-15 23:38:24 +0300 |
commit | 930cfe0f129d2e9fee8ed3e8488daee881aa31c5 (patch) | |
tree | 3f92fcb4644834f1915de9f617fff21f25d56fdb /drivers | |
parent | 407308f60d46e50d258143f0bd38adc3f780908e (diff) | |
download | linux-930cfe0f129d2e9fee8ed3e8488daee881aa31c5.tar.xz |
hinic: Use devm_kasprintf instead of hard coding it
'devm_kasprintf' is less verbose than:
snprintf(NULL, 0, ...);
devm_kzalloc(...);
sprintf
so use it instead.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Zhao Chen <zhaochen6@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/huawei/hinic/hinic_rx.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c b/drivers/net/ethernet/huawei/hinic/hinic_rx.c index 04c887d13848..1eadd99a7fad 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c @@ -502,7 +502,7 @@ int hinic_init_rxq(struct hinic_rxq *rxq, struct hinic_rq *rq, struct net_device *netdev) { struct hinic_qp *qp = container_of(rq, struct hinic_qp, rq); - int err, pkts, irqname_len; + int err, pkts; rxq->netdev = netdev; rxq->rq = rq; @@ -511,13 +511,11 @@ int hinic_init_rxq(struct hinic_rxq *rxq, struct hinic_rq *rq, rxq_stats_init(rxq); - irqname_len = snprintf(NULL, 0, "hinic_rxq%d", qp->q_id) + 1; - rxq->irq_name = devm_kzalloc(&netdev->dev, irqname_len, GFP_KERNEL); + rxq->irq_name = devm_kasprintf(&netdev->dev, GFP_KERNEL, + "hinic_rxq%d", qp->q_id); if (!rxq->irq_name) return -ENOMEM; - sprintf(rxq->irq_name, "hinic_rxq%d", qp->q_id); - pkts = rx_alloc_pkts(rxq); if (!pkts) { err = -ENOMEM; |