Implement scsi_configure_device()
PATCH 6/9 Implement scsi_configure_device()
This patch implements the function scsi_configure_device(). This function elevates an sdev into SDEV_RUNNING and configures it properly so that I/O is possible on the device.
Signed-off-by Hannes Reinecke <[email protected]>
--- drivers/scsi/scsi_scan.c | 62 ++++++++++++++++++++++++++++++++------------- 1 files changed, 44 insertions(+), 18 deletions(-)
drivers/scsi/scsi_scan.c +44 -18
@@ -692,6 +692,37 @@ static int scsi_probe_lun(struct scsi_de }/** +* scsi_configure_device - configure a scsi_device +* @sdev: The scsi_device to configure +* +* Description: +* Configure an existing scsi_device. This function +* elevates a scsi_device from state SDEV_CREATED or +* SDEV_DEL into SDEV_RUNNING. +* +* Return: +* 0 On Success +* <0 On failure. +* +**/ +int scsi_configure_device (struct scsi_device *sdev) +{ +int ret =0 ; + +/* set the device running here so that slave configure +* may do I/O */ +if (scsi_device_set_state (sdev,SDEV_RUNNING ) !=0 ) +return -ENXIO ; + +transport_configure_device (&sdev->sdev_gendev); + +if (sdev->host->hostt->slave_configure) + ret = sdev->host->hostt->slave_configure (sdev); + +return ret; +} + +/** * scsi_add_lun - allocate and fully initialze a scsi_device * @sdevscan: holds information to be stored in the new scsi_device * @sdevnew: store the address of the newly allocated scsi_device
@@ -711,6 +742,8 @@ static int scsi_probe_lun(struct scsi_destatic int scsi_add_lun (struct scsi_device *sdev,unsigned char *inq_result,int *bflags,int async) { +int ret; +/* * XXX do not save the inquiry, since it can change underneath us, * save just vendor/model/rev.
@@ -874,10 +907,6 @@ static int scsi_add_lun(struct scsi_deviif (*bflags &BLIST_USE_10_BYTE_MS ) sdev->use_10_for_ms =1 ; -/* set the device running here so that slave configure -* may do I/O */ -scsi_device_set_state (sdev,SDEV_RUNNING ); -if (*bflags &BLIST_MS_192_BYTES_FOR_3F ) sdev->use_192_bytes_for_3f =1 ;
@@ -887,21 +916,18 @@ static int scsi_add_lun(struct scsi_deviif (*bflags &BLIST_RETRY_HWERROR ) sdev->retry_hwerror =1 ; -transport_configure_device (&sdev->sdev_gendev); - -if (sdev->host->hostt->slave_configure) { -int ret = sdev->host->hostt->slave_configure (sdev); -if (ret) { -/* -* if LLDD reports slave not present, don't clutter -* console with alloc failure messages -*/ -if (ret != -ENXIO ) { -sdev_printk (KERN_ERR , sdev, -"failed to configure device\n" ); - } -return SCSI_SCAN_NO_RESPONSE ; + ret =scsi_configure_device (sdev); +if (ret) { +/* +* if LLDD reports slave not present, don't clutter +* console with alloc failure messages +*/ +if (ret != -ENXIO ) { +sdev_printk (KERN_ERR , sdev, +"failed to configure device\n" ); } +scsi_destroy_device (sdev); +return SCSI_SCAN_NO_RESPONSE ; }/*
Signature · 1 line
1.4.3.4