Commit af1cbdf2 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

[PATCH] remove scsi_slave_attach/scsi_slave_detach

I added those two to factor out common code from the upper drivers
a long time ago, but after Doug & Lubens nice work there's nothing
left but incrementing/decrementing a counter in struct scsi_device
that's never used except in the case were we not it must be NULL
because we just walked the chain of drivers to detach every single
one..
parent d35701d1
...@@ -5397,15 +5397,10 @@ static int osst_attach(Scsi_Device * SDp) ...@@ -5397,15 +5397,10 @@ static int osst_attach(Scsi_Device * SDp)
if (SDp->type != TYPE_TAPE || !osst_supports(SDp)) if (SDp->type != TYPE_TAPE || !osst_supports(SDp))
return 1; return 1;
if (scsi_slave_attach(SDp)) {
printk(KERN_ERR "osst :E: Failed to attach scsi slave.\n");
return 1;
}
drive = alloc_disk(1); drive = alloc_disk(1);
if (!drive) { if (!drive) {
printk(KERN_ERR "osst :E: Out of memory. Device not attached.\n"); printk(KERN_ERR "osst :E: Out of memory. Device not attached.\n");
goto out_slave_detach; return 1;
} }
/* if this is the first attach, build the infrastructure */ /* if this is the first attach, build the infrastructure */
...@@ -5581,8 +5576,6 @@ static int osst_attach(Scsi_Device * SDp) ...@@ -5581,8 +5576,6 @@ static int osst_attach(Scsi_Device * SDp)
out_put_disk: out_put_disk:
put_disk(drive); put_disk(drive);
out_slave_detach:
scsi_slave_detach(SDp);
return 1; return 1;
}; };
...@@ -5605,7 +5598,6 @@ static void osst_detach(Scsi_Device * SDp) ...@@ -5605,7 +5598,6 @@ static void osst_detach(Scsi_Device * SDp)
devfs_unregister_tape(tpnt->drive->number); devfs_unregister_tape(tpnt->drive->number);
put_disk(tpnt->drive); put_disk(tpnt->drive);
os_scsi_tapes[i] = NULL; os_scsi_tapes[i] = NULL;
scsi_slave_detach(SDp);
osst_nr_dev--; osst_nr_dev--;
write_unlock(&os_scsi_tapes_lock); write_unlock(&os_scsi_tapes_lock);
for (mode = 0; mode < ST_NBR_MODES; ++mode) { for (mode = 0; mode < ST_NBR_MODES; ++mode) {
......
...@@ -187,14 +187,7 @@ struct scsi_request *scsi_allocate_request(struct scsi_device *sdev) ...@@ -187,14 +187,7 @@ struct scsi_request *scsi_allocate_request(struct scsi_device *sdev)
*/ */
void scsi_release_request(struct scsi_request *sreq) void scsi_release_request(struct scsi_request *sreq)
{ {
if (likely(sreq->sr_command != NULL)) { __scsi_release_request(sreq);
struct request_queue *q = sreq->sr_device->request_queue;
scsi_put_command(sreq->sr_command);
sreq->sr_command = NULL;
scsi_queue_next_request(q, NULL);
}
kfree(sreq); kfree(sreq);
} }
...@@ -1276,39 +1269,6 @@ void scsi_set_device_offline(struct scsi_device *sdev) ...@@ -1276,39 +1269,6 @@ void scsi_set_device_offline(struct scsi_device *sdev)
} }
} }
/*
* Function: scsi_slave_attach()
*
* Purpose: Called from the upper level driver attach to handle common
* attach code.
*
* Arguments: sdev - scsi_device to attach
*
* Returns: 1 on error, 0 on succes
*
* Lock Status: Protected via scsi_devicelist_mutex.
*/
int scsi_slave_attach(struct scsi_device *sdev)
{
sdev->attached++;
return 0;
}
/*
* Function: scsi_slave_detach()
*
* Purpose: Called from the upper level driver attach to handle common
* detach code.
*
* Arguments: sdev - struct scsi_device to detach
*
* Lock Status: Protected via scsi_devicelist_mutex.
*/
void scsi_slave_detach(struct scsi_device *sdev)
{
sdev->attached--;
}
/* /*
* This entry point is called from the upper level module's module_init() * This entry point is called from the upper level module's module_init()
* routine. That implies that when this function is called, the * routine. That implies that when this function is called, the
......
...@@ -261,8 +261,6 @@ extern struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, int flags); ...@@ -261,8 +261,6 @@ extern struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, int flags);
extern void scsi_put_command(struct scsi_cmnd *cmd); extern void scsi_put_command(struct scsi_cmnd *cmd);
extern void scsi_adjust_queue_depth(Scsi_Device *, int, int); extern void scsi_adjust_queue_depth(Scsi_Device *, int, int);
extern int scsi_track_queue_full(Scsi_Device *, int); extern int scsi_track_queue_full(Scsi_Device *, int);
extern int scsi_slave_attach(struct scsi_device *);
extern void scsi_slave_detach(struct scsi_device *);
extern int scsi_device_get(struct scsi_device *); extern int scsi_device_get(struct scsi_device *);
extern void scsi_device_put(struct scsi_device *); extern void scsi_device_put(struct scsi_device *);
extern void scsi_set_device_offline(struct scsi_device *); extern void scsi_set_device_offline(struct scsi_device *);
...@@ -344,8 +342,6 @@ struct scsi_device { ...@@ -344,8 +342,6 @@ struct scsi_device {
* vendor-specific cmd's */ * vendor-specific cmd's */
unsigned sector_size; /* size in bytes */ unsigned sector_size; /* size in bytes */
int attached; /* # of high level drivers attached to
* this */
int access_count; /* Count of open channels/mounts */ int access_count; /* Count of open channels/mounts */
void *hostdata; /* available to low-level driver */ void *hostdata; /* available to low-level driver */
......
...@@ -1269,9 +1269,6 @@ struct scsi_device *scsi_add_device(struct Scsi_Host *shost, ...@@ -1269,9 +1269,6 @@ struct scsi_device *scsi_add_device(struct Scsi_Host *shost,
int scsi_remove_device(struct scsi_device *sdev) int scsi_remove_device(struct scsi_device *sdev)
{ {
scsi_detach_device(sdev); scsi_detach_device(sdev);
if (sdev->attached)
return -EINVAL;
scsi_device_unregister(sdev); scsi_device_unregister(sdev);
return 0; return 0;
} }
......
...@@ -77,8 +77,6 @@ EXPORT_SYMBOL(scsi_sleep); ...@@ -77,8 +77,6 @@ EXPORT_SYMBOL(scsi_sleep);
EXPORT_SYMBOL(scsi_io_completion); EXPORT_SYMBOL(scsi_io_completion);
EXPORT_SYMBOL(scsi_slave_attach);
EXPORT_SYMBOL(scsi_slave_detach);
EXPORT_SYMBOL(scsi_device_get); EXPORT_SYMBOL(scsi_device_get);
EXPORT_SYMBOL(scsi_device_put); EXPORT_SYMBOL(scsi_device_put);
EXPORT_SYMBOL(scsi_add_device); EXPORT_SYMBOL(scsi_add_device);
......
...@@ -1302,14 +1302,10 @@ static int sd_attach(struct scsi_device * sdp) ...@@ -1302,14 +1302,10 @@ static int sd_attach(struct scsi_device * sdp)
SCSI_LOG_HLQUEUE(3, printk("sd_attach: scsi device: <%d,%d,%d,%d>\n", SCSI_LOG_HLQUEUE(3, printk("sd_attach: scsi device: <%d,%d,%d,%d>\n",
sdp->host->host_no, sdp->channel, sdp->id, sdp->lun)); sdp->host->host_no, sdp->channel, sdp->id, sdp->lun));
error = scsi_slave_attach(sdp);
if (error)
goto out;
error = -ENOMEM; error = -ENOMEM;
sdkp = kmalloc(sizeof(*sdkp), GFP_KERNEL); sdkp = kmalloc(sizeof(*sdkp), GFP_KERNEL);
if (!sdkp) if (!sdkp)
goto out_detach; goto out;
gd = alloc_disk(16); gd = alloc_disk(16);
if (!gd) if (!gd)
...@@ -1368,8 +1364,6 @@ static int sd_attach(struct scsi_device * sdp) ...@@ -1368,8 +1364,6 @@ static int sd_attach(struct scsi_device * sdp)
put_disk(gd); put_disk(gd);
out_free: out_free:
kfree(sdkp); kfree(sdkp);
out_detach:
scsi_slave_detach(sdp);
out: out:
return error; return error;
} }
...@@ -1406,7 +1400,6 @@ static void sd_detach(struct scsi_device * sdp) ...@@ -1406,7 +1400,6 @@ static void sd_detach(struct scsi_device * sdp)
sd_devlist_remove(sdkp); sd_devlist_remove(sdkp);
del_gendisk(sdkp->disk); del_gendisk(sdkp->disk);
scsi_slave_detach(sdp);
spin_lock(&sd_index_lock); spin_lock(&sd_index_lock);
clear_bit(sdkp->index, sd_index_bits); clear_bit(sdkp->index, sd_index_bits);
......
...@@ -1359,10 +1359,6 @@ sg_attach(Scsi_Device * scsidp) ...@@ -1359,10 +1359,6 @@ sg_attach(Scsi_Device * scsidp)
if (!disk) if (!disk)
return -ENOMEM; return -ENOMEM;
error = scsi_slave_attach(scsidp);
if (error)
goto out_put;
write_lock_irqsave(&sg_dev_arr_lock, iflags); write_lock_irqsave(&sg_dev_arr_lock, iflags);
if (sg_nr_dev >= sg_dev_max) { /* try to resize */ if (sg_nr_dev >= sg_dev_max) { /* try to resize */
Sg_device **tmp_da; Sg_device **tmp_da;
...@@ -1375,7 +1371,7 @@ sg_attach(Scsi_Device * scsidp) ...@@ -1375,7 +1371,7 @@ sg_attach(Scsi_Device * scsidp)
printk(KERN_ERR printk(KERN_ERR
"sg_attach: device array cannot be resized\n"); "sg_attach: device array cannot be resized\n");
error = -ENOMEM; error = -ENOMEM;
goto out_detach; goto out;
} }
write_lock_irqsave(&sg_dev_arr_lock, iflags); write_lock_irqsave(&sg_dev_arr_lock, iflags);
memset(tmp_da, 0, tmp_dev_max * sizeof (Sg_device *)); memset(tmp_da, 0, tmp_dev_max * sizeof (Sg_device *));
...@@ -1400,7 +1396,7 @@ sg_attach(Scsi_Device * scsidp) ...@@ -1400,7 +1396,7 @@ sg_attach(Scsi_Device * scsidp)
if (NULL != sdp) if (NULL != sdp)
vfree((char *) sdp); vfree((char *) sdp);
error = -ENODEV; error = -ENODEV;
goto out_detach; goto out;
} }
if (k < sg_dev_max) { if (k < sg_dev_max) {
if (NULL == sdp) { if (NULL == sdp) {
...@@ -1416,7 +1412,7 @@ sg_attach(Scsi_Device * scsidp) ...@@ -1416,7 +1412,7 @@ sg_attach(Scsi_Device * scsidp)
write_unlock_irqrestore(&sg_dev_arr_lock, iflags); write_unlock_irqrestore(&sg_dev_arr_lock, iflags);
printk(KERN_ERR "sg_attach: Sg_device cannot be allocated\n"); printk(KERN_ERR "sg_attach: Sg_device cannot be allocated\n");
error = -ENOMEM; error = -ENOMEM;
goto out_detach; goto out;
} }
SCSI_LOG_TIMEOUT(3, printk("sg_attach: dev=%d \n", k)); SCSI_LOG_TIMEOUT(3, printk("sg_attach: dev=%d \n", k));
...@@ -1473,9 +1469,7 @@ sg_attach(Scsi_Device * scsidp) ...@@ -1473,9 +1469,7 @@ sg_attach(Scsi_Device * scsidp)
} }
return 0; return 0;
out_detach: out:
scsi_slave_detach(scsidp);
out_put:
put_disk(disk); put_disk(disk);
return error; return error;
} }
...@@ -1526,7 +1520,6 @@ sg_detach(Scsi_Device * scsidp) ...@@ -1526,7 +1520,6 @@ sg_detach(Scsi_Device * scsidp)
SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d\n", k)); SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d\n", k));
sg_dev_arr[k] = NULL; sg_dev_arr[k] = NULL;
} }
scsi_slave_detach(scsidp);
sg_nr_dev--; sg_nr_dev--;
break; break;
} }
......
...@@ -515,10 +515,6 @@ static int sr_attach(struct scsi_device *sdev) ...@@ -515,10 +515,6 @@ static int sr_attach(struct scsi_device *sdev)
if (sdev->type != TYPE_ROM && sdev->type != TYPE_WORM) if (sdev->type != TYPE_ROM && sdev->type != TYPE_WORM)
return 1; return 1;
error = scsi_slave_attach(sdev);
if (error)
return error;
error = -ENOMEM; error = -ENOMEM;
cd = kmalloc(sizeof(*cd), GFP_KERNEL); cd = kmalloc(sizeof(*cd), GFP_KERNEL);
if (!cd) if (!cd)
...@@ -592,7 +588,6 @@ static int sr_attach(struct scsi_device *sdev) ...@@ -592,7 +588,6 @@ static int sr_attach(struct scsi_device *sdev)
fail_free: fail_free:
kfree(cd); kfree(cd);
fail: fail:
scsi_slave_detach(sdev);
return error; return error;
} }
...@@ -820,7 +815,6 @@ static void sr_detach(struct scsi_device * SDp) ...@@ -820,7 +815,6 @@ static void sr_detach(struct scsi_device * SDp)
return; return;
sr_devlist_remove(cd); sr_devlist_remove(cd);
scsi_slave_detach(SDp);
del_gendisk(cd->disk); del_gendisk(cd->disk);
spin_lock(&sr_index_lock); spin_lock(&sr_index_lock);
......
...@@ -3725,16 +3725,13 @@ static int st_attach(Scsi_Device * SDp) ...@@ -3725,16 +3725,13 @@ static int st_attach(Scsi_Device * SDp)
return 1; return 1;
} }
if (scsi_slave_attach(SDp))
return 1;
i = SDp->host->sg_tablesize; i = SDp->host->sg_tablesize;
if (st_max_sg_segs < i) if (st_max_sg_segs < i)
i = st_max_sg_segs; i = st_max_sg_segs;
buffer = new_tape_buffer(TRUE, (SDp->host)->unchecked_isa_dma, i); buffer = new_tape_buffer(TRUE, (SDp->host)->unchecked_isa_dma, i);
if (buffer == NULL) { if (buffer == NULL) {
printk(KERN_ERR "st: Can't allocate new tape buffer. Device not attached.\n"); printk(KERN_ERR "st: Can't allocate new tape buffer. Device not attached.\n");
goto out_slave_detach; goto out;
} }
disk = alloc_disk(1); disk = alloc_disk(1);
...@@ -3923,8 +3920,7 @@ static int st_attach(Scsi_Device * SDp) ...@@ -3923,8 +3920,7 @@ static int st_attach(Scsi_Device * SDp)
put_disk(disk); put_disk(disk);
out_buffer_free: out_buffer_free:
kfree(buffer); kfree(buffer);
out_slave_detach: out:
scsi_slave_detach(SDp);
return 1; return 1;
}; };
...@@ -3962,7 +3958,6 @@ static void st_detach(Scsi_Device * SDp) ...@@ -3962,7 +3958,6 @@ static void st_detach(Scsi_Device * SDp)
normalize_buffer(tpnt->buffer); normalize_buffer(tpnt->buffer);
kfree(tpnt->buffer); kfree(tpnt->buffer);
} }
scsi_slave_detach(SDp);
put_disk(tpnt->disk); put_disk(tpnt->disk);
kfree(tpnt); kfree(tpnt);
return; return;
......
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