aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2007-07-17 06:21:15 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-07-17 06:21:15 -0400
commit1c1133e1ff850279d604581af31a400c830b0393 (patch)
tree4bb102eed5593273405db2171a69ed86692db5ae /block
parent9b9f770cef0037fd0e4d623f31ddfa8acda38205 (diff)
bsg: device hash table cleanup
- kill unused bsg_list_idx macro. - add bsg_dev_idx_hash() that returns an appropriate hlist_head. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r--block/bsg.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/block/bsg.c b/block/bsg.c
index b25378459ff0..55a4303ed21f 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -72,7 +72,6 @@ static DEFINE_MUTEX(bsg_mutex);
72static int bsg_device_nr, bsg_minor_idx; 72static int bsg_device_nr, bsg_minor_idx;
73 73
74#define BSG_LIST_ARRAY_SIZE 8 74#define BSG_LIST_ARRAY_SIZE 8
75#define bsg_list_idx(minor) ((minor) & (BSG_LIST_ARRAY_SIZE - 1))
76static struct hlist_head bsg_device_list[BSG_LIST_ARRAY_SIZE]; 75static struct hlist_head bsg_device_list[BSG_LIST_ARRAY_SIZE];
77 76
78static struct class *bsg_class; 77static struct class *bsg_class;
@@ -139,9 +138,9 @@ out:
139 return bc; 138 return bc;
140} 139}
141 140
142static inline void 141static inline struct hlist_head *bsg_dev_idx_hash(int index)
143bsg_add_done_cmd(struct bsg_device *bd, struct bsg_command *bc)
144{ 142{
143 return &bsg_device_list[index & (BSG_LIST_ARRAY_SIZE - 1)];
145} 144}
146 145
147static int bsg_io_schedule(struct bsg_device *bd) 146static int bsg_io_schedule(struct bsg_device *bd)
@@ -748,8 +747,7 @@ static struct bsg_device *bsg_add_device(struct inode *inode,
748 atomic_set(&bd->ref_count, 1); 747 atomic_set(&bd->ref_count, 1);
749 bd->minor = iminor(inode); 748 bd->minor = iminor(inode);
750 mutex_lock(&bsg_mutex); 749 mutex_lock(&bsg_mutex);
751 hlist_add_head(&bd->dev_list, 750 hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(bd->minor));
752 &bsg_device_list[bd->minor & (BSG_LIST_ARRAY_SIZE - 1)]);
753 751
754 strncpy(bd->name, rq->bsg_dev.class_dev->class_id, sizeof(bd->name) - 1); 752 strncpy(bd->name, rq->bsg_dev.class_dev->class_id, sizeof(bd->name) - 1);
755 dprintk("bound to <%s>, max queue %d\n", 753 dprintk("bound to <%s>, max queue %d\n",
@@ -761,14 +759,12 @@ static struct bsg_device *bsg_add_device(struct inode *inode,
761 759
762static struct bsg_device *__bsg_get_device(int minor) 760static struct bsg_device *__bsg_get_device(int minor)
763{ 761{
764 struct hlist_head *list;
765 struct bsg_device *bd = NULL; 762 struct bsg_device *bd = NULL;
766 struct hlist_node *entry; 763 struct hlist_node *entry;
767 764
768 mutex_lock(&bsg_mutex); 765 mutex_lock(&bsg_mutex);
769 766
770 list = &bsg_device_list[minor & (BSG_LIST_ARRAY_SIZE - 1)]; 767 hlist_for_each(entry, bsg_dev_idx_hash(minor)) {
771 hlist_for_each(entry, list) {
772 bd = hlist_entry(entry, struct bsg_device, dev_list); 768 bd = hlist_entry(entry, struct bsg_device, dev_list);
773 if (bd->minor == minor) { 769 if (bd->minor == minor) {
774 atomic_inc(&bd->ref_count); 770 atomic_inc(&bd->ref_count);