#include <scsi/scsi_driver.h>
#include <scsi/sg.h>
-const static char bsg_version[] = "block layer sg (bsg) 0.4";
+#define BSG_DESCRIPTION "Block layer SCSI generic (bsg) driver"
+#define BSG_VERSION "0.4"
struct bsg_device {
request_queue_t *queue;
static int bsg_device_nr, bsg_minor_idx;
#define BSG_LIST_ARRAY_SIZE 8
-#define bsg_list_idx(minor) ((minor) & (BSG_LIST_ARRAY_SIZE - 1))
static struct hlist_head bsg_device_list[BSG_LIST_ARRAY_SIZE];
static struct class *bsg_class;
return bc;
}
-static inline void
-bsg_add_done_cmd(struct bsg_device *bd, struct bsg_command *bc)
+static inline struct hlist_head *bsg_dev_idx_hash(int index)
{
+ return &bsg_device_list[index & (BSG_LIST_ARRAY_SIZE - 1)];
}
static int bsg_io_schedule(struct bsg_device *bd)
atomic_set(&bd->ref_count, 1);
bd->minor = iminor(inode);
mutex_lock(&bsg_mutex);
- hlist_add_head(&bd->dev_list,
- &bsg_device_list[bd->minor & (BSG_LIST_ARRAY_SIZE - 1)]);
+ hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(bd->minor));
strncpy(bd->name, rq->bsg_dev.class_dev->class_id, sizeof(bd->name) - 1);
dprintk("bound to <%s>, max queue %d\n",
static struct bsg_device *__bsg_get_device(int minor)
{
- struct hlist_head *list;
struct bsg_device *bd = NULL;
struct hlist_node *entry;
mutex_lock(&bsg_mutex);
- list = &bsg_device_list[minor & (BSG_LIST_ARRAY_SIZE - 1)];
- hlist_for_each(entry, list) {
+ hlist_for_each(entry, bsg_dev_idx_hash(minor)) {
bd = hlist_entry(entry, struct bsg_device, dev_list);
if (bd->minor == minor) {
atomic_inc(&bd->ref_count);
if (ret)
goto remove_cdev;
- printk(KERN_INFO "%s loaded (major %d)\n", bsg_version, bsg_major);
+ printk(KERN_INFO BSG_DESCRIPTION " version " BSG_VERSION
+ " loaded (major %d)\n", bsg_major);
return 0;
remove_cdev:
printk(KERN_ERR "bsg: failed register scsi interface %d\n", ret);
}
MODULE_AUTHOR("Jens Axboe");
-MODULE_DESCRIPTION("Block layer SGSI generic (sg) driver");
+MODULE_DESCRIPTION(BSG_DESCRIPTION);
MODULE_LICENSE("GPL");
device_initcall(bsg_init);