Commit 82069379 authored by Akinobu Mita's avatar Akinobu Mita Committed by James Bottomley

[SCSI] scsi_debug: simplify creation and destruction of driver attribute files

Instead of repeatedly calling driver_create_file() to create driver
attribute files, This achieves the same thing by constructing an array
of driver_attribute and setting it to bus_type->drv_groups.

This change simplifies both creation and destruction of the attribute
files, and also removes sparse warning caused by driver_attributes which
are unnecessarily declared as global.
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 319e2e3f
...@@ -2873,13 +2873,13 @@ static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host) ...@@ -2873,13 +2873,13 @@ static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host)
return 0; return 0;
} }
static ssize_t sdebug_delay_show(struct device_driver * ddp, char * buf) static ssize_t delay_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_delay); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_delay);
} }
static ssize_t sdebug_delay_store(struct device_driver * ddp, static ssize_t delay_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int delay; int delay;
char work[20]; char work[20];
...@@ -2892,16 +2892,15 @@ static ssize_t sdebug_delay_store(struct device_driver * ddp, ...@@ -2892,16 +2892,15 @@ static ssize_t sdebug_delay_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(delay, S_IRUGO | S_IWUSR, sdebug_delay_show, static DRIVER_ATTR_RW(delay);
sdebug_delay_store);
static ssize_t sdebug_opts_show(struct device_driver * ddp, char * buf) static ssize_t opts_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "0x%x\n", scsi_debug_opts); return scnprintf(buf, PAGE_SIZE, "0x%x\n", scsi_debug_opts);
} }
static ssize_t sdebug_opts_store(struct device_driver * ddp, static ssize_t opts_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int opts; int opts;
char work[20]; char work[20];
...@@ -2921,15 +2920,14 @@ static ssize_t sdebug_opts_store(struct device_driver * ddp, ...@@ -2921,15 +2920,14 @@ static ssize_t sdebug_opts_store(struct device_driver * ddp,
scsi_debug_cmnd_count = 0; scsi_debug_cmnd_count = 0;
return count; return count;
} }
DRIVER_ATTR(opts, S_IRUGO | S_IWUSR, sdebug_opts_show, static DRIVER_ATTR_RW(opts);
sdebug_opts_store);
static ssize_t sdebug_ptype_show(struct device_driver * ddp, char * buf) static ssize_t ptype_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_ptype); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_ptype);
} }
static ssize_t sdebug_ptype_store(struct device_driver * ddp, static ssize_t ptype_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int n; int n;
...@@ -2939,14 +2937,14 @@ static ssize_t sdebug_ptype_store(struct device_driver * ddp, ...@@ -2939,14 +2937,14 @@ static ssize_t sdebug_ptype_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(ptype, S_IRUGO | S_IWUSR, sdebug_ptype_show, sdebug_ptype_store); static DRIVER_ATTR_RW(ptype);
static ssize_t sdebug_dsense_show(struct device_driver * ddp, char * buf) static ssize_t dsense_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dsense); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dsense);
} }
static ssize_t sdebug_dsense_store(struct device_driver * ddp, static ssize_t dsense_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int n; int n;
...@@ -2956,15 +2954,14 @@ static ssize_t sdebug_dsense_store(struct device_driver * ddp, ...@@ -2956,15 +2954,14 @@ static ssize_t sdebug_dsense_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(dsense, S_IRUGO | S_IWUSR, sdebug_dsense_show, static DRIVER_ATTR_RW(dsense);
sdebug_dsense_store);
static ssize_t sdebug_fake_rw_show(struct device_driver * ddp, char * buf) static ssize_t fake_rw_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_fake_rw); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_fake_rw);
} }
static ssize_t sdebug_fake_rw_store(struct device_driver * ddp, static ssize_t fake_rw_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int n; int n;
...@@ -2974,15 +2971,14 @@ static ssize_t sdebug_fake_rw_store(struct device_driver * ddp, ...@@ -2974,15 +2971,14 @@ static ssize_t sdebug_fake_rw_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(fake_rw, S_IRUGO | S_IWUSR, sdebug_fake_rw_show, static DRIVER_ATTR_RW(fake_rw);
sdebug_fake_rw_store);
static ssize_t sdebug_no_lun_0_show(struct device_driver * ddp, char * buf) static ssize_t no_lun_0_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_no_lun_0); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_no_lun_0);
} }
static ssize_t sdebug_no_lun_0_store(struct device_driver * ddp, static ssize_t no_lun_0_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int n; int n;
...@@ -2992,15 +2988,14 @@ static ssize_t sdebug_no_lun_0_store(struct device_driver * ddp, ...@@ -2992,15 +2988,14 @@ static ssize_t sdebug_no_lun_0_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(no_lun_0, S_IRUGO | S_IWUSR, sdebug_no_lun_0_show, static DRIVER_ATTR_RW(no_lun_0);
sdebug_no_lun_0_store);
static ssize_t sdebug_num_tgts_show(struct device_driver * ddp, char * buf) static ssize_t num_tgts_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_num_tgts); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_num_tgts);
} }
static ssize_t sdebug_num_tgts_store(struct device_driver * ddp, static ssize_t num_tgts_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int n; int n;
...@@ -3011,27 +3006,26 @@ static ssize_t sdebug_num_tgts_store(struct device_driver * ddp, ...@@ -3011,27 +3006,26 @@ static ssize_t sdebug_num_tgts_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(num_tgts, S_IRUGO | S_IWUSR, sdebug_num_tgts_show, static DRIVER_ATTR_RW(num_tgts);
sdebug_num_tgts_store);
static ssize_t sdebug_dev_size_mb_show(struct device_driver * ddp, char * buf) static ssize_t dev_size_mb_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dev_size_mb); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dev_size_mb);
} }
DRIVER_ATTR(dev_size_mb, S_IRUGO, sdebug_dev_size_mb_show, NULL); static DRIVER_ATTR_RO(dev_size_mb);
static ssize_t sdebug_num_parts_show(struct device_driver * ddp, char * buf) static ssize_t num_parts_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_num_parts); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_num_parts);
} }
DRIVER_ATTR(num_parts, S_IRUGO, sdebug_num_parts_show, NULL); static DRIVER_ATTR_RO(num_parts);
static ssize_t sdebug_every_nth_show(struct device_driver * ddp, char * buf) static ssize_t every_nth_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_every_nth); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_every_nth);
} }
static ssize_t sdebug_every_nth_store(struct device_driver * ddp, static ssize_t every_nth_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int nth; int nth;
...@@ -3042,15 +3036,14 @@ static ssize_t sdebug_every_nth_store(struct device_driver * ddp, ...@@ -3042,15 +3036,14 @@ static ssize_t sdebug_every_nth_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(every_nth, S_IRUGO | S_IWUSR, sdebug_every_nth_show, static DRIVER_ATTR_RW(every_nth);
sdebug_every_nth_store);
static ssize_t sdebug_max_luns_show(struct device_driver * ddp, char * buf) static ssize_t max_luns_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_max_luns); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_max_luns);
} }
static ssize_t sdebug_max_luns_store(struct device_driver * ddp, static ssize_t max_luns_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int n; int n;
...@@ -3061,15 +3054,14 @@ static ssize_t sdebug_max_luns_store(struct device_driver * ddp, ...@@ -3061,15 +3054,14 @@ static ssize_t sdebug_max_luns_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(max_luns, S_IRUGO | S_IWUSR, sdebug_max_luns_show, static DRIVER_ATTR_RW(max_luns);
sdebug_max_luns_store);
static ssize_t sdebug_max_queue_show(struct device_driver * ddp, char * buf) static ssize_t max_queue_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_max_queue); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_max_queue);
} }
static ssize_t sdebug_max_queue_store(struct device_driver * ddp, static ssize_t max_queue_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int n; int n;
...@@ -3080,27 +3072,26 @@ static ssize_t sdebug_max_queue_store(struct device_driver * ddp, ...@@ -3080,27 +3072,26 @@ static ssize_t sdebug_max_queue_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(max_queue, S_IRUGO | S_IWUSR, sdebug_max_queue_show, static DRIVER_ATTR_RW(max_queue);
sdebug_max_queue_store);
static ssize_t sdebug_no_uld_show(struct device_driver * ddp, char * buf) static ssize_t no_uld_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_no_uld); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_no_uld);
} }
DRIVER_ATTR(no_uld, S_IRUGO, sdebug_no_uld_show, NULL); static DRIVER_ATTR_RO(no_uld);
static ssize_t sdebug_scsi_level_show(struct device_driver * ddp, char * buf) static ssize_t scsi_level_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_scsi_level); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_scsi_level);
} }
DRIVER_ATTR(scsi_level, S_IRUGO, sdebug_scsi_level_show, NULL); static DRIVER_ATTR_RO(scsi_level);
static ssize_t sdebug_virtual_gb_show(struct device_driver * ddp, char * buf) static ssize_t virtual_gb_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_virtual_gb); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_virtual_gb);
} }
static ssize_t sdebug_virtual_gb_store(struct device_driver * ddp, static ssize_t virtual_gb_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int n; int n;
...@@ -3113,16 +3104,15 @@ static ssize_t sdebug_virtual_gb_store(struct device_driver * ddp, ...@@ -3113,16 +3104,15 @@ static ssize_t sdebug_virtual_gb_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(virtual_gb, S_IRUGO | S_IWUSR, sdebug_virtual_gb_show, static DRIVER_ATTR_RW(virtual_gb);
sdebug_virtual_gb_store);
static ssize_t sdebug_add_host_show(struct device_driver * ddp, char * buf) static ssize_t add_host_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_add_host); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_add_host);
} }
static ssize_t sdebug_add_host_store(struct device_driver * ddp, static ssize_t add_host_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int delta_hosts; int delta_hosts;
...@@ -3139,16 +3129,14 @@ static ssize_t sdebug_add_host_store(struct device_driver * ddp, ...@@ -3139,16 +3129,14 @@ static ssize_t sdebug_add_host_store(struct device_driver * ddp,
} }
return count; return count;
} }
DRIVER_ATTR(add_host, S_IRUGO | S_IWUSR, sdebug_add_host_show, static DRIVER_ATTR_RW(add_host);
sdebug_add_host_store);
static ssize_t sdebug_vpd_use_hostno_show(struct device_driver * ddp, static ssize_t vpd_use_hostno_show(struct device_driver *ddp, char *buf)
char * buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_vpd_use_hostno); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_vpd_use_hostno);
} }
static ssize_t sdebug_vpd_use_hostno_store(struct device_driver * ddp, static ssize_t vpd_use_hostno_store(struct device_driver *ddp, const char *buf,
const char * buf, size_t count) size_t count)
{ {
int n; int n;
...@@ -3158,40 +3146,39 @@ static ssize_t sdebug_vpd_use_hostno_store(struct device_driver * ddp, ...@@ -3158,40 +3146,39 @@ static ssize_t sdebug_vpd_use_hostno_store(struct device_driver * ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(vpd_use_hostno, S_IRUGO | S_IWUSR, sdebug_vpd_use_hostno_show, static DRIVER_ATTR_RW(vpd_use_hostno);
sdebug_vpd_use_hostno_store);
static ssize_t sdebug_sector_size_show(struct device_driver * ddp, char * buf) static ssize_t sector_size_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%u\n", scsi_debug_sector_size); return scnprintf(buf, PAGE_SIZE, "%u\n", scsi_debug_sector_size);
} }
DRIVER_ATTR(sector_size, S_IRUGO, sdebug_sector_size_show, NULL); static DRIVER_ATTR_RO(sector_size);
static ssize_t sdebug_dix_show(struct device_driver *ddp, char *buf) static ssize_t dix_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dix); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dix);
} }
DRIVER_ATTR(dix, S_IRUGO, sdebug_dix_show, NULL); static DRIVER_ATTR_RO(dix);
static ssize_t sdebug_dif_show(struct device_driver *ddp, char *buf) static ssize_t dif_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dif); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_dif);
} }
DRIVER_ATTR(dif, S_IRUGO, sdebug_dif_show, NULL); static DRIVER_ATTR_RO(dif);
static ssize_t sdebug_guard_show(struct device_driver *ddp, char *buf) static ssize_t guard_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%u\n", scsi_debug_guard); return scnprintf(buf, PAGE_SIZE, "%u\n", scsi_debug_guard);
} }
DRIVER_ATTR(guard, S_IRUGO, sdebug_guard_show, NULL); static DRIVER_ATTR_RO(guard);
static ssize_t sdebug_ato_show(struct device_driver *ddp, char *buf) static ssize_t ato_show(struct device_driver *ddp, char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_ato); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_ato);
} }
DRIVER_ATTR(ato, S_IRUGO, sdebug_ato_show, NULL); static DRIVER_ATTR_RO(ato);
static ssize_t sdebug_map_show(struct device_driver *ddp, char *buf) static ssize_t map_show(struct device_driver *ddp, char *buf)
{ {
ssize_t count; ssize_t count;
...@@ -3206,15 +3193,14 @@ static ssize_t sdebug_map_show(struct device_driver *ddp, char *buf) ...@@ -3206,15 +3193,14 @@ static ssize_t sdebug_map_show(struct device_driver *ddp, char *buf)
return count; return count;
} }
DRIVER_ATTR(map, S_IRUGO, sdebug_map_show, NULL); static DRIVER_ATTR_RO(map);
static ssize_t sdebug_removable_show(struct device_driver *ddp, static ssize_t removable_show(struct device_driver *ddp, char *buf)
char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_removable ? 1 : 0); return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_removable ? 1 : 0);
} }
static ssize_t sdebug_removable_store(struct device_driver *ddp, static ssize_t removable_store(struct device_driver *ddp, const char *buf,
const char *buf, size_t count) size_t count)
{ {
int n; int n;
...@@ -3224,74 +3210,43 @@ static ssize_t sdebug_removable_store(struct device_driver *ddp, ...@@ -3224,74 +3210,43 @@ static ssize_t sdebug_removable_store(struct device_driver *ddp,
} }
return -EINVAL; return -EINVAL;
} }
DRIVER_ATTR(removable, S_IRUGO | S_IWUSR, sdebug_removable_show, static DRIVER_ATTR_RW(removable);
sdebug_removable_store);
/* Note: The following array creates attribute files in the
/* Note: The following function creates attribute files in the
/sys/bus/pseudo/drivers/scsi_debug directory. The advantage of these /sys/bus/pseudo/drivers/scsi_debug directory. The advantage of these
files (over those found in the /sys/module/scsi_debug/parameters files (over those found in the /sys/module/scsi_debug/parameters
directory) is that auxiliary actions can be triggered when an attribute directory) is that auxiliary actions can be triggered when an attribute
is changed. For example see: sdebug_add_host_store() above. is changed. For example see: sdebug_add_host_store() above.
*/ */
static int do_create_driverfs_files(void)
{
int ret;
ret = driver_create_file(&sdebug_driverfs_driver, &driver_attr_add_host); static struct attribute *sdebug_drv_attrs[] = {
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_delay); &driver_attr_delay.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_dev_size_mb); &driver_attr_opts.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_dsense); &driver_attr_ptype.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_every_nth); &driver_attr_dsense.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_fake_rw); &driver_attr_fake_rw.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_max_luns); &driver_attr_no_lun_0.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_max_queue); &driver_attr_num_tgts.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_no_lun_0); &driver_attr_dev_size_mb.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_no_uld); &driver_attr_num_parts.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_num_parts); &driver_attr_every_nth.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_num_tgts); &driver_attr_max_luns.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_ptype); &driver_attr_max_queue.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_opts); &driver_attr_no_uld.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_removable); &driver_attr_scsi_level.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_scsi_level); &driver_attr_virtual_gb.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_virtual_gb); &driver_attr_add_host.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_vpd_use_hostno); &driver_attr_vpd_use_hostno.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_sector_size); &driver_attr_sector_size.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_dix); &driver_attr_dix.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_dif); &driver_attr_dif.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_guard); &driver_attr_guard.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_ato); &driver_attr_ato.attr,
ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_map); &driver_attr_map.attr,
return ret; &driver_attr_removable.attr,
} NULL,
};
static void do_remove_driverfs_files(void) ATTRIBUTE_GROUPS(sdebug_drv);
{
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_map);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_ato);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_guard);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_dif);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_dix);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_sector_size);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_vpd_use_hostno);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_virtual_gb);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_scsi_level);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_opts);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_ptype);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_removable);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_num_tgts);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_num_parts);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_no_uld);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_no_lun_0);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_max_queue);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_max_luns);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_fake_rw);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_every_nth);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_dsense);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_dev_size_mb);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_delay);
driver_remove_file(&sdebug_driverfs_driver, &driver_attr_add_host);
}
struct device *pseudo_primary; struct device *pseudo_primary;
...@@ -3456,12 +3411,6 @@ static int __init scsi_debug_init(void) ...@@ -3456,12 +3411,6 @@ static int __init scsi_debug_init(void)
ret); ret);
goto bus_unreg; goto bus_unreg;
} }
ret = do_create_driverfs_files();
if (ret < 0) {
printk(KERN_WARNING "scsi_debug: driver_create_file error: %d\n",
ret);
goto del_files;
}
init_all_queued(); init_all_queued();
...@@ -3482,9 +3431,6 @@ static int __init scsi_debug_init(void) ...@@ -3482,9 +3431,6 @@ static int __init scsi_debug_init(void)
} }
return 0; return 0;
del_files:
do_remove_driverfs_files();
driver_unregister(&sdebug_driverfs_driver);
bus_unreg: bus_unreg:
bus_unregister(&pseudo_lld_bus); bus_unregister(&pseudo_lld_bus);
dev_unreg: dev_unreg:
...@@ -3506,7 +3452,6 @@ static void __exit scsi_debug_exit(void) ...@@ -3506,7 +3452,6 @@ static void __exit scsi_debug_exit(void)
stop_all_queued(); stop_all_queued();
for (; k; k--) for (; k; k--)
sdebug_remove_adapter(); sdebug_remove_adapter();
do_remove_driverfs_files();
driver_unregister(&sdebug_driverfs_driver); driver_unregister(&sdebug_driverfs_driver);
bus_unregister(&pseudo_lld_bus); bus_unregister(&pseudo_lld_bus);
root_device_unregister(pseudo_primary); root_device_unregister(pseudo_primary);
...@@ -4096,4 +4041,5 @@ static struct bus_type pseudo_lld_bus = { ...@@ -4096,4 +4041,5 @@ static struct bus_type pseudo_lld_bus = {
.match = pseudo_lld_bus_match, .match = pseudo_lld_bus_match,
.probe = sdebug_driver_probe, .probe = sdebug_driver_probe,
.remove = sdebug_driver_remove, .remove = sdebug_driver_remove,
.drv_groups = sdebug_drv_groups,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment