Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: qat - use list_for_each_entry*

Use list_for_each_entry*() instead of list_for_each*() to simplify
the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Geliang Tang and committed by
Herbert Xu
dc2c6322 e4ae86e2

+12 -29
+4 -9
drivers/crypto/qat/qat_common/adf_ctl_drv.c
··· 255 255 256 256 static int adf_ctl_is_device_in_use(int id) 257 257 { 258 - struct list_head *itr, *head = adf_devmgr_get_head(); 258 + struct adf_accel_dev *dev; 259 259 260 - list_for_each(itr, head) { 261 - struct adf_accel_dev *dev = 262 - list_entry(itr, struct adf_accel_dev, list); 263 - 260 + list_for_each_entry(dev, adf_devmgr_get_head(), list) { 264 261 if (id == dev->accel_id || id == ADF_CFG_ALL_DEVICES) { 265 262 if (adf_devmgr_in_reset(dev) || adf_dev_in_use(dev)) { 266 263 dev_info(&GET_DEV(dev), ··· 272 275 273 276 static int adf_ctl_stop_devices(uint32_t id) 274 277 { 275 - struct list_head *itr, *head = adf_devmgr_get_head(); 278 + struct adf_accel_dev *accel_dev; 276 279 int ret = 0; 277 280 278 - list_for_each_prev(itr, head) { 279 - struct adf_accel_dev *accel_dev = 280 - list_entry(itr, struct adf_accel_dev, list); 281 + list_for_each_entry_reverse(accel_dev, adf_devmgr_get_head(), list) { 281 282 if (id == accel_dev->accel_id || id == ADF_CFG_ALL_DEVICES) { 282 283 if (!adf_dev_started(accel_dev)) 283 284 continue;
+8 -20
drivers/crypto/qat/qat_common/qat_crypto.c
··· 67 67 68 68 static int qat_crypto_free_instances(struct adf_accel_dev *accel_dev) 69 69 { 70 - struct qat_crypto_instance *inst; 71 - struct list_head *list_ptr, *tmp; 70 + struct qat_crypto_instance *inst, *tmp; 72 71 int i; 73 72 74 - list_for_each_safe(list_ptr, tmp, &accel_dev->crypto_list) { 75 - inst = list_entry(list_ptr, struct qat_crypto_instance, list); 76 - 73 + list_for_each_entry_safe(inst, tmp, &accel_dev->crypto_list, list) { 77 74 for (i = 0; i < atomic_read(&inst->refctr); i++) 78 75 qat_crypto_put_instance(inst); 79 76 ··· 86 89 if (inst->pke_rx) 87 90 adf_remove_ring(inst->pke_rx); 88 91 89 - list_del(list_ptr); 92 + list_del(&inst->list); 90 93 kfree(inst); 91 94 } 92 95 return 0; ··· 94 97 95 98 struct qat_crypto_instance *qat_crypto_get_instance_node(int node) 96 99 { 97 - struct adf_accel_dev *accel_dev = NULL; 98 - struct qat_crypto_instance *inst = NULL; 99 - struct list_head *itr; 100 + struct adf_accel_dev *accel_dev = NULL, *tmp_dev; 101 + struct qat_crypto_instance *inst = NULL, *tmp_inst; 100 102 unsigned long best = ~0; 101 103 102 - list_for_each(itr, adf_devmgr_get_head()) { 103 - struct adf_accel_dev *tmp_dev; 104 + list_for_each_entry(tmp_dev, adf_devmgr_get_head(), list) { 104 105 unsigned long ctr; 105 - 106 - tmp_dev = list_entry(itr, struct adf_accel_dev, list); 107 106 108 107 if ((node == dev_to_node(&GET_DEV(tmp_dev)) || 109 108 dev_to_node(&GET_DEV(tmp_dev)) < 0) && ··· 116 123 if (!accel_dev) { 117 124 pr_info("QAT: Could not find a device on node %d\n", node); 118 125 /* Get any started device */ 119 - list_for_each(itr, adf_devmgr_get_head()) { 120 - struct adf_accel_dev *tmp_dev; 121 - 122 - tmp_dev = list_entry(itr, struct adf_accel_dev, list); 126 + list_for_each_entry(tmp_dev, adf_devmgr_get_head(), list) { 123 127 if (adf_dev_started(tmp_dev) && 124 128 !list_empty(&tmp_dev->crypto_list)) { 125 129 accel_dev = tmp_dev; ··· 129 139 return NULL; 130 140 131 141 best = ~0; 132 - list_for_each(itr, &accel_dev->crypto_list) { 133 - struct qat_crypto_instance *tmp_inst; 142 + list_for_each_entry(tmp_inst, &accel_dev->crypto_list, list) { 134 143 unsigned long ctr; 135 144 136 - tmp_inst = list_entry(itr, struct qat_crypto_instance, list); 137 145 ctr = atomic_read(&tmp_inst->refctr); 138 146 if (best > ctr) { 139 147 inst = tmp_inst;