Commit 0723e2a4 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

[PATCH] merge sd.h into sd.c and some cleanup

Now that only sd.c includes sd.h it can be safely merged into it.
Also get rid of typedef abuse in sd.c
parent 2b448c6b
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* - Alex Davis <letmein@erols.com> Fix problem where partition info * - Alex Davis <letmein@erols.com> Fix problem where partition info
* not being read in sd_open. Fix problem where removable media * not being read in sd_open. Fix problem where removable media
* could be ejected after sd_open. * could be ejected after sd_open.
* - Douglas Gilbert <dgilbert@interlog.com> cleanup for lk 2.5 series * - Douglas Gilbert <dgilbert@interlog.com> cleanup for lk 2.5.x
* *
* Logging policy (needs CONFIG_SCSI_LOGGING defined): * Logging policy (needs CONFIG_SCSI_LOGGING defined):
* - setting up transfer: SCSI_LOG_HLQUEUE levels 1 and 2 * - setting up transfer: SCSI_LOG_HLQUEUE levels 1 and 2
...@@ -29,39 +29,34 @@ ...@@ -29,39 +29,34 @@
* than the level indicated above to trigger output. * than the level indicated above to trigger output.
*/ */
#define MAJOR_NR SCSI_DISK0_MAJOR
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/bio.h> #include <linux/bio.h>
#include <linux/string.h> #include <linux/genhd.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/smp.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#define MAJOR_NR SCSI_DISK0_MAJOR
#define LOCAL_END_REQUEST
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/blkpg.h> #include <linux/blkpg.h>
#include <asm/uaccess.h>
#include "scsi.h" #include "scsi.h"
#include "hosts.h" #include "hosts.h"
#include "sd.h"
#include <scsi/scsi_ioctl.h> #include <scsi/scsi_ioctl.h>
#include <scsi/scsicam.h> /* must follow "hosts.h" */ #include <scsi/scsicam.h>
#include <linux/genhd.h>
/* static char sd_version_str[] = "Version: 2.0.3 (20020417)"; */ #define N_SD_MAJORS 8
#define SD_MAJOR_MASK (N_SD_MAJORS - 1)
#define SD_MAJOR(i) (!(i) ? SCSI_DISK0_MAJOR : SCSI_DISK1_MAJOR-1+(i)) #define SD_MAJOR(i) (!(i) ? SCSI_DISK0_MAJOR : SCSI_DISK1_MAJOR-1+(i))
...@@ -72,30 +67,44 @@ ...@@ -72,30 +67,44 @@
#define MKDEV_SD(index) MKDEV_SD_PARTITION((index) << 4) #define MKDEV_SD(index) MKDEV_SD_PARTITION((index) << 4)
#define N_USED_SD_MAJORS (1 + ((sd_template.dev_max - 1) >> 4)) #define N_USED_SD_MAJORS (1 + ((sd_template.dev_max - 1) >> 4))
#define MAX_RETRIES 5
/* /*
* Time out in seconds for disks and Magneto-opticals (which are slower). * Time out in seconds for disks and Magneto-opticals (which are slower).
*/ */
#define SD_TIMEOUT (30 * HZ)
#define SD_MOD_TIMEOUT (75 * HZ)
#define SD_TIMEOUT (30 * HZ) /*
#define SD_MOD_TIMEOUT (75 * HZ) * Amount to over allocate sd_dsk_arr by
*/
#define SD_DSK_ARR_LUMP 6
#define SD_DSK_ARR_LUMP 6 /* amount to over allocate sd_dsk_arr by */ /*
* Number of allowed retries
*/
#define SD_MAX_RETRIES 5
struct scsi_disk {
struct scsi_device *device;
sector_t capacity; /* size in 512-byte sectors */
u8 media_present;
u8 write_prot;
unsigned WCE : 1; /* state of disk WCE bit */
unsigned RCD : 1; /* state of disk RCD bit */
};
static Scsi_Disk ** sd_dsk_arr; static struct scsi_disk ** sd_dsk_arr;
static rwlock_t sd_dsk_arr_lock = RW_LOCK_UNLOCKED; static rwlock_t sd_dsk_arr_lock = RW_LOCK_UNLOCKED;
static int check_scsidisk_media_change(struct gendisk *); static int check_scsidisk_media_change(struct gendisk *);
static int sd_revalidate(struct gendisk *); static int sd_revalidate(struct gendisk *);
static void sd_init_onedisk(Scsi_Disk * sdkp, struct gendisk *disk); static void sd_init_onedisk(struct scsi_disk * sdkp, struct gendisk *disk);
static int sd_init(void); static int sd_init(void);
static int sd_attach(Scsi_Device *); static int sd_attach(struct scsi_device *);
static int sd_detect(Scsi_Device *); static int sd_detect(struct scsi_device *);
static void sd_detach(Scsi_Device *); static void sd_detach(struct scsi_device *);
static int sd_init_command(Scsi_Cmnd *); static int sd_init_command(struct scsi_cmnd *);
static int sd_synchronize_cache(int, int); static int sd_synchronize_cache(int, int);
static int sd_notifier(struct notifier_block *, unsigned long, void *); static int sd_notifier(struct notifier_block *, unsigned long, void *);
...@@ -117,9 +126,9 @@ static struct Scsi_Device_Template sd_template = { ...@@ -117,9 +126,9 @@ static struct Scsi_Device_Template sd_template = {
.init_command = sd_init_command, .init_command = sd_init_command,
}; };
static void sd_rw_intr(Scsi_Cmnd * SCpnt); static void sd_rw_intr(struct scsi_cmnd * SCpnt);
static Scsi_Disk * sd_get_sdisk(int index); static struct scsi_disk * sd_get_sdisk(int index);
#if defined(CONFIG_PPC32) #if defined(CONFIG_PPC32)
/** /**
...@@ -139,8 +148,8 @@ static Scsi_Disk * sd_get_sdisk(int index); ...@@ -139,8 +148,8 @@ static Scsi_Disk * sd_get_sdisk(int index);
kdev_t __init kdev_t __init
sd_find_target(void *hp, int scsi_id) sd_find_target(void *hp, int scsi_id)
{ {
Scsi_Disk *sdkp; struct scsi_disk *sdkp;
Scsi_Device *sdp; struct scsi_device *sdp;
struct Scsi_Host *shp = hp; struct Scsi_Host *shp = hp;
int dsk_nr; int dsk_nr;
kdev_t retval = NODEV; kdev_t retval = NODEV;
...@@ -183,8 +192,8 @@ static int sd_ioctl(struct inode * inode, struct file * filp, ...@@ -183,8 +192,8 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
{ {
struct block_device *bdev = inode->i_bdev; struct block_device *bdev = inode->i_bdev;
struct gendisk *disk = bdev->bd_disk; struct gendisk *disk = bdev->bd_disk;
Scsi_Disk *sdkp = disk->private_data; struct scsi_disk *sdkp = disk->private_data;
Scsi_Device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
sector_t capacity = sdkp->capacity; sector_t capacity = sdkp->capacity;
struct Scsi_Host *host; struct Scsi_Host *host;
int diskinfo[4]; int diskinfo[4];
...@@ -276,12 +285,12 @@ static struct gendisk **sd_disks; ...@@ -276,12 +285,12 @@ static struct gendisk **sd_disks;
* *
* Returns 1 if successful and 0 if error (or cannot be done now). * Returns 1 if successful and 0 if error (or cannot be done now).
**/ **/
static int sd_init_command(Scsi_Cmnd * SCpnt) static int sd_init_command(struct scsi_cmnd * SCpnt)
{ {
int this_count, timeout; int this_count, timeout;
struct gendisk *disk; struct gendisk *disk;
sector_t block; sector_t block;
Scsi_Device *sdp = SCpnt->device; struct scsi_device *sdp = SCpnt->device;
timeout = SD_TIMEOUT; timeout = SD_TIMEOUT;
if (SCpnt->device->type != TYPE_DISK) if (SCpnt->device->type != TYPE_DISK)
...@@ -435,7 +444,7 @@ static int sd_init_command(Scsi_Cmnd * SCpnt) ...@@ -435,7 +444,7 @@ static int sd_init_command(Scsi_Cmnd * SCpnt)
SCpnt->transfersize = sdp->sector_size; SCpnt->transfersize = sdp->sector_size;
SCpnt->underflow = this_count << 9; SCpnt->underflow = this_count << 9;
SCpnt->allowed = MAX_RETRIES; SCpnt->allowed = SD_MAX_RETRIES;
SCpnt->timeout_per_command = timeout; SCpnt->timeout_per_command = timeout;
/* /*
...@@ -467,8 +476,8 @@ static int sd_init_command(Scsi_Cmnd * SCpnt) ...@@ -467,8 +476,8 @@ static int sd_init_command(Scsi_Cmnd * SCpnt)
static int sd_open(struct inode *inode, struct file *filp) static int sd_open(struct inode *inode, struct file *filp)
{ {
struct gendisk *disk = inode->i_bdev->bd_disk; struct gendisk *disk = inode->i_bdev->bd_disk;
Scsi_Disk *sdkp = disk->private_data; struct scsi_disk *sdkp = disk->private_data;
Scsi_Device * sdp = sdkp->device; struct scsi_device * sdp = sdkp->device;
int retval = -ENXIO; int retval = -ENXIO;
SCSI_LOG_HLQUEUE(3, printk("sd_open: disk=%s\n", disk->disk_name)); SCSI_LOG_HLQUEUE(3, printk("sd_open: disk=%s\n", disk->disk_name));
...@@ -552,8 +561,8 @@ static int sd_open(struct inode *inode, struct file *filp) ...@@ -552,8 +561,8 @@ static int sd_open(struct inode *inode, struct file *filp)
static int sd_release(struct inode *inode, struct file *filp) static int sd_release(struct inode *inode, struct file *filp)
{ {
struct gendisk *disk = inode->i_bdev->bd_disk; struct gendisk *disk = inode->i_bdev->bd_disk;
Scsi_Disk *sdkp = disk->private_data; struct scsi_disk *sdkp = disk->private_data;
Scsi_Device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
SCSI_LOG_HLQUEUE(3, printk("sd_release: disk=%s\n", disk->disk_name)); SCSI_LOG_HLQUEUE(3, printk("sd_release: disk=%s\n", disk->disk_name));
if (!sdp) if (!sdp)
...@@ -594,7 +603,7 @@ static struct block_device_operations sd_fops = ...@@ -594,7 +603,7 @@ static struct block_device_operations sd_fops =
* *
* Note: potentially run from within an ISR. Must not block. * Note: potentially run from within an ISR. Must not block.
**/ **/
static void sd_rw_intr(Scsi_Cmnd * SCpnt) static void sd_rw_intr(struct scsi_cmnd * SCpnt)
{ {
int result = SCpnt->result; int result = SCpnt->result;
int this_count = SCpnt->bufflen >> 9; int this_count = SCpnt->bufflen >> 9;
...@@ -690,7 +699,7 @@ static void sd_rw_intr(Scsi_Cmnd * SCpnt) ...@@ -690,7 +699,7 @@ static void sd_rw_intr(Scsi_Cmnd * SCpnt)
} }
static void static void
sd_set_media_not_present(Scsi_Disk *sdkp) { sd_set_media_not_present(struct scsi_disk *sdkp) {
sdkp->media_present = 0; sdkp->media_present = 0;
sdkp->capacity = 0; sdkp->capacity = 0;
sdkp->device->changed = 1; sdkp->device->changed = 1;
...@@ -706,8 +715,8 @@ sd_set_media_not_present(Scsi_Disk *sdkp) { ...@@ -706,8 +715,8 @@ sd_set_media_not_present(Scsi_Disk *sdkp) {
**/ **/
static int check_scsidisk_media_change(struct gendisk *disk) static int check_scsidisk_media_change(struct gendisk *disk)
{ {
Scsi_Disk *sdkp = disk->private_data; struct scsi_disk *sdkp = disk->private_data;
Scsi_Device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
int retval; int retval;
int flag = 0; /* <<<< what is this for?? */ int flag = 0; /* <<<< what is this for?? */
...@@ -755,7 +764,7 @@ static int check_scsidisk_media_change(struct gendisk *disk) ...@@ -755,7 +764,7 @@ static int check_scsidisk_media_change(struct gendisk *disk)
} }
/* /*
* For removable scsi disk we have to recognise the presence * For removable scsi disk we have to recognise the presence
* of a disk in the drive. This is kept in the Scsi_Disk * of a disk in the drive. This is kept in the struct scsi_disk
* struct and tested at open ! Daniel Roche ( dan@lectra.fr ) * struct and tested at open ! Daniel Roche ( dan@lectra.fr )
*/ */
...@@ -768,7 +777,7 @@ static int check_scsidisk_media_change(struct gendisk *disk) ...@@ -768,7 +777,7 @@ static int check_scsidisk_media_change(struct gendisk *disk)
} }
static int static int
sd_media_not_present(Scsi_Disk *sdkp, Scsi_Request *SRpnt) { sd_media_not_present(struct scsi_disk *sdkp, struct scsi_request *SRpnt) {
int the_result = SRpnt->sr_result; int the_result = SRpnt->sr_result;
if (the_result != 0 if (the_result != 0
...@@ -786,10 +795,10 @@ sd_media_not_present(Scsi_Disk *sdkp, Scsi_Request *SRpnt) { ...@@ -786,10 +795,10 @@ sd_media_not_present(Scsi_Disk *sdkp, Scsi_Request *SRpnt) {
* spinup disk - called only in sd_init_onedisk() * spinup disk - called only in sd_init_onedisk()
*/ */
static void static void
sd_spinup_disk(Scsi_Disk *sdkp, char *diskname, sd_spinup_disk(struct scsi_disk *sdkp, char *diskname,
Scsi_Request *SRpnt, unsigned char *buffer) { struct scsi_request *SRpnt, unsigned char *buffer) {
unsigned char cmd[10]; unsigned char cmd[10];
Scsi_Device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
unsigned long spintime_value = 0; unsigned long spintime_value = 0;
int the_result, retries, spintime; int the_result, retries, spintime;
...@@ -810,7 +819,7 @@ sd_spinup_disk(Scsi_Disk *sdkp, char *diskname, ...@@ -810,7 +819,7 @@ sd_spinup_disk(Scsi_Disk *sdkp, char *diskname,
SRpnt->sr_data_direction = SCSI_DATA_NONE; SRpnt->sr_data_direction = SCSI_DATA_NONE;
scsi_wait_req (SRpnt, (void *) cmd, (void *) buffer, scsi_wait_req (SRpnt, (void *) cmd, (void *) buffer,
0/*512*/, SD_TIMEOUT, MAX_RETRIES); 0/*512*/, SD_TIMEOUT, SD_MAX_RETRIES);
the_result = SRpnt->sr_result; the_result = SRpnt->sr_result;
retries++; retries++;
...@@ -846,7 +855,7 @@ sd_spinup_disk(Scsi_Disk *sdkp, char *diskname, ...@@ -846,7 +855,7 @@ sd_spinup_disk(Scsi_Disk *sdkp, char *diskname,
SRpnt->sr_data_direction = SCSI_DATA_READ; SRpnt->sr_data_direction = SCSI_DATA_READ;
scsi_wait_req(SRpnt, (void *)cmd, scsi_wait_req(SRpnt, (void *)cmd,
(void *) buffer, 0/*512*/, (void *) buffer, 0/*512*/,
SD_TIMEOUT, MAX_RETRIES); SD_TIMEOUT, SD_MAX_RETRIES);
spintime_value = jiffies; spintime_value = jiffies;
} }
spintime = 1; spintime = 1;
...@@ -873,8 +882,8 @@ sd_spinup_disk(Scsi_Disk *sdkp, char *diskname, ...@@ -873,8 +882,8 @@ sd_spinup_disk(Scsi_Disk *sdkp, char *diskname,
* sd_read_cache_type - called only from sd_init_onedisk() * sd_read_cache_type - called only from sd_init_onedisk()
*/ */
static void static void
sd_read_cache_type(Scsi_Disk *sdkp, char *diskname, sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
Scsi_Request *SRpnt, unsigned char *buffer) { struct scsi_request *SRpnt, unsigned char *buffer) {
unsigned char cmd[10]; unsigned char cmd[10];
int the_result, retries; int the_result, retries;
...@@ -896,7 +905,7 @@ sd_read_cache_type(Scsi_Disk *sdkp, char *diskname, ...@@ -896,7 +905,7 @@ sd_read_cache_type(Scsi_Disk *sdkp, char *diskname,
SRpnt->sr_data_direction = SCSI_DATA_READ; SRpnt->sr_data_direction = SCSI_DATA_READ;
scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer,
128, SD_TIMEOUT, MAX_RETRIES); 128, SD_TIMEOUT, SD_MAX_RETRIES);
the_result = SRpnt->sr_result; the_result = SRpnt->sr_result;
retries--; retries--;
...@@ -947,10 +956,10 @@ sd_read_cache_type(Scsi_Disk *sdkp, char *diskname, ...@@ -947,10 +956,10 @@ sd_read_cache_type(Scsi_Disk *sdkp, char *diskname,
* read disk capacity - called only in sd_init_onedisk() * read disk capacity - called only in sd_init_onedisk()
*/ */
static void static void
sd_read_capacity(Scsi_Disk *sdkp, char *diskname, sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
Scsi_Request *SRpnt, unsigned char *buffer) { struct scsi_request *SRpnt, unsigned char *buffer) {
unsigned char cmd[10]; unsigned char cmd[10];
Scsi_Device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
int the_result, retries; int the_result, retries;
int sector_size; int sector_size;
...@@ -966,7 +975,7 @@ sd_read_capacity(Scsi_Disk *sdkp, char *diskname, ...@@ -966,7 +975,7 @@ sd_read_capacity(Scsi_Disk *sdkp, char *diskname,
SRpnt->sr_data_direction = SCSI_DATA_READ; SRpnt->sr_data_direction = SCSI_DATA_READ;
scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer,
8, SD_TIMEOUT, MAX_RETRIES); 8, SD_TIMEOUT, SD_MAX_RETRIES);
if (sd_media_not_present(sdkp, SRpnt)) if (sd_media_not_present(sdkp, SRpnt))
return; return;
...@@ -1071,7 +1080,7 @@ sd_read_capacity(Scsi_Disk *sdkp, char *diskname, ...@@ -1071,7 +1080,7 @@ sd_read_capacity(Scsi_Disk *sdkp, char *diskname,
} }
static int static int
sd_do_mode_sense6(Scsi_Device *sdp, Scsi_Request *SRpnt, sd_do_mode_sense6(struct scsi_device *sdp, struct scsi_request *SRpnt,
int modepage, unsigned char *buffer, int len) { int modepage, unsigned char *buffer, int len) {
unsigned char cmd[8]; unsigned char cmd[8];
...@@ -1086,7 +1095,7 @@ sd_do_mode_sense6(Scsi_Device *sdp, Scsi_Request *SRpnt, ...@@ -1086,7 +1095,7 @@ sd_do_mode_sense6(Scsi_Device *sdp, Scsi_Request *SRpnt,
SRpnt->sr_data_direction = SCSI_DATA_READ; SRpnt->sr_data_direction = SCSI_DATA_READ;
scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer,
len, SD_TIMEOUT, MAX_RETRIES); len, SD_TIMEOUT, SD_MAX_RETRIES);
return SRpnt->sr_result; return SRpnt->sr_result;
} }
...@@ -1095,9 +1104,9 @@ sd_do_mode_sense6(Scsi_Device *sdp, Scsi_Request *SRpnt, ...@@ -1095,9 +1104,9 @@ sd_do_mode_sense6(Scsi_Device *sdp, Scsi_Request *SRpnt,
* read write protect setting, if possible - called only in sd_init_onedisk() * read write protect setting, if possible - called only in sd_init_onedisk()
*/ */
static void static void
sd_read_write_protect_flag(Scsi_Disk *sdkp, char *diskname, sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
Scsi_Request *SRpnt, unsigned char *buffer) { struct scsi_request *SRpnt, unsigned char *buffer) {
Scsi_Device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
int res; int res;
/* /*
...@@ -1136,18 +1145,18 @@ sd_read_write_protect_flag(Scsi_Disk *sdkp, char *diskname, ...@@ -1136,18 +1145,18 @@ sd_read_write_protect_flag(Scsi_Disk *sdkp, char *diskname,
/** /**
* sd_init_onedisk - called the first time a new disk is seen, * sd_init_onedisk - called the first time a new disk is seen,
* performs disk spin up, read_capacity, etc. * performs disk spin up, read_capacity, etc.
* @sdkp: pointer to associated Scsi_Disk object * @sdkp: pointer to associated struct scsi_disk object
* @dsk_nr: disk number within this driver (e.g. 0->/dev/sda, * @dsk_nr: disk number within this driver (e.g. 0->/dev/sda,
* 1->/dev/sdb, etc) * 1->/dev/sdb, etc)
* *
* Note: this function is local to this driver. * Note: this function is local to this driver.
**/ **/
static void static void
sd_init_onedisk(Scsi_Disk * sdkp, struct gendisk *disk) sd_init_onedisk(struct scsi_disk * sdkp, struct gendisk *disk)
{ {
unsigned char *buffer; unsigned char *buffer;
Scsi_Device *sdp; struct scsi_device *sdp;
Scsi_Request *SRpnt; struct scsi_request *SRpnt;
SCSI_LOG_HLQUEUE(3, printk("sd_init_onedisk: disk=%s\n", disk->disk_name)); SCSI_LOG_HLQUEUE(3, printk("sd_init_onedisk: disk=%s\n", disk->disk_name));
...@@ -1215,7 +1224,7 @@ static int sd_registered; ...@@ -1215,7 +1224,7 @@ static int sd_registered;
static int sd_init() static int sd_init()
{ {
int k, maxparts; int k, maxparts;
Scsi_Disk * sdkp; struct scsi_disk * sdkp;
SCSI_LOG_HLQUEUE(3, printk("sd_init: dev_noticed=%d\n", SCSI_LOG_HLQUEUE(3, printk("sd_init: dev_noticed=%d\n",
sd_template.dev_noticed)); sd_template.dev_noticed));
...@@ -1255,10 +1264,10 @@ static int sd_init() ...@@ -1255,10 +1264,10 @@ static int sd_init()
if (sd_dsk_arr) { if (sd_dsk_arr) {
zero_mem_lth(sd_dsk_arr, sd_template.dev_max); zero_mem_lth(sd_dsk_arr, sd_template.dev_max);
for (k = 0; k < sd_template.dev_max; ++k) { for (k = 0; k < sd_template.dev_max; ++k) {
sdkp = vmalloc(sizeof(Scsi_Disk)); sdkp = vmalloc(sizeof(struct scsi_disk));
if (NULL == sdkp) if (NULL == sdkp)
goto cleanup_mem; goto cleanup_mem;
memset(sdkp, 0, sizeof(Scsi_Disk)); memset(sdkp, 0, sizeof(struct scsi_disk));
sd_dsk_arr[k] = sdkp; sd_dsk_arr[k] = sdkp;
} }
} }
...@@ -1300,7 +1309,7 @@ static int sd_init() ...@@ -1300,7 +1309,7 @@ static int sd_init()
* Note: this function is invoked from the scsi mid-level. * Note: this function is invoked from the scsi mid-level.
* This function is called before sd_init() so very little is available. * This function is called before sd_init() so very little is available.
**/ **/
static int sd_detect(Scsi_Device * sdp) static int sd_detect(struct scsi_device * sdp)
{ {
SCSI_LOG_HLQUEUE(3, printk("sd_detect: type=%d\n", sdp->type)); SCSI_LOG_HLQUEUE(3, printk("sd_detect: type=%d\n", sdp->type));
if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD) if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD)
...@@ -1324,9 +1333,9 @@ static int sd_detect(Scsi_Device * sdp) ...@@ -1324,9 +1333,9 @@ static int sd_detect(Scsi_Device * sdp)
* (e.g. /dev/sda). More precisely it is the block device major * (e.g. /dev/sda). More precisely it is the block device major
* and minor number that is chosen here. * and minor number that is chosen here.
**/ **/
static int sd_attach(Scsi_Device * sdp) static int sd_attach(struct scsi_device * sdp)
{ {
Scsi_Disk *sdkp = NULL; /* shut up lame gcc warning */ struct scsi_disk *sdkp = NULL; /* shut up lame gcc warning */
int dsk_nr; int dsk_nr;
unsigned long iflags; unsigned long iflags;
struct gendisk *gd; struct gendisk *gd;
...@@ -1354,7 +1363,7 @@ static int sd_attach(Scsi_Device * sdp) ...@@ -1354,7 +1363,7 @@ static int sd_attach(Scsi_Device * sdp)
for (dsk_nr = 0; dsk_nr < sd_template.dev_max; dsk_nr++) { for (dsk_nr = 0; dsk_nr < sd_template.dev_max; dsk_nr++) {
sdkp = sd_dsk_arr[dsk_nr]; sdkp = sd_dsk_arr[dsk_nr];
if (!sdkp->device) { if (!sdkp->device) {
memset(sdkp, 0, sizeof(Scsi_Disk)); memset(sdkp, 0, sizeof(struct scsi_disk));
sdkp->device = sdp; sdkp->device = sdp;
break; break;
} }
...@@ -1401,7 +1410,7 @@ static int sd_attach(Scsi_Device * sdp) ...@@ -1401,7 +1410,7 @@ static int sd_attach(Scsi_Device * sdp)
static int sd_revalidate(struct gendisk *disk) static int sd_revalidate(struct gendisk *disk)
{ {
Scsi_Disk *sdkp = disk->private_data; struct scsi_disk *sdkp = disk->private_data;
if (!sdkp->device) if (!sdkp->device)
return -ENODEV; return -ENODEV;
...@@ -1422,9 +1431,9 @@ static int sd_revalidate(struct gendisk *disk) ...@@ -1422,9 +1431,9 @@ static int sd_revalidate(struct gendisk *disk)
* that could be re-used by a subsequent sd_attach(). * that could be re-used by a subsequent sd_attach().
* This function is not called when the built-in sd driver is "exit-ed". * This function is not called when the built-in sd driver is "exit-ed".
**/ **/
static void sd_detach(Scsi_Device * sdp) static void sd_detach(struct scsi_device * sdp)
{ {
Scsi_Disk *sdkp = NULL; struct scsi_disk *sdkp = NULL;
int dsk_nr; int dsk_nr;
unsigned long iflags; unsigned long iflags;
...@@ -1516,7 +1525,7 @@ static int sd_notifier(struct notifier_block *nbt, unsigned long event, void *bu ...@@ -1516,7 +1525,7 @@ static int sd_notifier(struct notifier_block *nbt, unsigned long event, void *bu
|| event == SYS_POWER_OFF)) || event == SYS_POWER_OFF))
return NOTIFY_DONE; return NOTIFY_DONE;
for (i = 0; i < sd_template.dev_max; i++) { for (i = 0; i < sd_template.dev_max; i++) {
Scsi_Disk *sdkp = sd_get_sdisk(i); struct scsi_disk *sdkp = sd_get_sdisk(i);
if (!sdkp || !sdkp->device) if (!sdkp || !sdkp->device)
continue; continue;
...@@ -1539,9 +1548,9 @@ static int sd_notifier(struct notifier_block *nbt, unsigned long event, void *bu ...@@ -1539,9 +1548,9 @@ static int sd_notifier(struct notifier_block *nbt, unsigned long event, void *bu
* have user context) */ * have user context) */
static int sd_synchronize_cache(int index, int verbose) static int sd_synchronize_cache(int index, int verbose)
{ {
Scsi_Request *SRpnt; struct scsi_request *SRpnt;
Scsi_Disk *sdkp = sd_get_sdisk(index); struct scsi_disk *sdkp = sd_get_sdisk(index);
Scsi_Device *SDpnt = sdkp->device; struct scsi_device *SDpnt = sdkp->device;
int retries, the_result; int retries, the_result;
if (!SDpnt->online) if (!SDpnt->online)
...@@ -1570,7 +1579,7 @@ static int sd_synchronize_cache(int index, int verbose) ...@@ -1570,7 +1579,7 @@ static int sd_synchronize_cache(int index, int verbose)
/* leave the rest of the command zero to indicate /* leave the rest of the command zero to indicate
* flush everything */ * flush everything */
scsi_wait_req(SRpnt, (void *)cmd, NULL, 0, scsi_wait_req(SRpnt, (void *)cmd, NULL, 0,
SD_TIMEOUT, MAX_RETRIES); SD_TIMEOUT, SD_MAX_RETRIES);
if(SRpnt->sr_result == 0) if(SRpnt->sr_result == 0)
break; break;
...@@ -1593,9 +1602,9 @@ static int sd_synchronize_cache(int index, int verbose) ...@@ -1593,9 +1602,9 @@ static int sd_synchronize_cache(int index, int verbose)
return (the_result == 0); return (the_result == 0);
} }
static Scsi_Disk * sd_get_sdisk(int index) static struct scsi_disk * sd_get_sdisk(int index)
{ {
Scsi_Disk * sdkp = NULL; struct scsi_disk * sdkp = NULL;
unsigned long iflags; unsigned long iflags;
read_lock_irqsave(&sd_dsk_arr_lock, iflags); read_lock_irqsave(&sd_dsk_arr_lock, iflags);
......
/*
* sd.h Copyright (C) 1992 Drew Eckhardt
* SCSI disk driver header file by
* Drew Eckhardt
*
* <drew@colorado.edu>
*
* Modified by Eric Youngdale eric@andante.org to
* add scatter-gather, multiple outstanding request, and other
* enhancements.
*/
#ifndef _SD_H
#define _SD_H
#ifndef _SCSI_H
#include "scsi.h"
#endif
#ifndef _GENDISK_H
#include <linux/genhd.h>
#endif
typedef struct scsi_disk {
sector_t capacity; /* size in 512-byte sectors */
Scsi_Device *device;
unsigned char media_present;
unsigned char write_prot;
unsigned WCE:1; /* state of disk WCE bit */
unsigned RCD:1; /* state of disk RCD bit */
} Scsi_Disk;
extern int revalidate_scsidisk(kdev_t dev, int maxusage);
/*
* Used by pmac to find the device associated with a target.
*/
extern kdev_t sd_find_target(void *host, int tgt);
#define N_SD_MAJORS 8
#define SD_MAJOR_MASK (N_SD_MAJORS - 1)
#endif
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