Commit ba3d4acd authored by Johannes Berg's avatar Johannes Berg Committed by Luca Coelho
Browse files

iwlwifi: make iwl_txq_dyn_alloc_dma() return the txq



Use the ERR_PTR() machinery to return the queue or an
error, instead of having a separate out parameter.

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220210181930.1f0c5d72fb89.Iefca56d535558b7a8d23204fd16129c17b6704b6@changeid


Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent 3009c797
Loading
Loading
Loading
Loading
+12 −14
Original line number Original line Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
/*
 * Copyright (C) 2020-2021 Intel Corporation
 * Copyright (C) 2020-2022 Intel Corporation
 */
 */
#include <net/tso.h>
#include <net/tso.h>
#include <linux/tcp.h>
#include <linux/tcp.h>
@@ -1083,9 +1083,8 @@ int iwl_txq_alloc(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num,
	return -ENOMEM;
	return -ENOMEM;
}
}


static int iwl_txq_dyn_alloc_dma(struct iwl_trans *trans,
static struct iwl_txq *
				 struct iwl_txq **intxq, int size,
iwl_txq_dyn_alloc_dma(struct iwl_trans *trans, int size, unsigned int timeout)
				 unsigned int timeout)
{
{
	size_t bc_tbl_size, bc_tbl_entries;
	size_t bc_tbl_size, bc_tbl_entries;
	struct iwl_txq *txq;
	struct iwl_txq *txq;
@@ -1097,18 +1096,18 @@ static int iwl_txq_dyn_alloc_dma(struct iwl_trans *trans,
	bc_tbl_entries = bc_tbl_size / sizeof(u16);
	bc_tbl_entries = bc_tbl_size / sizeof(u16);


	if (WARN_ON(size > bc_tbl_entries))
	if (WARN_ON(size > bc_tbl_entries))
		return -EINVAL;
		return ERR_PTR(-EINVAL);


	txq = kzalloc(sizeof(*txq), GFP_KERNEL);
	txq = kzalloc(sizeof(*txq), GFP_KERNEL);
	if (!txq)
	if (!txq)
		return -ENOMEM;
		return ERR_PTR(-ENOMEM);


	txq->bc_tbl.addr = dma_pool_alloc(trans->txqs.bc_pool, GFP_KERNEL,
	txq->bc_tbl.addr = dma_pool_alloc(trans->txqs.bc_pool, GFP_KERNEL,
					  &txq->bc_tbl.dma);
					  &txq->bc_tbl.dma);
	if (!txq->bc_tbl.addr) {
	if (!txq->bc_tbl.addr) {
		IWL_ERR(trans, "Scheduler BC Table allocation failed\n");
		IWL_ERR(trans, "Scheduler BC Table allocation failed\n");
		kfree(txq);
		kfree(txq);
		return -ENOMEM;
		return ERR_PTR(-ENOMEM);
	}
	}


	ret = iwl_txq_alloc(trans, txq, size, false);
	ret = iwl_txq_alloc(trans, txq, size, false);
@@ -1124,12 +1123,11 @@ static int iwl_txq_dyn_alloc_dma(struct iwl_trans *trans,


	txq->wd_timeout = msecs_to_jiffies(timeout);
	txq->wd_timeout = msecs_to_jiffies(timeout);


	*intxq = txq;
	return txq;
	return 0;


error:
error:
	iwl_txq_gen2_free_memory(trans, txq);
	iwl_txq_gen2_free_memory(trans, txq);
	return ret;
	return ERR_PTR(ret);
}
}


static int iwl_txq_alloc_response(struct iwl_trans *trans, struct iwl_txq *txq,
static int iwl_txq_alloc_response(struct iwl_trans *trans, struct iwl_txq *txq,
@@ -1189,7 +1187,7 @@ static int iwl_txq_alloc_response(struct iwl_trans *trans, struct iwl_txq *txq,
int iwl_txq_dyn_alloc(struct iwl_trans *trans, __le16 flags, u8 sta_id, u8 tid,
int iwl_txq_dyn_alloc(struct iwl_trans *trans, __le16 flags, u8 sta_id, u8 tid,
		      int cmd_id, int size, unsigned int timeout)
		      int cmd_id, int size, unsigned int timeout)
{
{
	struct iwl_txq *txq = NULL;
	struct iwl_txq *txq;
	struct iwl_tx_queue_cfg_cmd cmd = {
	struct iwl_tx_queue_cfg_cmd cmd = {
		.flags = flags,
		.flags = flags,
		.sta_id = sta_id,
		.sta_id = sta_id,
@@ -1203,9 +1201,9 @@ int iwl_txq_dyn_alloc(struct iwl_trans *trans, __le16 flags, u8 sta_id, u8 tid,
	};
	};
	int ret;
	int ret;


	ret = iwl_txq_dyn_alloc_dma(trans, &txq, size, timeout);
	txq = iwl_txq_dyn_alloc_dma(trans, size, timeout);
	if (ret)
	if (IS_ERR(txq))
		return ret;
		return PTR_ERR(txq);


	cmd.tfdq_addr = cpu_to_le64(txq->dma_addr);
	cmd.tfdq_addr = cpu_to_le64(txq->dma_addr);
	cmd.byte_cnt_addr = cpu_to_le64(txq->bc_tbl.dma);
	cmd.byte_cnt_addr = cpu_to_le64(txq->bc_tbl.dma);