crypto: qat - refactor ring-related debug functions

Refactor the functions `adf_ring_start()` and `adf_ring_next()` to
improve readability.

This does not introduce any functional change.

Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Ahsan Atta <ahsan.atta@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Giovanni Cabiddu 2025-07-14 08:10:30 +01:00 committed by Herbert Xu
parent 6908c5f4f0
commit 0fab5ee0d4

View File

@ -10,16 +10,21 @@
static DEFINE_MUTEX(ring_read_lock);
static DEFINE_MUTEX(bank_read_lock);
#define ADF_RING_NUM_MSGS(ring) \
(ADF_SIZE_TO_RING_SIZE_IN_BYTES(ring->ring_size) / \
ADF_MSG_SIZE_TO_BYTES(ring->msg_size))
static void *adf_ring_start(struct seq_file *sfile, loff_t *pos)
{
struct adf_etr_ring_data *ring = sfile->private;
unsigned int num_msg = ADF_RING_NUM_MSGS(ring);
loff_t val = *pos;
mutex_lock(&ring_read_lock);
if (*pos == 0)
if (val == 0)
return SEQ_START_TOKEN;
if (*pos >= (ADF_SIZE_TO_RING_SIZE_IN_BYTES(ring->ring_size) /
ADF_MSG_SIZE_TO_BYTES(ring->msg_size)))
if (val >= num_msg)
return NULL;
return ring->base_addr +
@ -29,15 +34,15 @@ static void *adf_ring_start(struct seq_file *sfile, loff_t *pos)
static void *adf_ring_next(struct seq_file *sfile, void *v, loff_t *pos)
{
struct adf_etr_ring_data *ring = sfile->private;
unsigned int num_msg = ADF_RING_NUM_MSGS(ring);
loff_t val = *pos;
if (*pos >= (ADF_SIZE_TO_RING_SIZE_IN_BYTES(ring->ring_size) /
ADF_MSG_SIZE_TO_BYTES(ring->msg_size))) {
(*pos)++;
(*pos)++;
if (val >= num_msg)
return NULL;
}
return ring->base_addr +
(ADF_MSG_SIZE_TO_BYTES(ring->msg_size) * (*pos)++);
return ring->base_addr + (ADF_MSG_SIZE_TO_BYTES(ring->msg_size) * val);
}
static int adf_ring_show(struct seq_file *sfile, void *v)