Skip to content

Commit

Permalink
crypto: qat - Use list_for_each_entry() helper
Browse files Browse the repository at this point in the history
Convert list_for_each() to list_for_each_entry() so that the list_itr
list_head pointer and list_entry() call are no longer needed, which
can reduce a few lines of code. No functional changed.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Jinjie Ruan authored and Herbert Xu committed Sep 15, 2023
1 parent 7b3c234 commit 65029ee
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions drivers/crypto/intel/qat/qat_common/adf_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ int adf_service_unregister(struct service_hndl *service)
static int adf_dev_init(struct adf_accel_dev *accel_dev)
{
struct service_hndl *service;
struct list_head *list_itr;
struct adf_hw_device_data *hw_data = accel_dev->hw_device;
int ret;

Expand Down Expand Up @@ -137,8 +136,7 @@ static int adf_dev_init(struct adf_accel_dev *accel_dev)
* This is to facilitate any ordering dependencies between services
* prior to starting any of the accelerators.
*/
list_for_each(list_itr, &service_table) {
service = list_entry(list_itr, struct service_hndl, list);
list_for_each_entry(service, &service_table, list) {
if (service->event_hld(accel_dev, ADF_EVENT_INIT)) {
dev_err(&GET_DEV(accel_dev),
"Failed to initialise service %s\n",
Expand All @@ -165,7 +163,6 @@ static int adf_dev_start(struct adf_accel_dev *accel_dev)
{
struct adf_hw_device_data *hw_data = accel_dev->hw_device;
struct service_hndl *service;
struct list_head *list_itr;
int ret;

set_bit(ADF_STATUS_STARTING, &accel_dev->status);
Expand Down Expand Up @@ -209,8 +206,7 @@ static int adf_dev_start(struct adf_accel_dev *accel_dev)

adf_heartbeat_start(accel_dev);

list_for_each(list_itr, &service_table) {
service = list_entry(list_itr, struct service_hndl, list);
list_for_each_entry(service, &service_table, list) {
if (service->event_hld(accel_dev, ADF_EVENT_START)) {
dev_err(&GET_DEV(accel_dev),
"Failed to start service %s\n",
Expand Down Expand Up @@ -259,7 +255,6 @@ static void adf_dev_stop(struct adf_accel_dev *accel_dev)
{
struct adf_hw_device_data *hw_data = accel_dev->hw_device;
struct service_hndl *service;
struct list_head *list_itr;
bool wait = false;
int ret;

Expand All @@ -280,8 +275,7 @@ static void adf_dev_stop(struct adf_accel_dev *accel_dev)
if (!list_empty(&accel_dev->compression_list))
qat_comp_algs_unregister();

list_for_each(list_itr, &service_table) {
service = list_entry(list_itr, struct service_hndl, list);
list_for_each_entry(service, &service_table, list) {
if (!test_bit(accel_dev->accel_id, service->start_status))
continue;
ret = service->event_hld(accel_dev, ADF_EVENT_STOP);
Expand Down Expand Up @@ -318,7 +312,6 @@ static void adf_dev_shutdown(struct adf_accel_dev *accel_dev)
{
struct adf_hw_device_data *hw_data = accel_dev->hw_device;
struct service_hndl *service;
struct list_head *list_itr;

if (!hw_data) {
dev_err(&GET_DEV(accel_dev),
Expand All @@ -340,8 +333,7 @@ static void adf_dev_shutdown(struct adf_accel_dev *accel_dev)
&accel_dev->status);
}

list_for_each(list_itr, &service_table) {
service = list_entry(list_itr, struct service_hndl, list);
list_for_each_entry(service, &service_table, list) {
if (!test_bit(accel_dev->accel_id, service->init_status))
continue;
if (service->event_hld(accel_dev, ADF_EVENT_SHUTDOWN))
Expand Down Expand Up @@ -378,10 +370,8 @@ static void adf_dev_shutdown(struct adf_accel_dev *accel_dev)
int adf_dev_restarting_notify(struct adf_accel_dev *accel_dev)
{
struct service_hndl *service;
struct list_head *list_itr;

list_for_each(list_itr, &service_table) {
service = list_entry(list_itr, struct service_hndl, list);
list_for_each_entry(service, &service_table, list) {
if (service->event_hld(accel_dev, ADF_EVENT_RESTARTING))
dev_err(&GET_DEV(accel_dev),
"Failed to restart service %s.\n",
Expand All @@ -393,10 +383,8 @@ int adf_dev_restarting_notify(struct adf_accel_dev *accel_dev)
int adf_dev_restarted_notify(struct adf_accel_dev *accel_dev)
{
struct service_hndl *service;
struct list_head *list_itr;

list_for_each(list_itr, &service_table) {
service = list_entry(list_itr, struct service_hndl, list);
list_for_each_entry(service, &service_table, list) {
if (service->event_hld(accel_dev, ADF_EVENT_RESTARTED))
dev_err(&GET_DEV(accel_dev),
"Failed to restart service %s.\n",
Expand Down

0 comments on commit 65029ee

Please sign in to comment.