Commit 96eefad2 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Christoph Hellwig

scsi: Implement sr_printk()

Update the sr driver to use dev_printk() variants instead of
plain printk(); this will prefix logging messages with the
appropriate device.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent d9e5d618
...@@ -292,8 +292,8 @@ static unsigned int sr_check_events(struct cdrom_device_info *cdi, ...@@ -292,8 +292,8 @@ static unsigned int sr_check_events(struct cdrom_device_info *cdi,
if (!cd->tur_changed) { if (!cd->tur_changed) {
if (cd->get_event_changed) { if (cd->get_event_changed) {
if (cd->tur_mismatch++ > 8) { if (cd->tur_mismatch++ > 8) {
sdev_printk(KERN_WARNING, cd->device, sr_printk(KERN_WARNING, cd,
"GET_EVENT and TUR disagree continuously, suppress GET_EVENT events\n"); "GET_EVENT and TUR disagree continuously, suppress GET_EVENT events\n");
cd->ignore_get_event = true; cd->ignore_get_event = true;
} }
} else { } else {
...@@ -322,7 +322,7 @@ static int sr_done(struct scsi_cmnd *SCpnt) ...@@ -322,7 +322,7 @@ static int sr_done(struct scsi_cmnd *SCpnt)
struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk); struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
#ifdef DEBUG #ifdef DEBUG
printk("sr.c done: %x\n", result); scmd_printk(KERN_INFO, SCpnt, "done: %x\n", result);
#endif #endif
/* /*
...@@ -398,13 +398,14 @@ static int sr_init_command(struct scsi_cmnd *SCpnt) ...@@ -398,13 +398,14 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
* is used for a killable error condition */ * is used for a killable error condition */
ret = BLKPREP_KILL; ret = BLKPREP_KILL;
SCSI_LOG_HLQUEUE(1, printk("Doing sr request, dev = %s, block = %d\n", SCSI_LOG_HLQUEUE(1, scmd_printk(KERN_INFO, SCpnt,
cd->disk->disk_name, block)); "Doing sr request, block = %d\n", block));
if (!cd->device || !scsi_device_online(cd->device)) { if (!cd->device || !scsi_device_online(cd->device)) {
SCSI_LOG_HLQUEUE(2, printk("Finishing %u sectors\n", SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
blk_rq_sectors(rq))); "Finishing %u sectors\n", blk_rq_sectors(rq)));
SCSI_LOG_HLQUEUE(2, printk("Retry with 0x%p\n", SCpnt)); SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
"Retry with 0x%p\n", SCpnt));
goto out; goto out;
} }
...@@ -425,7 +426,8 @@ static int sr_init_command(struct scsi_cmnd *SCpnt) ...@@ -425,7 +426,8 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
if (!in_interrupt()) if (!in_interrupt())
sr_set_blocklength(cd, 2048); sr_set_blocklength(cd, 2048);
else else
printk("sr: can't switch blocksize: in interrupt\n"); scmd_printk(KERN_INFO, SCpnt,
"can't switch blocksize: in interrupt\n");
} }
if (s_size != 512 && s_size != 1024 && s_size != 2048) { if (s_size != 512 && s_size != 1024 && s_size != 2048) {
...@@ -438,7 +440,7 @@ static int sr_init_command(struct scsi_cmnd *SCpnt) ...@@ -438,7 +440,7 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
goto out; goto out;
SCpnt->cmnd[0] = WRITE_10; SCpnt->cmnd[0] = WRITE_10;
SCpnt->sc_data_direction = DMA_TO_DEVICE; SCpnt->sc_data_direction = DMA_TO_DEVICE;
cd->cdi.media_written = 1; cd->cdi.media_written = 1;
} else if (rq_data_dir(rq) == READ) { } else if (rq_data_dir(rq) == READ) {
SCpnt->cmnd[0] = READ_10; SCpnt->cmnd[0] = READ_10;
SCpnt->sc_data_direction = DMA_FROM_DEVICE; SCpnt->sc_data_direction = DMA_FROM_DEVICE;
...@@ -475,11 +477,11 @@ static int sr_init_command(struct scsi_cmnd *SCpnt) ...@@ -475,11 +477,11 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
this_count = (scsi_bufflen(SCpnt) >> 9) / (s_size >> 9); this_count = (scsi_bufflen(SCpnt) >> 9) / (s_size >> 9);
SCSI_LOG_HLQUEUE(2, printk("%s : %s %d/%u 512 byte blocks.\n", SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
cd->cdi.name, "%s %d/%u 512 byte blocks.\n",
(rq_data_dir(rq) == WRITE) ? (rq_data_dir(rq) == WRITE) ?
"writing" : "reading", "writing" : "reading",
this_count, blk_rq_sectors(rq))); this_count, blk_rq_sectors(rq)));
SCpnt->cmnd[1] = 0; SCpnt->cmnd[1] = 0;
block = (unsigned int)blk_rq_pos(rq) / (s_size >> 9); block = (unsigned int)blk_rq_pos(rq) / (s_size >> 9);
...@@ -810,8 +812,8 @@ static void get_sectorsize(struct scsi_cd *cd) ...@@ -810,8 +812,8 @@ static void get_sectorsize(struct scsi_cd *cd)
case 512: case 512:
break; break;
default: default:
printk("%s: unsupported sector size %d.\n", sr_printk(KERN_INFO, cd,
cd->cdi.name, sector_size); "unsupported sector size %d.", sector_size);
cd->capacity = 0; cd->capacity = 0;
} }
...@@ -853,7 +855,7 @@ static void get_capabilities(struct scsi_cd *cd) ...@@ -853,7 +855,7 @@ static void get_capabilities(struct scsi_cd *cd)
/* allocate transfer buffer */ /* allocate transfer buffer */
buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
if (!buffer) { if (!buffer) {
printk(KERN_ERR "sr: out of memory.\n"); sr_printk(KERN_ERR, cd, "out of memory.\n");
return; return;
} }
...@@ -872,7 +874,7 @@ static void get_capabilities(struct scsi_cd *cd) ...@@ -872,7 +874,7 @@ static void get_capabilities(struct scsi_cd *cd)
CDC_SELECT_DISC | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_SELECT_SPEED |
CDC_MRW | CDC_MRW_W | CDC_RAM); CDC_MRW | CDC_MRW_W | CDC_RAM);
kfree(buffer); kfree(buffer);
printk("%s: scsi-1 drive\n", cd->cdi.name); sr_printk(KERN_INFO, cd, "scsi-1 drive");
return; return;
} }
...@@ -881,22 +883,23 @@ static void get_capabilities(struct scsi_cd *cd) ...@@ -881,22 +883,23 @@ static void get_capabilities(struct scsi_cd *cd)
cd->readcd_known = 1; cd->readcd_known = 1;
cd->readcd_cdda = buffer[n + 5] & 0x01; cd->readcd_cdda = buffer[n + 5] & 0x01;
/* print some capability bits */ /* print some capability bits */
printk("%s: scsi3-mmc drive: %dx/%dx %s%s%s%s%s%s\n", cd->cdi.name, sr_printk(KERN_INFO, cd,
((buffer[n + 14] << 8) + buffer[n + 15]) / 176, "scsi3-mmc drive: %dx/%dx %s%s%s%s%s%s\n",
cd->cdi.speed, ((buffer[n + 14] << 8) + buffer[n + 15]) / 176,
buffer[n + 3] & 0x01 ? "writer " : "", /* CD Writer */ cd->cdi.speed,
buffer[n + 3] & 0x20 ? "dvd-ram " : "", buffer[n + 3] & 0x01 ? "writer " : "", /* CD Writer */
buffer[n + 2] & 0x02 ? "cd/rw " : "", /* can read rewriteable */ buffer[n + 3] & 0x20 ? "dvd-ram " : "",
buffer[n + 4] & 0x20 ? "xa/form2 " : "", /* can read xa/from2 */ buffer[n + 2] & 0x02 ? "cd/rw " : "", /* can read rewriteable */
buffer[n + 5] & 0x01 ? "cdda " : "", /* can read audio data */ buffer[n + 4] & 0x20 ? "xa/form2 " : "", /* can read xa/from2 */
loadmech[buffer[n + 6] >> 5]); buffer[n + 5] & 0x01 ? "cdda " : "", /* can read audio data */
loadmech[buffer[n + 6] >> 5]);
if ((buffer[n + 6] >> 5) == 0) if ((buffer[n + 6] >> 5) == 0)
/* caddy drives can't close tray... */ /* caddy drives can't close tray... */
cd->cdi.mask |= CDC_CLOSE_TRAY; cd->cdi.mask |= CDC_CLOSE_TRAY;
if ((buffer[n + 2] & 0x8) == 0) if ((buffer[n + 2] & 0x8) == 0)
/* not a DVD drive */ /* not a DVD drive */
cd->cdi.mask |= CDC_DVD; cd->cdi.mask |= CDC_DVD;
if ((buffer[n + 3] & 0x20) == 0) if ((buffer[n + 3] & 0x20) == 0)
/* can't write DVD-RAM media */ /* can't write DVD-RAM media */
cd->cdi.mask |= CDC_DVD_RAM; cd->cdi.mask |= CDC_DVD_RAM;
if ((buffer[n + 3] & 0x10) == 0) if ((buffer[n + 3] & 0x10) == 0)
...@@ -935,7 +938,7 @@ static void get_capabilities(struct scsi_cd *cd) ...@@ -935,7 +938,7 @@ static void get_capabilities(struct scsi_cd *cd)
/* /*
* sr_packet() is the entry point for the generic commands generated * sr_packet() is the entry point for the generic commands generated
* by the Uniform CD-ROM layer. * by the Uniform CD-ROM layer.
*/ */
static int sr_packet(struct cdrom_device_info *cdi, static int sr_packet(struct cdrom_device_info *cdi,
struct packet_command *cgc) struct packet_command *cgc)
......
...@@ -55,6 +55,10 @@ typedef struct scsi_cd { ...@@ -55,6 +55,10 @@ typedef struct scsi_cd {
struct gendisk *disk; struct gendisk *disk;
} Scsi_CD; } Scsi_CD;
#define sr_printk(prefix, cd, fmt, a...) \
sdev_printk(prefix, (cd)->device, "[%s] " fmt, \
(cd)->cdi.name, ##a)
int sr_do_ioctl(Scsi_CD *, struct packet_command *); int sr_do_ioctl(Scsi_CD *, struct packet_command *);
int sr_lock_door(struct cdrom_device_info *, int); int sr_lock_door(struct cdrom_device_info *, int);
......
...@@ -36,7 +36,6 @@ module_param(xa_test, int, S_IRUGO | S_IWUSR); ...@@ -36,7 +36,6 @@ module_param(xa_test, int, S_IRUGO | S_IWUSR);
* the status of the unchecked_isa_dma flag in the host structure */ * the status of the unchecked_isa_dma flag in the host structure */
#define SR_GFP_DMA(cd) (((cd)->device->host->unchecked_isa_dma) ? GFP_DMA : 0) #define SR_GFP_DMA(cd) (((cd)->device->host->unchecked_isa_dma) ? GFP_DMA : 0)
static int sr_read_tochdr(struct cdrom_device_info *cdi, static int sr_read_tochdr(struct cdrom_device_info *cdi,
struct cdrom_tochdr *tochdr) struct cdrom_tochdr *tochdr)
{ {
...@@ -219,7 +218,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) ...@@ -219,7 +218,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
case UNIT_ATTENTION: case UNIT_ATTENTION:
SDev->changed = 1; SDev->changed = 1;
if (!cgc->quiet) if (!cgc->quiet)
printk(KERN_INFO "%s: disc change detected.\n", cd->cdi.name); sr_printk(KERN_INFO, cd,
"disc change detected.\n");
if (retries++ < 10) if (retries++ < 10)
goto retry; goto retry;
err = -ENOMEDIUM; err = -ENOMEDIUM;
...@@ -229,7 +229,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) ...@@ -229,7 +229,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
sshdr.ascq == 0x01) { sshdr.ascq == 0x01) {
/* sense: Logical unit is in process of becoming ready */ /* sense: Logical unit is in process of becoming ready */
if (!cgc->quiet) if (!cgc->quiet)
printk(KERN_INFO "%s: CDROM not ready yet.\n", cd->cdi.name); sr_printk(KERN_INFO, cd,
"CDROM not ready yet.\n");
if (retries++ < 10) { if (retries++ < 10) {
/* sleep 2 sec and try again */ /* sleep 2 sec and try again */
ssleep(2); ssleep(2);
...@@ -241,7 +242,9 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) ...@@ -241,7 +242,9 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
} }
} }
if (!cgc->quiet) if (!cgc->quiet)
printk(KERN_INFO "%s: CDROM not ready. Make sure there is a disc in the drive.\n", cd->cdi.name); sr_printk(KERN_INFO, cd,
"CDROM not ready. Make sure there "
"is a disc in the drive.\n");
#ifdef DEBUG #ifdef DEBUG
scsi_print_sense_hdr("sr", &sshdr); scsi_print_sense_hdr("sr", &sshdr);
#endif #endif
...@@ -259,7 +262,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) ...@@ -259,7 +262,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
#endif #endif
break; break;
default: default:
printk(KERN_ERR "%s: CDROM (ioctl) error, command: ", cd->cdi.name); sr_printk(KERN_ERR, cd,
"CDROM (ioctl) error, command: ");
__scsi_print_command(cgc->cmd); __scsi_print_command(cgc->cmd);
scsi_print_sense_hdr("sr", &sshdr); scsi_print_sense_hdr("sr", &sshdr);
err = -EIO; err = -EIO;
...@@ -491,8 +495,8 @@ static int sr_read_cd(Scsi_CD *cd, unsigned char *dest, int lba, int format, int ...@@ -491,8 +495,8 @@ static int sr_read_cd(Scsi_CD *cd, unsigned char *dest, int lba, int format, int
struct packet_command cgc; struct packet_command cgc;
#ifdef DEBUG #ifdef DEBUG
printk("%s: sr_read_cd lba=%d format=%d blksize=%d\n", sr_printk(KERN_INFO, cd, "sr_read_cd lba=%d format=%d blksize=%d\n",
cd->cdi.name, lba, format, blksize); lba, format, blksize);
#endif #endif
memset(&cgc, 0, sizeof(struct packet_command)); memset(&cgc, 0, sizeof(struct packet_command));
...@@ -539,7 +543,8 @@ static int sr_read_sector(Scsi_CD *cd, int lba, int blksize, unsigned char *dest ...@@ -539,7 +543,8 @@ static int sr_read_sector(Scsi_CD *cd, int lba, int blksize, unsigned char *dest
if (-EDRIVE_CANT_DO_THIS != rc) if (-EDRIVE_CANT_DO_THIS != rc)
return rc; return rc;
cd->readcd_known = 0; cd->readcd_known = 0;
printk("CDROM does'nt support READ CD (0xbe) command\n"); sr_printk(KERN_INFO, cd,
"CDROM does'nt support READ CD (0xbe) command\n");
/* fall & retry the other way */ /* fall & retry the other way */
} }
/* ... if this fails, we switch the blocksize using MODE SELECT */ /* ... if this fails, we switch the blocksize using MODE SELECT */
...@@ -548,7 +553,8 @@ static int sr_read_sector(Scsi_CD *cd, int lba, int blksize, unsigned char *dest ...@@ -548,7 +553,8 @@ static int sr_read_sector(Scsi_CD *cd, int lba, int blksize, unsigned char *dest
return rc; return rc;
} }
#ifdef DEBUG #ifdef DEBUG
printk("%s: sr_read_sector lba=%d blksize=%d\n", cd->cdi.name, lba, blksize); sr_printk(KERN_INFO, cd, "sr_read_sector lba=%d blksize=%d\n",
lba, blksize);
#endif #endif
memset(&cgc, 0, sizeof(struct packet_command)); memset(&cgc, 0, sizeof(struct packet_command));
...@@ -592,7 +598,7 @@ int sr_is_xa(Scsi_CD *cd) ...@@ -592,7 +598,7 @@ int sr_is_xa(Scsi_CD *cd)
} }
kfree(raw_sector); kfree(raw_sector);
#ifdef DEBUG #ifdef DEBUG
printk("%s: sr_is_xa: %d\n", cd->cdi.name, is_xa); sr_printk(KERN_INFO, cd, "sr_is_xa: %d\n", is_xa);
#endif #endif
return is_xa; return is_xa;
} }
...@@ -123,7 +123,7 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength) ...@@ -123,7 +123,7 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength)
return -ENOMEM; return -ENOMEM;
#ifdef DEBUG #ifdef DEBUG
printk("%s: MODE SELECT 0x%x/%d\n", cd->cdi.name, density, blocklength); sr_printk(KERN_INFO, cd, "MODE SELECT 0x%x/%d\n", density, blocklength);
#endif #endif
memset(&cgc, 0, sizeof(struct packet_command)); memset(&cgc, 0, sizeof(struct packet_command));
cgc.cmd[0] = MODE_SELECT; cgc.cmd[0] = MODE_SELECT;
...@@ -144,8 +144,9 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength) ...@@ -144,8 +144,9 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength)
} }
#ifdef DEBUG #ifdef DEBUG
else else
printk("%s: switching blocklength to %d bytes failed\n", sr_printk(KERN_INFO, cd,
cd->cdi.name, blocklength); "switching blocklength to %d bytes failed\n",
blocklength);
#endif #endif
kfree(buffer); kfree(buffer);
return rc; return rc;
...@@ -190,8 +191,8 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -190,8 +191,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
if (rc != 0) if (rc != 0)
break; break;
if ((buffer[0] << 8) + buffer[1] < 0x0a) { if ((buffer[0] << 8) + buffer[1] < 0x0a) {
printk(KERN_INFO "%s: Hmm, seems the drive " sr_printk(KERN_INFO, cd, "Hmm, seems the drive "
"doesn't support multisession CD's\n", cd->cdi.name); "doesn't support multisession CD's\n");
no_multi = 1; no_multi = 1;
break; break;
} }
...@@ -218,9 +219,9 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -218,9 +219,9 @@ int sr_cd_check(struct cdrom_device_info *cdi)
if (rc != 0) if (rc != 0)
break; break;
if (buffer[14] != 0 && buffer[14] != 0xb0) { if (buffer[14] != 0 && buffer[14] != 0xb0) {
printk(KERN_INFO "%s: Hmm, seems the cdrom " sr_printk(KERN_INFO, cd, "Hmm, seems the cdrom "
"doesn't support multisession CD's\n", "doesn't support multisession CD's\n");
cd->cdi.name);
no_multi = 1; no_multi = 1;
break; break;
} }
...@@ -245,9 +246,8 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -245,9 +246,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
cgc.timeout = VENDOR_TIMEOUT; cgc.timeout = VENDOR_TIMEOUT;
rc = sr_do_ioctl(cd, &cgc); rc = sr_do_ioctl(cd, &cgc);
if (rc == -EINVAL) { if (rc == -EINVAL) {
printk(KERN_INFO "%s: Hmm, seems the drive " sr_printk(KERN_INFO, cd, "Hmm, seems the drive "
"doesn't support multisession CD's\n", "doesn't support multisession CD's\n");
cd->cdi.name);
no_multi = 1; no_multi = 1;
break; break;
} }
...@@ -277,8 +277,8 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -277,8 +277,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
break; break;
} }
if ((rc = buffer[2]) == 0) { if ((rc = buffer[2]) == 0) {
printk(KERN_WARNING sr_printk(KERN_WARNING, cd,
"%s: No finished session\n", cd->cdi.name); "No finished session\n");
break; break;
} }
cgc.cmd[0] = READ_TOC; /* Read TOC */ cgc.cmd[0] = READ_TOC; /* Read TOC */
...@@ -301,9 +301,9 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -301,9 +301,9 @@ int sr_cd_check(struct cdrom_device_info *cdi)
default: default:
/* should not happen */ /* should not happen */
printk(KERN_WARNING sr_printk(KERN_WARNING, cd,
"%s: unknown vendor code (%i), not initialized ?\n", "unknown vendor code (%i), not initialized ?\n",
cd->cdi.name, cd->vendor); cd->vendor);
sector = 0; sector = 0;
no_multi = 1; no_multi = 1;
break; break;
...@@ -321,8 +321,8 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -321,8 +321,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
#ifdef DEBUG #ifdef DEBUG
if (sector) if (sector)
printk(KERN_DEBUG "%s: multisession offset=%lu\n", sr_printk(KERN_DEBUG, cd, "multisession offset=%lu\n",
cd->cdi.name, sector); sector);
#endif #endif
kfree(buffer); kfree(buffer);
return rc; return rc;
......
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