]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
target: Use LIST_HEAD()/DEFINE_MUTEX() for static objects
authorRoland Dreier <roland@purestorage.com>
Thu, 12 Jan 2012 18:41:18 +0000 (10:41 -0800)
committerNicholas Bellinger <nab@linux-iscsi.org>
Sat, 25 Feb 2012 22:37:46 +0000 (14:37 -0800)
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>
drivers/target/iscsi/iscsi_target_tq.c
drivers/target/target_core_configfs.c
drivers/target/target_core_pr.c

index 0baac5bcebd450d583058dd9218745e309404d07..977e1cf90e83e9b98eee725d82efc4032d903e04 100644 (file)
@@ -536,12 +536,6 @@ int iscsi_thread_set_init(void)
                return -ENOMEM;
        }
 
-       spin_lock_init(&active_ts_lock);
-       spin_lock_init(&inactive_ts_lock);
-       spin_lock_init(&ts_bitmap_lock);
-       INIT_LIST_HEAD(&active_ts_list);
-       INIT_LIST_HEAD(&inactive_ts_list);
-
        return 0;
 }
 
index 6e043eeb1db9c4449edfb4a4385184de1c0633fa..0700d3b3d1c0b57106b0df52178ebcd32a17bdb1 100644 (file)
@@ -52,8 +52,8 @@
 
 extern struct t10_alua_lu_gp *default_lu_gp;
 
-static struct list_head g_tf_list;
-static struct mutex g_tf_lock;
+static LIST_HEAD(g_tf_list);
+static DEFINE_MUTEX(g_tf_lock);
 
 struct target_core_configfs_attribute {
        struct configfs_attribute attr;
@@ -3117,8 +3117,6 @@ static int __init target_core_init_configfs(void)
        config_group_init(&subsys->su_group);
        mutex_init(&subsys->su_mutex);
 
-       INIT_LIST_HEAD(&g_tf_list);
-       mutex_init(&g_tf_lock);
        ret = init_se_kmem_caches();
        if (ret < 0)
                return ret;
index b7c779389eea6820c34c5f9d6a6dafc98638c932..6beada82016589d3ea8185ef9b49ca4aa7031314 100644 (file)
@@ -1487,7 +1487,7 @@ static int core_scsi3_decode_spec_i_port(
        struct se_dev_entry *dest_se_deve = NULL, *local_se_deve;
        struct t10_pr_registration *dest_pr_reg, *local_pr_reg, *pr_reg_e;
        struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe;
-       struct list_head tid_dest_list;
+       LIST_HEAD(tid_dest_list);
        struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp;
        struct target_core_fabric_ops *tmp_tf_ops;
        unsigned char *buf;
@@ -1498,7 +1498,6 @@ static int core_scsi3_decode_spec_i_port(
        u32 dest_rtpi = 0;
 
        memset(dest_iport, 0, 64);
-       INIT_LIST_HEAD(&tid_dest_list);
 
        local_se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun];
        /*
@@ -2994,7 +2993,7 @@ static int core_scsi3_pro_preempt(
        struct se_dev_entry *se_deve;
        struct se_node_acl *pr_reg_nacl;
        struct se_session *se_sess = cmd->se_sess;
-       struct list_head preempt_and_abort_list;
+       LIST_HEAD(preempt_and_abort_list);
        struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder;
        struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr;
        u32 pr_res_mapped_lun = 0;
@@ -3027,7 +3026,6 @@ static int core_scsi3_pro_preempt(
                cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST;
                return -EINVAL;
        }
-       INIT_LIST_HEAD(&preempt_and_abort_list);
 
        spin_lock(&dev->dev_reservation_lock);
        pr_res_holder = dev->dev_pr_res_holder;