Commit 4e5ba3ff authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

[PATCH] get rid of ->detect for upper layer drivers

Okay, we're finally at the point where ->detect has become entirely
superflous.  In sd, sr and st it does nothing but return different
values that are ignored anyway, in sg it increments a variable
that is never read (and thus removed in this patch aswell), only
in osst it increments a variable that is actually checked for beeing
non-zero.  But if it was zero we'd never reached that place anyway
(same check in the beginning of osst_detect and osst_attach).

This make the upper layer interface a lot nicer and avoids the
race condition where a device is remove between detect and attach
(which currently wouldn't matter anyway as we aren't doing anything
in detect anymore)
parent 24e696ca
...@@ -554,7 +554,6 @@ struct Scsi_Device_Template ...@@ -554,7 +554,6 @@ struct Scsi_Device_Template
const char * tag; const char * tag;
struct module * module; /* Used for loadable modules */ struct module * module; /* Used for loadable modules */
unsigned char scsi_type; unsigned char scsi_type;
int (*detect)(Scsi_Device *); /* Returns 1 if we can attach this device */
int (*attach)(Scsi_Device *); /* Attach devices to arrays */ int (*attach)(Scsi_Device *); /* Attach devices to arrays */
void (*detach)(Scsi_Device *); void (*detach)(Scsi_Device *);
int (*init_command)(Scsi_Cmnd *); /* Used by new queueing code. int (*init_command)(Scsi_Cmnd *); /* Used by new queueing code.
......
...@@ -153,10 +153,8 @@ static int osst_copy_from_buffer(OSST_buffer *, unsigned char *); ...@@ -153,10 +153,8 @@ static int osst_copy_from_buffer(OSST_buffer *, unsigned char *);
static int osst_init(void); static int osst_init(void);
static int osst_attach(Scsi_Device *); static int osst_attach(Scsi_Device *);
static int osst_detect(Scsi_Device *);
static void osst_detach(Scsi_Device *); static void osst_detach(Scsi_Device *);
static int osst_dev_noticed;
static int osst_nr_dev; static int osst_nr_dev;
static int osst_dev_max; static int osst_dev_max;
...@@ -166,7 +164,6 @@ struct Scsi_Device_Template osst_template = ...@@ -166,7 +164,6 @@ struct Scsi_Device_Template osst_template =
name: "OnStream tape", name: "OnStream tape",
tag: "osst", tag: "osst",
scsi_type: TYPE_TAPE, scsi_type: TYPE_TAPE,
detect: osst_detect,
attach: osst_attach, attach: osst_attach,
detach: osst_detach detach: osst_detach
}; };
...@@ -5564,15 +5561,6 @@ static int osst_attach(Scsi_Device * SDp) ...@@ -5564,15 +5561,6 @@ static int osst_attach(Scsi_Device * SDp)
return 0; return 0;
}; };
static int osst_detect(Scsi_Device * SDp)
{
if (SDp->type != TYPE_TAPE) return 0;
if ( ! osst_supports(SDp) ) return 0;
osst_dev_noticed++;
return 1;
}
static int osst_registered = 0; static int osst_registered = 0;
/* Driver initialization (not __initfunc because may be called later) */ /* Driver initialization (not __initfunc because may be called later) */
...@@ -5580,9 +5568,6 @@ static int osst_init() ...@@ -5580,9 +5568,6 @@ static int osst_init()
{ {
int i; int i;
if (osst_dev_noticed == 0)
return 0;
if (!osst_registered) { if (!osst_registered) {
if (register_chrdev(MAJOR_NR,"osst",&osst_fops)) { if (register_chrdev(MAJOR_NR,"osst",&osst_fops)) {
printk(KERN_ERR "osst :W: Unable to get major %d for OnStream tapes\n",MAJOR_NR); printk(KERN_ERR "osst :W: Unable to get major %d for OnStream tapes\n",MAJOR_NR);
...@@ -5653,7 +5638,6 @@ static void osst_detach(Scsi_Device * SDp) ...@@ -5653,7 +5638,6 @@ static void osst_detach(Scsi_Device * SDp)
os_scsi_tapes[i] = NULL; os_scsi_tapes[i] = NULL;
scsi_slave_detach(SDp); scsi_slave_detach(SDp);
osst_nr_dev--; osst_nr_dev--;
osst_dev_noticed--;
return; return;
} }
} }
......
...@@ -1960,17 +1960,6 @@ static int proc_scsi_gen_write(struct file * file, const char * buf, ...@@ -1960,17 +1960,6 @@ static int proc_scsi_gen_write(struct file * file, const char * buf,
} }
#endif #endif
void scsi_detect_device(struct scsi_device *sdev)
{
struct Scsi_Device_Template *sdt;
down_read(&scsi_devicelist_mutex);
for (sdt = scsi_devicelist; sdt; sdt = sdt->next)
if (sdt->detect)
(*sdt->detect)(sdev);
up_read(&scsi_devicelist_mutex);
}
int scsi_attach_device(struct scsi_device *sdev) int scsi_attach_device(struct scsi_device *sdev)
{ {
struct Scsi_Device_Template *sdt; struct Scsi_Device_Template *sdt;
...@@ -2091,22 +2080,6 @@ int scsi_register_device(struct Scsi_Device_Template *tpnt) ...@@ -2091,22 +2080,6 @@ int scsi_register_device(struct Scsi_Device_Template *tpnt)
driver_register(&tpnt->scsi_driverfs_driver); driver_register(&tpnt->scsi_driverfs_driver);
/*
* First scan the devices that we know about, and see if we notice them.
*/
for (shpnt = scsi_host_get_next(NULL); shpnt;
shpnt = scsi_host_get_next(shpnt)) {
for (SDpnt = shpnt->host_queue; SDpnt;
SDpnt = SDpnt->next) {
if (tpnt->detect)
(*tpnt->detect) (SDpnt);
}
}
/*
* Now actually connect the devices to the new driver.
*/
for (shpnt = scsi_host_get_next(NULL); shpnt; for (shpnt = scsi_host_get_next(NULL); shpnt;
shpnt = scsi_host_get_next(shpnt)) { shpnt = scsi_host_get_next(shpnt)) {
for (SDpnt = shpnt->host_queue; SDpnt; for (SDpnt = shpnt->host_queue; SDpnt;
......
...@@ -481,7 +481,6 @@ extern void scsi_do_cmd(Scsi_Cmnd *, const void *cmnd, ...@@ -481,7 +481,6 @@ extern void scsi_do_cmd(Scsi_Cmnd *, const void *cmnd,
int timeout, int retries); int timeout, int retries);
extern int scsi_dev_init(void); extern int scsi_dev_init(void);
extern int scsi_mlqueue_insert(struct scsi_cmnd *, int); extern int scsi_mlqueue_insert(struct scsi_cmnd *, int);
extern void scsi_detect_device(struct scsi_device *);
extern int scsi_attach_device(struct scsi_device *); extern int scsi_attach_device(struct scsi_device *);
extern void scsi_detach_device(struct scsi_device *); extern void scsi_detach_device(struct scsi_device *);
......
...@@ -1478,8 +1478,6 @@ static int scsi_add_lun(Scsi_Device *sdevscan, Scsi_Device **sdevnew, ...@@ -1478,8 +1478,6 @@ static int scsi_add_lun(Scsi_Device *sdevscan, Scsi_Device **sdevnew,
* function */ * function */
sdev->max_device_blocked = SCSI_DEFAULT_DEVICE_BLOCKED; sdev->max_device_blocked = SCSI_DEFAULT_DEVICE_BLOCKED;
scsi_detect_device(sdev);
if (sdevnew != NULL) if (sdevnew != NULL)
*sdevnew = sdev; *sdevnew = sdev;
......
...@@ -94,7 +94,6 @@ static void sd_init_onedisk(struct scsi_disk * sdkp, struct gendisk *disk); ...@@ -94,7 +94,6 @@ static void sd_init_onedisk(struct scsi_disk * sdkp, struct gendisk *disk);
static void sd_rw_intr(struct scsi_cmnd * SCpnt); static void sd_rw_intr(struct scsi_cmnd * SCpnt);
static int sd_attach(struct scsi_device *); static int sd_attach(struct scsi_device *);
static int sd_detect(struct scsi_device *);
static void sd_detach(struct scsi_device *); static void sd_detach(struct scsi_device *);
static int sd_init_command(struct scsi_cmnd *); static int sd_init_command(struct scsi_cmnd *);
static int sd_synchronize_cache(struct scsi_disk *, int); static int sd_synchronize_cache(struct scsi_disk *, int);
...@@ -107,7 +106,6 @@ static struct Scsi_Device_Template sd_template = { ...@@ -107,7 +106,6 @@ static struct Scsi_Device_Template sd_template = {
.name = "disk", .name = "disk",
.tag = "sd", .tag = "sd",
.scsi_type = TYPE_DISK, .scsi_type = TYPE_DISK,
.detect = sd_detect,
.attach = sd_attach, .attach = sd_attach,
.detach = sd_detach, .detach = sd_detach,
.init_command = sd_init_command, .init_command = sd_init_command,
...@@ -1165,23 +1163,6 @@ sd_init_onedisk(struct scsi_disk * sdkp, struct gendisk *disk) ...@@ -1165,23 +1163,6 @@ sd_init_onedisk(struct scsi_disk * sdkp, struct gendisk *disk)
kfree(buffer); kfree(buffer);
} }
/**
* sd_detect - called at the start of driver initialization, once
* for each scsi device (not just disks) present.
*
* Returns 0 if not interested in this scsi device (e.g. scanner);
* 1 if this device is of interest (e.g. a disk).
*
* Note: this function is invoked from the scsi mid-level.
**/
static int sd_detect(struct scsi_device * sdp)
{
SCSI_LOG_HLQUEUE(3, printk("sd_detect: type=%d\n", sdp->type));
if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD)
return 0;
return 1;
}
/** /**
* sd_attach - called during driver initialization and whenever a * sd_attach - called during driver initialization and whenever a
* new scsi device is attached to the system. It is called once * new scsi device is attached to the system. It is called once
......
...@@ -111,7 +111,6 @@ static int sg_allow_dio = SG_ALLOW_DIO_DEF; ...@@ -111,7 +111,6 @@ static int sg_allow_dio = SG_ALLOW_DIO_DEF;
#define SG_DEV_ARR_LUMP 6 /* amount to over allocate sg_dev_arr by */ #define SG_DEV_ARR_LUMP 6 /* amount to over allocate sg_dev_arr by */
static int sg_attach(Scsi_Device *); static int sg_attach(Scsi_Device *);
static int sg_detect(Scsi_Device *);
static void sg_detach(Scsi_Device *); static void sg_detach(Scsi_Device *);
static Scsi_Request *dummy_cmdp; /* only used for sizeof */ static Scsi_Request *dummy_cmdp; /* only used for sizeof */
...@@ -124,7 +123,6 @@ static struct Scsi_Device_Template sg_template = { ...@@ -124,7 +123,6 @@ static struct Scsi_Device_Template sg_template = {
.name = "generic", .name = "generic",
.tag = "sg", .tag = "sg",
.scsi_type = 0xff, .scsi_type = 0xff,
.detect = sg_detect,
.attach = sg_attach, .attach = sg_attach,
.detach = sg_detach .detach = sg_detach
}; };
...@@ -233,7 +231,6 @@ static int sg_last_dev(void); ...@@ -233,7 +231,6 @@ static int sg_last_dev(void);
#endif #endif
static Sg_device **sg_dev_arr = NULL; static Sg_device **sg_dev_arr = NULL;
static int sg_dev_noticed;
static int sg_dev_max; static int sg_dev_max;
static int sg_nr_dev; static int sg_nr_dev;
...@@ -1338,13 +1335,6 @@ static struct file_operations sg_fops = { ...@@ -1338,13 +1335,6 @@ static struct file_operations sg_fops = {
.fasync = sg_fasync, .fasync = sg_fasync,
}; };
static int
sg_detect(Scsi_Device * scsidp)
{
sg_dev_noticed++;
return 1;
}
#ifndef MODULE #ifndef MODULE
static int __init static int __init
sg_def_reserved_size_setup(char *str) sg_def_reserved_size_setup(char *str)
...@@ -1563,7 +1553,6 @@ sg_detach(Scsi_Device * scsidp) ...@@ -1563,7 +1553,6 @@ sg_detach(Scsi_Device * scsidp)
} }
scsi_slave_detach(scsidp); scsi_slave_detach(scsidp);
sg_nr_dev--; sg_nr_dev--;
sg_dev_noticed--; /* from <dan@lectra.fr> */
break; break;
} }
write_unlock_irqrestore(&sg_dev_arr_lock, iflags); write_unlock_irqrestore(&sg_dev_arr_lock, iflags);
......
...@@ -66,7 +66,6 @@ MODULE_PARM(xa_test, "i"); /* see sr_ioctl.c */ ...@@ -66,7 +66,6 @@ MODULE_PARM(xa_test, "i"); /* see sr_ioctl.c */
CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_GENERIC_PACKET) CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_GENERIC_PACKET)
static int sr_attach(struct scsi_device *); static int sr_attach(struct scsi_device *);
static int sr_detect(struct scsi_device *);
static void sr_detach(struct scsi_device *); static void sr_detach(struct scsi_device *);
static int sr_init_command(struct scsi_cmnd *); static int sr_init_command(struct scsi_cmnd *);
...@@ -75,7 +74,6 @@ static struct Scsi_Device_Template sr_template = { ...@@ -75,7 +74,6 @@ static struct Scsi_Device_Template sr_template = {
.name = "cdrom", .name = "cdrom",
.tag = "sr", .tag = "sr",
.scsi_type = TYPE_ROM, .scsi_type = TYPE_ROM,
.detect = sr_detect,
.attach = sr_attach, .attach = sr_attach,
.detach = sr_detach, .detach = sr_detach,
.init_command = sr_init_command .init_command = sr_init_command
...@@ -489,14 +487,6 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose) ...@@ -489,14 +487,6 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose)
return 0; return 0;
} }
static int sr_detect(struct scsi_device * SDp)
{
if (SDp->type != TYPE_ROM && SDp->type != TYPE_WORM)
return 0;
return 1;
}
static int sr_attach(struct scsi_device *sdev) static int sr_attach(struct scsi_device *sdev)
{ {
struct gendisk *disk; struct gendisk *disk;
......
...@@ -170,7 +170,6 @@ static int sgl_map_user_pages(struct scatterlist *, const unsigned int, ...@@ -170,7 +170,6 @@ static int sgl_map_user_pages(struct scatterlist *, const unsigned int,
static int sgl_unmap_user_pages(struct scatterlist *, const unsigned int, int); static int sgl_unmap_user_pages(struct scatterlist *, const unsigned int, int);
static int st_attach(Scsi_Device *); static int st_attach(Scsi_Device *);
static int st_detect(Scsi_Device *);
static void st_detach(Scsi_Device *); static void st_detach(Scsi_Device *);
static struct Scsi_Device_Template st_template = { static struct Scsi_Device_Template st_template = {
...@@ -178,7 +177,6 @@ static struct Scsi_Device_Template st_template = { ...@@ -178,7 +177,6 @@ static struct Scsi_Device_Template st_template = {
.name = "tape", .name = "tape",
.tag = "st", .tag = "st",
.scsi_type = TYPE_TAPE, .scsi_type = TYPE_TAPE,
.detect = st_detect,
.attach = st_attach, .attach = st_attach,
.detach = st_detach .detach = st_detach
}; };
...@@ -3885,13 +3883,6 @@ static int st_attach(Scsi_Device * SDp) ...@@ -3885,13 +3883,6 @@ static int st_attach(Scsi_Device * SDp)
return 0; return 0;
}; };
static int st_detect(Scsi_Device * SDp)
{
if (SDp->type != TYPE_TAPE || st_incompatible(SDp))
return 0;
return 1;
}
static void st_detach(Scsi_Device * SDp) static void st_detach(Scsi_Device * SDp)
{ {
Scsi_Tape *tpnt; Scsi_Tape *tpnt;
......
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