Commit 8e84a650 authored by Kuan-Wei Chiu's avatar Kuan-Wei Chiu Committed by Herbert Xu
Browse files

crypto: octeontx2 - Remove custom swap functions in favor of built-in sort swap



The custom swap functions used in octeontx2 driver do not perform any
special operations and can be replaced with the built-in swap function
of sort. This change not only reduces code size but also improves
efficiency, especially in scenarios where CONFIG_RETPOLINE is enabled,
as it makes indirect function calls more expensive.

By using the built-in swap, we avoid these costly indirect function
calls, leading to better performance.

Signed-off-by: default avatarKuan-Wei Chiu <visitorckw@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent a304393a
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -1702,14 +1702,6 @@ static int compare_func(const void *lptr, const void *rptr)
	return 0;
}

static void swap_func(void *lptr, void *rptr, int size)
{
	struct cpt_device_desc *ldesc = lptr;
	struct cpt_device_desc *rdesc = rptr;

	swap(*ldesc, *rdesc);
}

int otx2_cpt_crypto_init(struct pci_dev *pdev, struct module *mod,
			 int num_queues, int num_devices)
{
@@ -1739,7 +1731,7 @@ int otx2_cpt_crypto_init(struct pci_dev *pdev, struct module *mod,
		is_crypto_registered = true;
	}
	sort(se_devices.desc, count, sizeof(struct cpt_device_desc),
	     compare_func, swap_func);
	     compare_func, NULL);

unlock:
	mutex_unlock(&mutex);