diff options
author | Roland Dreier <roland@purestorage.com> | 2012-01-12 13:41:18 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-02-25 17:37:46 -0500 |
commit | d0f474e501929acdbd116cca39ef083012f70f25 (patch) | |
tree | ce4db92ff234d82c3b61ff05404ed4ae41551770 | |
parent | d5b4a21b3dc116b477c1b1b493233a73aacbb440 (diff) |
target: Use LIST_HEAD()/DEFINE_MUTEX() for static objects
Instead of
static struct list_head foo;
static struct mutex bar;
...
INIT_LIST_HEAD(&foo);
mutex_init(&bar);
just do
static LIST_HEAD(foo);
static DEFINE_MUTEX(bar);
Also remove some superfluous struct list_head and spinlock_t
initialization calls where the variables are already defined using
macros that initialize them.
This saves a decent amount of compiled code too:
add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-178 (-178)
function old new delta
target_core_init_configfs 898 850 -48
core_scsi3_emulate_pro_preempt 1742 1683 -59
iscsi_thread_set_init 159 88 -71
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/iscsi/iscsi_target_tq.c | 6 | ||||
-rw-r--r-- | drivers/target/target_core_configfs.c | 6 | ||||
-rw-r--r-- | drivers/target/target_core_pr.c | 6 |
3 files changed, 4 insertions, 14 deletions
diff --git a/drivers/target/iscsi/iscsi_target_tq.c b/drivers/target/iscsi/iscsi_target_tq.c index 0baac5bcebd4..977e1cf90e83 100644 --- a/drivers/target/iscsi/iscsi_target_tq.c +++ b/drivers/target/iscsi/iscsi_target_tq.c | |||
@@ -536,12 +536,6 @@ int iscsi_thread_set_init(void) | |||
536 | return -ENOMEM; | 536 | return -ENOMEM; |
537 | } | 537 | } |
538 | 538 | ||
539 | spin_lock_init(&active_ts_lock); | ||
540 | spin_lock_init(&inactive_ts_lock); | ||
541 | spin_lock_init(&ts_bitmap_lock); | ||
542 | INIT_LIST_HEAD(&active_ts_list); | ||
543 | INIT_LIST_HEAD(&inactive_ts_list); | ||
544 | |||
545 | return 0; | 539 | return 0; |
546 | } | 540 | } |
547 | 541 | ||
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 6e043eeb1db9..0700d3b3d1c0 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
@@ -52,8 +52,8 @@ | |||
52 | 52 | ||
53 | extern struct t10_alua_lu_gp *default_lu_gp; | 53 | extern struct t10_alua_lu_gp *default_lu_gp; |
54 | 54 | ||
55 | static struct list_head g_tf_list; | 55 | static LIST_HEAD(g_tf_list); |
56 | static struct mutex g_tf_lock; | 56 | static DEFINE_MUTEX(g_tf_lock); |
57 | 57 | ||
58 | struct target_core_configfs_attribute { | 58 | struct target_core_configfs_attribute { |
59 | struct configfs_attribute attr; | 59 | struct configfs_attribute attr; |
@@ -3117,8 +3117,6 @@ static int __init target_core_init_configfs(void) | |||
3117 | config_group_init(&subsys->su_group); | 3117 | config_group_init(&subsys->su_group); |
3118 | mutex_init(&subsys->su_mutex); | 3118 | mutex_init(&subsys->su_mutex); |
3119 | 3119 | ||
3120 | INIT_LIST_HEAD(&g_tf_list); | ||
3121 | mutex_init(&g_tf_lock); | ||
3122 | ret = init_se_kmem_caches(); | 3120 | ret = init_se_kmem_caches(); |
3123 | if (ret < 0) | 3121 | if (ret < 0) |
3124 | return ret; | 3122 | return ret; |
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index b7c779389eea..6beada820165 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c | |||
@@ -1487,7 +1487,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1487 | struct se_dev_entry *dest_se_deve = NULL, *local_se_deve; | 1487 | struct se_dev_entry *dest_se_deve = NULL, *local_se_deve; |
1488 | struct t10_pr_registration *dest_pr_reg, *local_pr_reg, *pr_reg_e; | 1488 | struct t10_pr_registration *dest_pr_reg, *local_pr_reg, *pr_reg_e; |
1489 | struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe; | 1489 | struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe; |
1490 | struct list_head tid_dest_list; | 1490 | LIST_HEAD(tid_dest_list); |
1491 | struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp; | 1491 | struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp; |
1492 | struct target_core_fabric_ops *tmp_tf_ops; | 1492 | struct target_core_fabric_ops *tmp_tf_ops; |
1493 | unsigned char *buf; | 1493 | unsigned char *buf; |
@@ -1498,7 +1498,6 @@ static int core_scsi3_decode_spec_i_port( | |||
1498 | u32 dest_rtpi = 0; | 1498 | u32 dest_rtpi = 0; |
1499 | 1499 | ||
1500 | memset(dest_iport, 0, 64); | 1500 | memset(dest_iport, 0, 64); |
1501 | INIT_LIST_HEAD(&tid_dest_list); | ||
1502 | 1501 | ||
1503 | local_se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 1502 | local_se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
1504 | /* | 1503 | /* |
@@ -2994,7 +2993,7 @@ static int core_scsi3_pro_preempt( | |||
2994 | struct se_dev_entry *se_deve; | 2993 | struct se_dev_entry *se_deve; |
2995 | struct se_node_acl *pr_reg_nacl; | 2994 | struct se_node_acl *pr_reg_nacl; |
2996 | struct se_session *se_sess = cmd->se_sess; | 2995 | struct se_session *se_sess = cmd->se_sess; |
2997 | struct list_head preempt_and_abort_list; | 2996 | LIST_HEAD(preempt_and_abort_list); |
2998 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; | 2997 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; |
2999 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 2998 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
3000 | u32 pr_res_mapped_lun = 0; | 2999 | u32 pr_res_mapped_lun = 0; |
@@ -3027,7 +3026,6 @@ static int core_scsi3_pro_preempt( | |||
3027 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; | 3026 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3028 | return -EINVAL; | 3027 | return -EINVAL; |
3029 | } | 3028 | } |
3030 | INIT_LIST_HEAD(&preempt_and_abort_list); | ||
3031 | 3029 | ||
3032 | spin_lock(&dev->dev_reservation_lock); | 3030 | spin_lock(&dev->dev_reservation_lock); |
3033 | pr_res_holder = dev->dev_pr_res_holder; | 3031 | pr_res_holder = dev->dev_pr_res_holder; |