Archived
14
0
Fork 0

IDE: Coding Style fixes to drivers/ide/ide-cd.c

Before:
total: 43 errors, 66 warnings, 2183 lines checked

After:
total: 0 errors, 36 warnings, 2192 lines checked

I didn't (and I don't plan to) fix the warnings:
WARNING: line over 80 characters

[bart: minor fixes, md5sum checked (modulo s/"ignore = NULL;"/"ignore;"/ fix)]

Signed-off-by: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
Paolo Ciarrocchi 2008-04-26 17:36:42 +02:00 committed by Bartlomiej Zolnierkiewicz
parent 175f354b75
commit 9ce70fb2b5

View file

@ -83,7 +83,7 @@ static void ide_cd_put(struct cdrom_info *cd)
/* Mark that we've seen a media change, and invalidate our internal /* Mark that we've seen a media change, and invalidate our internal
buffers. */ buffers. */
static void cdrom_saw_media_change (ide_drive_t *drive) static void cdrom_saw_media_change(ide_drive_t *drive)
{ {
struct cdrom_info *cd = drive->driver_data; struct cdrom_info *cd = drive->driver_data;
@ -100,7 +100,8 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq,
return 0; return 0;
switch (sense->sense_key) { switch (sense->sense_key) {
case NO_SENSE: case RECOVERED_ERROR: case NO_SENSE:
case RECOVERED_ERROR:
break; break;
case NOT_READY: case NOT_READY:
/* /*
@ -159,7 +160,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
return; return;
if (sense->error_code == 0x70) { /* Current Error */ if (sense->error_code == 0x70) { /* Current Error */
switch(sense->sense_key) { switch (sense->sense_key) {
case MEDIUM_ERROR: case MEDIUM_ERROR:
case VOLUME_OVERFLOW: case VOLUME_OVERFLOW:
case ILLEGAL_REQUEST: case ILLEGAL_REQUEST:
@ -178,7 +179,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
bio_sectors = 4; bio_sectors = 4;
if (drive->queue->hardsect_size == 2048) if (drive->queue->hardsect_size == 2048)
sector <<= 2; /* Device sector size is 2K */ sector <<= 2; /* Device sector size is 2K */
sector &= ~(bio_sectors -1); sector &= ~(bio_sectors - 1);
valid = (sector - failed_command->sector) << 9; valid = (sector - failed_command->sector) << 9;
if (valid < 0) if (valid < 0)
@ -229,7 +230,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
(void) ide_do_drive_cmd(drive, rq, ide_preempt); (void) ide_do_drive_cmd(drive, rq, ide_preempt);
} }
static void cdrom_end_request (ide_drive_t *drive, int uptodate) static void cdrom_end_request(ide_drive_t *drive, int uptodate)
{ {
struct request *rq = HWGROUP(drive)->rq; struct request *rq = HWGROUP(drive)->rq;
int nsectors = rq->hard_cur_sectors; int nsectors = rq->hard_cur_sectors;
@ -333,14 +334,14 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
/* Check for tray open. */ /* Check for tray open. */
if (sense_key == NOT_READY) { if (sense_key == NOT_READY) {
cdrom_saw_media_change (drive); cdrom_saw_media_change(drive);
} else if (sense_key == UNIT_ATTENTION) { } else if (sense_key == UNIT_ATTENTION) {
/* Check for media change. */ /* Check for media change. */
cdrom_saw_media_change (drive); cdrom_saw_media_change(drive);
/*printk("%s: media changed\n",drive->name);*/ /*printk("%s: media changed\n",drive->name);*/
return 0; return 0;
} else if ((sense_key == ILLEGAL_REQUEST) && } else if (sense_key == ILLEGAL_REQUEST &&
(rq->cmd[0] == GPCMD_START_STOP_UNIT)) { rq->cmd[0] == GPCMD_START_STOP_UNIT) {
/* /*
* Don't print error message for this condition-- * Don't print error message for this condition--
* SFF8090i indicates that 5/24/00 is the correct * SFF8090i indicates that 5/24/00 is the correct
@ -373,10 +374,10 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
if (sense_key == NOT_READY) { if (sense_key == NOT_READY) {
/* Tray open. */ /* Tray open. */
if (rq_data_dir(rq) == READ) { if (rq_data_dir(rq) == READ) {
cdrom_saw_media_change (drive); cdrom_saw_media_change(drive);
/* Fail the request. */ /* Fail the request. */
printk ("%s: tray open\n", drive->name); printk("%s: tray open\n", drive->name);
do_end_request = 1; do_end_request = 1;
} else { } else {
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
@ -398,7 +399,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
*/ */
spin_lock_irqsave(&ide_lock, flags); spin_lock_irqsave(&ide_lock, flags);
blk_plug_device(drive->queue); blk_plug_device(drive->queue);
spin_unlock_irqrestore(&ide_lock,flags); spin_unlock_irqrestore(&ide_lock, flags);
return 1; return 1;
} }
} }
@ -406,25 +407,31 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
/* Media change. */ /* Media change. */
cdrom_saw_media_change (drive); cdrom_saw_media_change (drive);
/* Arrange to retry the request. /*
But be sure to give up if we've retried * Arrange to retry the request.
too many times. */ * But be sure to give up if we've retried
* too many times.
*/
if (++rq->errors > ERROR_MAX) if (++rq->errors > ERROR_MAX)
do_end_request = 1; do_end_request = 1;
} else if (sense_key == ILLEGAL_REQUEST || } else if (sense_key == ILLEGAL_REQUEST ||
sense_key == DATA_PROTECT) { sense_key == DATA_PROTECT) {
/* No point in retrying after an illegal /*
request or data protect error.*/ * No point in retrying after an illegal
ide_dump_status_no_sense (drive, "command error", stat); * request or data protect error.
*/
ide_dump_status_no_sense(drive, "command error", stat);
do_end_request = 1; do_end_request = 1;
} else if (sense_key == MEDIUM_ERROR) { } else if (sense_key == MEDIUM_ERROR) {
/* No point in re-trying a zillion times on a bad /*
* sector... If we got here the error is not correctable */ * No point in re-trying a zillion times on a bad
ide_dump_status_no_sense (drive, "media error (bad sector)", stat); * sector... If we got here the error is not correctable
*/
ide_dump_status_no_sense(drive, "media error (bad sector)", stat);
do_end_request = 1; do_end_request = 1;
} else if (sense_key == BLANK_CHECK) { } else if (sense_key == BLANK_CHECK) {
/* Disk appears blank ?? */ /* Disk appears blank ?? */
ide_dump_status_no_sense (drive, "media error (blank)", stat); ide_dump_status_no_sense(drive, "media error (blank)", stat);
do_end_request = 1; do_end_request = 1;
} else if ((err & ~ABRT_ERR) != 0) { } else if ((err & ~ABRT_ERR) != 0) {
/* Go to the default handler /* Go to the default handler
@ -556,7 +563,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
HANDLER is the interrupt handler to call when the command completes HANDLER is the interrupt handler to call when the command completes
or there's data ready. */ or there's data ready. */
#define ATAPI_MIN_CDB_BYTES 12 #define ATAPI_MIN_CDB_BYTES 12
static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
struct request *rq, struct request *rq,
ide_handler_t *handler) ide_handler_t *handler)
{ {
@ -748,7 +755,7 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
#define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */ #define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */
#define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */ #define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */
static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive) static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive)
{ {
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
int stat; int stat;
@ -772,7 +779,7 @@ static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive)
return ide_stopped; return ide_stopped;
} }
static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive) static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive)
{ {
struct request *rq = HWGROUP(drive)->rq; struct request *rq = HWGROUP(drive)->rq;
sector_t frame = rq->sector; sector_t frame = rq->sector;
@ -787,7 +794,7 @@ static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive)
return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr); return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr);
} }
static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block) static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block)
{ {
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
@ -796,9 +803,11 @@ static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block)
return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation);
} }
/* Fix up a possibly partially-processed request so that we can /*
start it over entirely, or even put it back on the request queue. */ * Fix up a possibly partially-processed request so that we can
static void restore_request (struct request *rq) * start it over entirely, or even put it back on the request queue.
*/
static void restore_request(struct request *rq)
{ {
if (rq->buffer != bio_data(rq->bio)) { if (rq->buffer != bio_data(rq->bio)) {
sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE; sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE;
@ -1210,7 +1219,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
* cdrom driver request routine. * cdrom driver request routine.
*/ */
static ide_startstop_t static ide_startstop_t
ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block)
{ {
ide_startstop_t action; ide_startstop_t action;
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
@ -1225,13 +1234,13 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
ide_stall_queue(drive, IDECD_SEEK_TIMER); ide_stall_queue(drive, IDECD_SEEK_TIMER);
return ide_stopped; return ide_stopped;
} }
printk (KERN_ERR "%s: DSC timeout\n", drive->name); printk(KERN_ERR "%s: DSC timeout\n", drive->name);
} }
info->cd_flags &= ~IDE_CD_FLAG_SEEKING; info->cd_flags &= ~IDE_CD_FLAG_SEEKING;
} }
if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) { if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap)
action = cdrom_start_seek(drive, block); action = cdrom_start_seek(drive, block);
} else else
action = cdrom_start_rw(drive, rq); action = cdrom_start_rw(drive, rq);
info->last_block = block; info->last_block = block;
return action; return action;
@ -1264,7 +1273,7 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
*/ */
static static
void msf_from_bcd (struct atapi_msf *msf) void msf_from_bcd(struct atapi_msf *msf)
{ {
msf->minute = BCD2BIN(msf->minute); msf->minute = BCD2BIN(msf->minute);
msf->second = BCD2BIN(msf->second); msf->second = BCD2BIN(msf->second);
@ -1364,7 +1373,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
/* Try to allocate space. */ /* Try to allocate space. */
toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL);
if (toc == NULL) { if (toc == NULL) {
printk (KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name);
return -ENOMEM; return -ENOMEM;
} }
info->toc = toc; info->toc = toc;
@ -1459,7 +1468,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
toc->ent[i].track = BCD2BIN(toc->ent[i].track); toc->ent[i].track = BCD2BIN(toc->ent[i].track);
msf_from_bcd(&toc->ent[i].addr.msf); msf_from_bcd(&toc->ent[i].addr.msf);
} }
toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute, toc->ent[i].addr.lba = msf_to_lba(toc->ent[i].addr.msf.minute,
toc->ent[i].addr.msf.second, toc->ent[i].addr.msf.second,
toc->ent[i].addr.msf.frame); toc->ent[i].addr.msf.frame);
} }
@ -1485,7 +1494,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
if (stat) if (stat)
return stat; return stat;
msf_from_bcd (&ms_tmp.ent.addr.msf); msf_from_bcd(&ms_tmp.ent.addr.msf);
toc->last_session_lba = msf_to_lba(ms_tmp.ent.addr.msf.minute, toc->last_session_lba = msf_to_lba(ms_tmp.ent.addr.msf.minute,
ms_tmp.ent.addr.msf.second, ms_tmp.ent.addr.msf.second,
ms_tmp.ent.addr.msf.frame); ms_tmp.ent.addr.msf.frame);
@ -1569,7 +1578,7 @@ static struct cdrom_device_ops ide_cdrom_dops = {
.generic_packet = ide_cdrom_packet, .generic_packet = ide_cdrom_packet,
}; };
static int ide_cdrom_register (ide_drive_t *drive, int nslots) static int ide_cdrom_register(ide_drive_t *drive, int nslots)
{ {
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *devinfo = &info->devinfo; struct cdrom_device_info *devinfo = &info->devinfo;
@ -1588,7 +1597,7 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
} }
static static
int ide_cdrom_probe_capabilities (ide_drive_t *drive) int ide_cdrom_probe_capabilities(ide_drive_t *drive)
{ {
struct cdrom_info *cd = drive->driver_data; struct cdrom_info *cd = drive->driver_data;
struct cdrom_device_info *cdi = &cd->devinfo; struct cdrom_device_info *cdi = &cd->devinfo;
@ -1838,7 +1847,7 @@ static unsigned int ide_cd_flags(struct hd_driveid *id)
} }
static static
int ide_cdrom_setup (ide_drive_t *drive) int ide_cdrom_setup(ide_drive_t *drive)
{ {
struct cdrom_info *cd = drive->driver_data; struct cdrom_info *cd = drive->driver_data;
struct cdrom_device_info *cdi = &cd->devinfo; struct cdrom_device_info *cdi = &cd->devinfo;
@ -1869,7 +1878,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD)
cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */ cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */
nslots = ide_cdrom_probe_capabilities (drive); nslots = ide_cdrom_probe_capabilities(drive);
/* /*
* set correct block size * set correct block size
@ -1881,7 +1890,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
drive->dsc_overlap = (drive->next != drive); drive->dsc_overlap = (drive->next != drive);
if (ide_cdrom_register(drive, nslots)) { if (ide_cdrom_register(drive, nslots)) {
printk (KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); printk(KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
cd->devinfo.handle = NULL; cd->devinfo.handle = NULL;
return 1; return 1;
} }
@ -1891,7 +1900,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
#ifdef CONFIG_IDE_PROC_FS #ifdef CONFIG_IDE_PROC_FS
static static
sector_t ide_cdrom_capacity (ide_drive_t *drive) sector_t ide_cdrom_capacity(ide_drive_t *drive)
{ {
unsigned long capacity, sectors_per_frame; unsigned long capacity, sectors_per_frame;
@ -1940,8 +1949,8 @@ static int proc_idecd_read_capacity
ide_drive_t *drive = data; ide_drive_t *drive = data;
int len; int len;
len = sprintf(page,"%llu\n", (long long)ide_cdrom_capacity(drive)); len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive));
PROC_IDE_READ_RETURN(page,start,off,count,eof,len); PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
} }
static ide_proc_entry_t idecd_proc[] = { static ide_proc_entry_t idecd_proc[] = {
@ -1970,13 +1979,14 @@ static ide_driver_t ide_cdrom_driver = {
#endif #endif
}; };
static int idecd_open(struct inode * inode, struct file * file) static int idecd_open(struct inode *inode, struct file *file)
{ {
struct gendisk *disk = inode->i_bdev->bd_disk; struct gendisk *disk = inode->i_bdev->bd_disk;
struct cdrom_info *info; struct cdrom_info *info;
int rc = -ENOMEM; int rc = -ENOMEM;
if (!(info = ide_cd_get(disk))) info = ide_cd_get(disk);
if (!info)
return -ENXIO; return -ENXIO;
rc = cdrom_open(&info->devinfo, inode, file); rc = cdrom_open(&info->devinfo, inode, file);
@ -1987,12 +1997,12 @@ static int idecd_open(struct inode * inode, struct file * file)
return rc; return rc;
} }
static int idecd_release(struct inode * inode, struct file * file) static int idecd_release(struct inode *inode, struct file *file)
{ {
struct gendisk *disk = inode->i_bdev->bd_disk; struct gendisk *disk = inode->i_bdev->bd_disk;
struct cdrom_info *info = ide_cd_g(disk); struct cdrom_info *info = ide_cd_g(disk);
cdrom_release (&info->devinfo, file); cdrom_release(&info->devinfo, file);
ide_cd_put(info); ide_cd_put(info);
@ -2033,12 +2043,12 @@ static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg)
return stat; return stat;
spindown = buffer[11] & 0x0f; spindown = buffer[11] & 0x0f;
if (copy_to_user((void __user *)arg, &spindown, sizeof (char))) if (copy_to_user((void __user *)arg, &spindown, sizeof(char)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
static int idecd_ioctl (struct inode *inode, struct file *file, static int idecd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct block_device *bdev = inode->i_bdev; struct block_device *bdev = inode->i_bdev;
@ -2083,11 +2093,11 @@ static struct block_device_operations idecd_ops = {
.release = idecd_release, .release = idecd_release,
.ioctl = idecd_ioctl, .ioctl = idecd_ioctl,
.media_changed = idecd_media_changed, .media_changed = idecd_media_changed,
.revalidate_disk= idecd_revalidate_disk .revalidate_disk = idecd_revalidate_disk
}; };
/* options */ /* options */
static char *ignore = NULL; static char *ignore;
module_param(ignore, charp, 0400); module_param(ignore, charp, 0400);
MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); MODULE_DESCRIPTION("ATAPI CD-ROM Driver");