diff options
Diffstat (limited to 'drivers/cdrom')
-rw-r--r-- | drivers/cdrom/cdrom.c | 74 | ||||
-rw-r--r-- | drivers/cdrom/gdrom.c | 139 | ||||
-rw-r--r-- | drivers/cdrom/viocd.c | 116 |
3 files changed, 173 insertions, 156 deletions
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 71d1b9bab70..af13c62dc47 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -242,6 +242,8 @@ -------------------------------------------------------------------------*/ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #define REVISION "Revision: 3.20" #define VERSION "Id: cdrom.c 3.20 2003/12/17" @@ -314,11 +316,17 @@ static const char *mrw_format_status[] = { static const char *mrw_address_space[] = { "DMA", "GAA" }; #if (ERRLOGMASK!=CD_NOTHING) -#define cdinfo(type, fmt, args...) \ - if ((ERRLOGMASK & type) || debug==1 ) \ - printk(KERN_INFO "cdrom: " fmt, ## args) +#define cdinfo(type, fmt, args...) \ +do { \ + if ((ERRLOGMASK & type) || debug == 1) \ + pr_info(fmt, ##args); \ +} while (0) #else -#define cdinfo(type, fmt, args...) +#define cdinfo(type, fmt, args...) \ +do { \ + if (0 && (ERRLOGMASK & type) || debug == 1) \ + pr_info(fmt, ##args); \ +} while (0) #endif /* These are used to simplify getting data in from and back to user land */ @@ -395,7 +403,7 @@ int register_cdrom(struct cdrom_device_info *cdi) if (cdo->open == NULL || cdo->release == NULL) return -EINVAL; if (!banner_printed) { - printk(KERN_INFO "Uniform CD-ROM driver " REVISION "\n"); + pr_info("Uniform CD-ROM driver " REVISION "\n"); banner_printed = 1; cdrom_sysctl_register(); } @@ -546,7 +554,7 @@ static int cdrom_mrw_bgformat(struct cdrom_device_info *cdi, int cont) unsigned char buffer[12]; int ret; - printk(KERN_INFO "cdrom: %sstarting format\n", cont ? "Re" : ""); + pr_info("%sstarting format\n", cont ? "Re" : ""); /* * FmtData bit set (bit 4), format type is 1 @@ -576,7 +584,7 @@ static int cdrom_mrw_bgformat(struct cdrom_device_info *cdi, int cont) ret = cdi->ops->generic_packet(cdi, &cgc); if (ret) - printk(KERN_INFO "cdrom: bgformat failed\n"); + pr_info("bgformat failed\n"); return ret; } @@ -622,8 +630,7 @@ static int cdrom_mrw_exit(struct cdrom_device_info *cdi) ret = 0; if (di.mrw_status == CDM_MRW_BGFORMAT_ACTIVE) { - printk(KERN_INFO "cdrom: issuing MRW back ground " - "format suspend\n"); + pr_info("issuing MRW background format suspend\n"); ret = cdrom_mrw_bgformat_susp(cdi, 0); } @@ -658,7 +665,8 @@ static int cdrom_mrw_set_lba_space(struct cdrom_device_info *cdi, int space) if ((ret = cdrom_mode_select(cdi, &cgc))) return ret; - printk(KERN_INFO "cdrom: %s: mrw address space %s selected\n", cdi->name, mrw_address_space[space]); + pr_info("%s: mrw address space %s selected\n", + cdi->name, mrw_address_space[space]); return 0; } @@ -762,7 +770,7 @@ static int cdrom_mrw_open_write(struct cdrom_device_info *cdi) * always reset to DMA lba space on open */ if (cdrom_mrw_set_lba_space(cdi, MRW_LBA_DMA)) { - printk(KERN_ERR "cdrom: failed setting lba address space\n"); + pr_err("failed setting lba address space\n"); return 1; } @@ -781,8 +789,7 @@ static int cdrom_mrw_open_write(struct cdrom_device_info *cdi) * 3 - MRW formatting complete */ ret = 0; - printk(KERN_INFO "cdrom open: mrw_status '%s'\n", - mrw_format_status[di.mrw_status]); + pr_info("open: mrw_status '%s'\n", mrw_format_status[di.mrw_status]); if (!di.mrw_status) ret = 1; else if (di.mrw_status == CDM_MRW_BGFORMAT_INACTIVE && @@ -932,8 +939,7 @@ static void cdrom_dvd_rw_close_write(struct cdrom_device_info *cdi) return; } - printk(KERN_INFO "cdrom: %s: dirty DVD+RW media, \"finalizing\"\n", - cdi->name); + pr_info("%s: dirty DVD+RW media, \"finalizing\"\n", cdi->name); init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE); cgc.cmd[0] = GPCMD_FLUSH_CACHE; @@ -2176,7 +2182,7 @@ retry: * frame dma, so drop to single frame dma if we need to */ if (cdi->cdda_method == CDDA_BPC_FULL && nframes > 1) { - printk("cdrom: dropping to single frame dma\n"); + pr_info("dropping to single frame dma\n"); cdi->cdda_method = CDDA_BPC_SINGLE; goto retry; } @@ -2189,7 +2195,7 @@ retry: if (cdi->last_sense != 0x04 && cdi->last_sense != 0x0b) return ret; - printk("cdrom: dropping to old style cdda (sense=%x)\n", cdi->last_sense); + pr_info("dropping to old style cdda (sense=%x)\n", cdi->last_sense); cdi->cdda_method = CDDA_OLD; return cdrom_read_cdda_old(cdi, ubuf, lba, nframes); } @@ -3401,7 +3407,7 @@ static int cdrom_print_info(const char *header, int val, char *info, "\t%d", CDROM_CAN(val) != 0); break; default: - printk(KERN_INFO "cdrom: invalid option%d\n", option); + pr_info("invalid option%d\n", option); return 1; } if (!ret) @@ -3412,7 +3418,7 @@ static int cdrom_print_info(const char *header, int val, char *info, return 0; } -static int cdrom_sysctl_info(ctl_table *ctl, int write, struct file * filp, +static int cdrom_sysctl_info(ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { int pos; @@ -3489,9 +3495,9 @@ static int cdrom_sysctl_info(ctl_table *ctl, int write, struct file * filp, goto done; doit: mutex_unlock(&cdrom_mutex); - return proc_dostring(ctl, write, filp, buffer, lenp, ppos); + return proc_dostring(ctl, write, buffer, lenp, ppos); done: - printk(KERN_INFO "cdrom: info buffer too small\n"); + pr_info("info buffer too small\n"); goto doit; } @@ -3525,12 +3531,12 @@ static void cdrom_update_settings(void) mutex_unlock(&cdrom_mutex); } -static int cdrom_sysctl_handler(ctl_table *ctl, int write, struct file * filp, +static int cdrom_sysctl_handler(ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { int ret; - ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos); + ret = proc_dointvec(ctl, write, buffer, lenp, ppos); if (write) { @@ -3557,67 +3563,65 @@ static ctl_table cdrom_table[] = { .data = &cdrom_sysctl_settings.info, .maxlen = CDROM_STR_SIZE, .mode = 0444, - .proc_handler = &cdrom_sysctl_info, + .proc_handler = cdrom_sysctl_info, }, { .procname = "autoclose", .data = &cdrom_sysctl_settings.autoclose, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &cdrom_sysctl_handler, + .proc_handler = cdrom_sysctl_handler, }, { .procname = "autoeject", .data = &cdrom_sysctl_settings.autoeject, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &cdrom_sysctl_handler, + .proc_handler = cdrom_sysctl_handler, }, { .procname = "debug", .data = &cdrom_sysctl_settings.debug, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &cdrom_sysctl_handler, + .proc_handler = cdrom_sysctl_handler, }, { .procname = "lock", .data = &cdrom_sysctl_settings.lock, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &cdrom_sysctl_handler, + .proc_handler = cdrom_sysctl_handler, }, { .procname = "check_media", .data = &cdrom_sysctl_settings.check, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = &cdrom_sysctl_handler + .proc_handler = cdrom_sysctl_handler }, - { .ctl_name = 0 } + { } }; static ctl_table cdrom_cdrom_table[] = { { - .ctl_name = DEV_CDROM, .procname = "cdrom", .maxlen = 0, .mode = 0555, .child = cdrom_table, }, - { .ctl_name = 0 } + { } }; /* Make sure that /proc/sys/dev is there */ static ctl_table cdrom_root_table[] = { { - .ctl_name = CTL_DEV, .procname = "dev", .maxlen = 0, .mode = 0555, .child = cdrom_cdrom_table, }, - { .ctl_name = 0 } + { } }; static struct ctl_table_header *cdrom_sysctl_header; @@ -3667,7 +3671,7 @@ static int __init cdrom_init(void) static void __exit cdrom_exit(void) { - printk(KERN_INFO "Uniform CD-ROM driver unloaded\n"); + pr_info("Uniform CD-ROM driver unloaded\n"); cdrom_sysctl_unregister(); } diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index b5621f27c4b..64a21461c40 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c @@ -19,6 +19,8 @@ * */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/init.h> #include <linux/module.h> #include <linux/fs.h> @@ -32,6 +34,7 @@ #include <linux/blkdev.h> #include <linux/interrupt.h> #include <linux/device.h> +#include <linux/mutex.h> #include <linux/wait.h> #include <linux/workqueue.h> #include <linux/platform_device.h> @@ -78,6 +81,7 @@ #define GDROM_DEFAULT_TIMEOUT (HZ * 7) +static DEFINE_MUTEX(gdrom_mutex); static const struct { int sense_key; const char * const text; @@ -138,18 +142,18 @@ static int gdrom_hardreset(struct cdrom_device_info *cd_info); static bool gdrom_is_busy(void) { - return (ctrl_inb(GDROM_ALTSTATUS_REG) & 0x80) != 0; + return (__raw_readb(GDROM_ALTSTATUS_REG) & 0x80) != 0; } static bool gdrom_data_request(void) { - return (ctrl_inb(GDROM_ALTSTATUS_REG) & 0x88) == 8; + return (__raw_readb(GDROM_ALTSTATUS_REG) & 0x88) == 8; } static bool gdrom_wait_clrbusy(void) { unsigned long timeout = jiffies + GDROM_DEFAULT_TIMEOUT; - while ((ctrl_inb(GDROM_ALTSTATUS_REG) & 0x80) && + while ((__raw_readb(GDROM_ALTSTATUS_REG) & 0x80) && (time_before(jiffies, timeout))) cpu_relax(); return time_before(jiffies, timeout + 1); @@ -177,14 +181,14 @@ static void gdrom_identifydevice(void *buf) gdrom_getsense(NULL); return; } - ctrl_outb(GDROM_COM_IDDEV, GDROM_STATUSCOMMAND_REG); + __raw_writeb(GDROM_COM_IDDEV, GDROM_STATUSCOMMAND_REG); if (!gdrom_wait_busy_sleeps()) { gdrom_getsense(NULL); return; } /* now read in the data */ for (c = 0; c < 40; c++) - data[c] = ctrl_inw(GDROM_DATA_REG); + data[c] = __raw_readw(GDROM_DATA_REG); } static void gdrom_spicommand(void *spi_string, int buflen) @@ -193,28 +197,28 @@ static void gdrom_spicommand(void *spi_string, int buflen) unsigned long timeout; /* ensure IRQ_WAIT is set */ - ctrl_outb(0x08, GDROM_ALTSTATUS_REG); + __raw_writeb(0x08, GDROM_ALTSTATUS_REG); /* specify how many bytes we expect back */ - ctrl_outb(buflen & 0xFF, GDROM_BCL_REG); - ctrl_outb((buflen >> 8) & 0xFF, GDROM_BCH_REG); + __raw_writeb(buflen & 0xFF, GDROM_BCL_REG); + __raw_writeb((buflen >> 8) & 0xFF, GDROM_BCH_REG); /* other parameters */ - ctrl_outb(0, GDROM_INTSEC_REG); - ctrl_outb(0, GDROM_SECNUM_REG); - ctrl_outb(0, GDROM_ERROR_REG); + __raw_writeb(0, GDROM_INTSEC_REG); + __raw_writeb(0, GDROM_SECNUM_REG); + __raw_writeb(0, GDROM_ERROR_REG); /* Wait until we can go */ if (!gdrom_wait_clrbusy()) { gdrom_getsense(NULL); return; } timeout = jiffies + GDROM_DEFAULT_TIMEOUT; - ctrl_outb(GDROM_COM_PACKET, GDROM_STATUSCOMMAND_REG); + __raw_writeb(GDROM_COM_PACKET, GDROM_STATUSCOMMAND_REG); while (!gdrom_data_request() && time_before(jiffies, timeout)) cpu_relax(); if (!time_before(jiffies, timeout + 1)) { gdrom_getsense(NULL); return; } - outsw(PHYSADDR(GDROM_DATA_REG), cmd, 6); + outsw(GDROM_DATA_REG, cmd, 6); } @@ -229,10 +233,10 @@ static char gdrom_execute_diagnostic(void) gdrom_hardreset(gd.cd_info); if (!gdrom_wait_clrbusy()) return 0; - ctrl_outb(GDROM_COM_EXECDIAG, GDROM_STATUSCOMMAND_REG); + __raw_writeb(GDROM_COM_EXECDIAG, GDROM_STATUSCOMMAND_REG); if (!gdrom_wait_busy_sleeps()) return 0; - return ctrl_inb(GDROM_ERROR_REG); + return __raw_readb(GDROM_ERROR_REG); } /* @@ -298,7 +302,7 @@ static int gdrom_readtoc_cmd(struct gdromtoc *toc, int session) err = -EINVAL; goto cleanup_readtoc; } - insw(PHYSADDR(GDROM_DATA_REG), toc, tocsize/2); + insw(GDROM_DATA_REG, toc, tocsize/2); if (gd.status & 0x01) err = -EINVAL; @@ -339,8 +343,7 @@ static int gdrom_get_last_session(struct cdrom_device_info *cd_info, tocuse = 0; err = gdrom_readtoc_cmd(gd.toc, 0); if (err) { - printk(KERN_INFO "GDROM: Could not get CD " - "table of contents\n"); + pr_info("Could not get CD table of contents\n"); return -ENXIO; } } @@ -357,8 +360,7 @@ static int gdrom_get_last_session(struct cdrom_device_info *cd_info, } while (track >= fentry); if ((track > 100) || (track < get_entry_track(gd.toc->first))) { - printk(KERN_INFO "GDROM: No data on the last " - "session of the CD\n"); + pr_info("No data on the last session of the CD\n"); gdrom_getsense(NULL); return -ENXIO; } @@ -383,7 +385,7 @@ static void gdrom_release(struct cdrom_device_info *cd_info) static int gdrom_drivestatus(struct cdrom_device_info *cd_info, int ignore) { /* read the sense key */ - char sense = ctrl_inb(GDROM_ERROR_REG); + char sense = __raw_readb(GDROM_ERROR_REG); sense &= 0xF0; if (sense == 0) return CDS_DISC_OK; @@ -396,16 +398,16 @@ static int gdrom_drivestatus(struct cdrom_device_info *cd_info, int ignore) static int gdrom_mediachanged(struct cdrom_device_info *cd_info, int ignore) { /* check the sense key */ - return (ctrl_inb(GDROM_ERROR_REG) & 0xF0) == 0x60; + return (__raw_readb(GDROM_ERROR_REG) & 0xF0) == 0x60; } /* reset the G1 bus */ static int gdrom_hardreset(struct cdrom_device_info *cd_info) { int count; - ctrl_outl(0x1fffff, GDROM_RESET_REG); + __raw_writel(0x1fffff, GDROM_RESET_REG); for (count = 0xa0000000; count < 0xa0200000; count += 4) - ctrl_inl(count); + __raw_readl(count); return 0; } @@ -449,16 +451,16 @@ static int gdrom_getsense(short *bufstring) GDROM_DEFAULT_TIMEOUT); if (gd.pending) goto cleanup_sense; - insw(PHYSADDR(GDROM_DATA_REG), &sense, sense_command->buflen/2); + insw(GDROM_DATA_REG, &sense, sense_command->buflen/2); if (sense[1] & 40) { - printk(KERN_INFO "GDROM: Drive not ready - command aborted\n"); + pr_info("Drive not ready - command aborted\n"); goto cleanup_sense; } sense_key = sense[1] & 0x0F; if (sense_key < ARRAY_SIZE(sense_texts)) - printk(KERN_INFO "GDROM: %s\n", sense_texts[sense_key].text); + pr_info("%s\n", sense_texts[sense_key].text); else - printk(KERN_ERR "GDROM: Unknown sense key: %d\n", sense_key); + pr_err("Unknown sense key: %d\n", sense_key); if (bufstring) /* return addional sense data */ memcpy(bufstring, &sense[4], 2); if (sense_key < 2) @@ -492,12 +494,18 @@ static struct cdrom_device_ops gdrom_ops = { static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode) { - return cdrom_open(gd.cd_info, bdev, mode); + int ret; + mutex_lock(&gdrom_mutex); + ret = cdrom_open(gd.cd_info, bdev, mode); + mutex_unlock(&gdrom_mutex); + return ret; } static int gdrom_bdops_release(struct gendisk *disk, fmode_t mode) { + mutex_lock(&gdrom_mutex); cdrom_release(gd.cd_info, mode); + mutex_unlock(&gdrom_mutex); return 0; } @@ -509,20 +517,26 @@ static int gdrom_bdops_mediachanged(struct gendisk *disk) static int gdrom_bdops_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, unsigned long arg) { - return cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg); + int ret; + + mutex_lock(&gdrom_mutex); + ret = cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg); + mutex_unlock(&gdrom_mutex); + + return ret; } -static struct block_device_operations gdrom_bdops = { +static const struct block_device_operations gdrom_bdops = { .owner = THIS_MODULE, .open = gdrom_bdops_open, .release = gdrom_bdops_release, .media_changed = gdrom_bdops_mediachanged, - .locked_ioctl = gdrom_bdops_ioctl, + .ioctl = gdrom_bdops_ioctl, }; static irqreturn_t gdrom_command_interrupt(int irq, void *dev_id) { - gd.status = ctrl_inb(GDROM_STATUSCOMMAND_REG); + gd.status = __raw_readb(GDROM_STATUSCOMMAND_REG); if (gd.pending != 1) return IRQ_HANDLED; gd.pending = 0; @@ -532,7 +546,7 @@ static irqreturn_t gdrom_command_interrupt(int irq, void *dev_id) static irqreturn_t gdrom_dma_interrupt(int irq, void *dev_id) { - gd.status = ctrl_inb(GDROM_STATUSCOMMAND_REG); + gd.status = __raw_readb(GDROM_STATUSCOMMAND_REG); if (gd.transfer != 1) return IRQ_HANDLED; gd.transfer = 0; @@ -586,10 +600,10 @@ static void gdrom_readdisk_dma(struct work_struct *work) spin_unlock(&gdrom_lock); block = blk_rq_pos(req)/GD_TO_BLK + GD_SESSION_OFFSET; block_cnt = blk_rq_sectors(req)/GD_TO_BLK; - ctrl_outl(PHYSADDR(req->buffer), GDROM_DMA_STARTADDR_REG); - ctrl_outl(block_cnt * GDROM_HARD_SECTOR, GDROM_DMA_LENGTH_REG); - ctrl_outl(1, GDROM_DMA_DIRECTION_REG); - ctrl_outl(1, GDROM_DMA_ENABLE_REG); + __raw_writel(virt_to_phys(req->buffer), GDROM_DMA_STARTADDR_REG); + __raw_writel(block_cnt * GDROM_HARD_SECTOR, GDROM_DMA_LENGTH_REG); + __raw_writel(1, GDROM_DMA_DIRECTION_REG); + __raw_writel(1, GDROM_DMA_ENABLE_REG); read_command->cmd[2] = (block >> 16) & 0xFF; read_command->cmd[3] = (block >> 8) & 0xFF; read_command->cmd[4] = block & 0xFF; @@ -597,32 +611,32 @@ static void gdrom_readdisk_dma(struct work_struct *work) read_command->cmd[9] = (block_cnt >> 8) & 0xFF; read_command->cmd[10] = block_cnt & 0xFF; /* set for DMA */ - ctrl_outb(1, GDROM_ERROR_REG); + __raw_writeb(1, GDROM_ERROR_REG); /* other registers */ - ctrl_outb(0, GDROM_SECNUM_REG); - ctrl_outb(0, GDROM_BCL_REG); - ctrl_outb(0, GDROM_BCH_REG); - ctrl_outb(0, GDROM_DSEL_REG); - ctrl_outb(0, GDROM_INTSEC_REG); + __raw_writeb(0, GDROM_SECNUM_REG); + __raw_writeb(0, GDROM_BCL_REG); + __raw_writeb(0, GDROM_BCH_REG); + __raw_writeb(0, GDROM_DSEL_REG); + __raw_writeb(0, GDROM_INTSEC_REG); /* Wait for registers to reset after any previous activity */ timeout = jiffies + HZ / 2; while (gdrom_is_busy() && time_before(jiffies, timeout)) cpu_relax(); - ctrl_outb(GDROM_COM_PACKET, GDROM_STATUSCOMMAND_REG); + __raw_writeb(GDROM_COM_PACKET, GDROM_STATUSCOMMAND_REG); timeout = jiffies + HZ / 2; /* Wait for packet command to finish */ while (gdrom_is_busy() && time_before(jiffies, timeout)) cpu_relax(); gd.pending = 1; gd.transfer = 1; - outsw(PHYSADDR(GDROM_DATA_REG), &read_command->cmd, 6); + outsw(GDROM_DATA_REG, &read_command->cmd, 6); timeout = jiffies + HZ / 2; /* Wait for any pending DMA to finish */ - while (ctrl_inb(GDROM_DMA_STATUS_REG) && + while (__raw_readb(GDROM_DMA_STATUS_REG) && time_before(jiffies, timeout)) cpu_relax(); /* start transfer */ - ctrl_outb(1, GDROM_DMA_STATUS_REG); + __raw_writeb(1, GDROM_DMA_STATUS_REG); wait_event_interruptible_timeout(request_queue, gd.transfer == 0, GDROM_DEFAULT_TIMEOUT); err = gd.transfer ? -EIO : 0; @@ -643,14 +657,13 @@ static void gdrom_request(struct request_queue *rq) struct request *req; while ((req = blk_fetch_request(rq)) != NULL) { - if (!blk_fs_request(req)) { - printk(KERN_DEBUG "GDROM: Non-fs request ignored\n"); + if (req->cmd_type != REQ_TYPE_FS) { + printk(KERN_DEBUG "gdrom: Non-fs request ignored\n"); __blk_end_request_all(req, -EIO); continue; } if (rq_data_dir(req) != READ) { - printk(KERN_NOTICE "GDROM: Read only device -"); - printk(" write request ignored\n"); + pr_notice("Read only device - write request ignored\n"); __blk_end_request_all(req, -EIO); continue; } @@ -685,7 +698,7 @@ static int __devinit gdrom_outputversion(void) firmw_ver = kstrndup(id->firmver, 16, GFP_KERNEL); if (!firmw_ver) goto free_manuf_name; - printk(KERN_INFO "GDROM: %s from %s with firmware %s\n", + pr_info("%s from %s with firmware %s\n", model_name, manuf_name, firmw_ver); err = 0; kfree(firmw_ver); @@ -701,11 +714,11 @@ free_id: /* set the default mode for DMA transfer */ static int __devinit gdrom_init_dma_mode(void) { - ctrl_outb(0x13, GDROM_ERROR_REG); - ctrl_outb(0x22, GDROM_INTSEC_REG); + __raw_writeb(0x13, GDROM_ERROR_REG); + __raw_writeb(0x22, GDROM_INTSEC_REG); if (!gdrom_wait_clrbusy()) return -EBUSY; - ctrl_outb(0xEF, GDROM_STATUSCOMMAND_REG); + __raw_writeb(0xEF, GDROM_STATUSCOMMAND_REG); if (!gdrom_wait_busy_sleeps()) return -EBUSY; /* Memory protection setting for GDROM DMA @@ -715,8 +728,8 @@ static int __devinit gdrom_init_dma_mode(void) * Bits 6 - 0 end of transfer range in 1 MB blocks OR'ed with 0x80 * (0x40 | 0x80) = start range at 0x0C000000 * (0x7F | 0x80) = end range at 0x0FFFFFFF */ - ctrl_outl(0x8843407F, GDROM_DMA_ACCESS_CTRL_REG); - ctrl_outl(9, GDROM_DMA_WAIT_REG); /* DMA word setting */ + __raw_writel(0x8843407F, GDROM_DMA_ACCESS_CTRL_REG); + __raw_writel(9, GDROM_DMA_WAIT_REG); /* DMA word setting */ return 0; } @@ -741,7 +754,7 @@ static int __devinit probe_gdrom_setupqueue(void) { blk_queue_logical_block_size(gd.gdrom_rq, GDROM_HARD_SECTOR); /* using DMA so memory will need to be contiguous */ - blk_queue_max_hw_segments(gd.gdrom_rq, 1); + blk_queue_max_segments(gd.gdrom_rq, 1); /* set a large max size to get most from DMA */ blk_queue_max_segment_size(gd.gdrom_rq, 0x40000); gd.disk->queue = gd.gdrom_rq; @@ -757,7 +770,7 @@ static int __devinit probe_gdrom(struct platform_device *devptr) int err; /* Start the device */ if (gdrom_execute_diagnostic() != 1) { - printk(KERN_WARNING "GDROM: ATA Probe for GDROM failed.\n"); + pr_warning("ATA Probe for GDROM failed\n"); return -ENODEV; } /* Print out firmware ID */ @@ -767,7 +780,7 @@ static int __devinit probe_gdrom(struct platform_device *devptr) gdrom_major = register_blkdev(0, GDROM_DEV_NAME); if (gdrom_major <= 0) return gdrom_major; - printk(KERN_INFO "GDROM: Registered with major number %d\n", + pr_info("Registered with major number %d\n", gdrom_major); /* Specify basic properties of drive */ gd.cd_info = kzalloc(sizeof(struct cdrom_device_info), GFP_KERNEL); @@ -818,13 +831,13 @@ probe_fail_no_disk: unregister_blkdev(gdrom_major, GDROM_DEV_NAME); gdrom_major = 0; probe_fail_no_mem: - printk(KERN_WARNING "GDROM: Probe failed - error is 0x%X\n", err); + pr_warning("Probe failed - error is 0x%X\n", err); return err; } static int __devexit remove_gdrom(struct platform_device *devptr) { - flush_scheduled_work(); + flush_work_sync(&work); blk_cleanup_queue(gd.gdrom_rq); free_irq(HW_EVENT_GDROM_CMD, &gd); free_irq(HW_EVENT_GDROM_DMA, &gd); diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c index 0fff646cc2f..be73a9b493a 100644 --- a/drivers/cdrom/viocd.c +++ b/drivers/cdrom/viocd.c @@ -31,6 +31,8 @@ * the OS/400 partition. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/major.h> #include <linux/blkdev.h> #include <linux/cdrom.h> @@ -40,6 +42,7 @@ #include <linux/module.h> #include <linux/completion.h> #include <linux/proc_fs.h> +#include <linux/mutex.h> #include <linux/seq_file.h> #include <linux/scatterlist.h> @@ -53,14 +56,12 @@ #define VIOCD_VERS "1.06" -#define VIOCD_KERN_WARNING KERN_WARNING "viocd: " -#define VIOCD_KERN_INFO KERN_INFO "viocd: " - /* * Should probably make this a module parameter....sigh */ #define VIOCD_MAX_CD HVMAXARCHITECTEDVIRTUALCDROMS +static DEFINE_MUTEX(viocd_mutex); static const struct vio_error_entry viocd_err_table[] = { {0x0201, EINVAL, "Invalid Range"}, {0x0202, EINVAL, "Invalid Token"}, @@ -154,13 +155,21 @@ static const struct file_operations proc_viocd_operations = { static int viocd_blk_open(struct block_device *bdev, fmode_t mode) { struct disk_info *di = bdev->bd_disk->private_data; - return cdrom_open(&di->viocd_info, bdev, mode); + int ret; + + mutex_lock(&viocd_mutex); + ret = cdrom_open(&di->viocd_info, bdev, mode); + mutex_unlock(&viocd_mutex); + + return ret; } static int viocd_blk_release(struct gendisk *disk, fmode_t mode) { struct disk_info *di = disk->private_data; + mutex_lock(&viocd_mutex); cdrom_release(&di->viocd_info, mode); + mutex_unlock(&viocd_mutex); return 0; } @@ -168,7 +177,13 @@ static int viocd_blk_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, unsigned long arg) { struct disk_info *di = bdev->bd_disk->private_data; - return cdrom_ioctl(&di->viocd_info, bdev, mode, cmd, arg); + int ret; + + mutex_lock(&viocd_mutex); + ret = cdrom_ioctl(&di->viocd_info, bdev, mode, cmd, arg); + mutex_unlock(&viocd_mutex); + + return ret; } static int viocd_blk_media_changed(struct gendisk *disk) @@ -177,11 +192,11 @@ static int viocd_blk_media_changed(struct gendisk *disk) return cdrom_media_changed(&di->viocd_info); } -struct block_device_operations viocd_fops = { +static const struct block_device_operations viocd_fops = { .owner = THIS_MODULE, .open = viocd_blk_open, .release = viocd_blk_release, - .locked_ioctl = viocd_blk_ioctl, + .ioctl = viocd_blk_ioctl, .media_changed = viocd_blk_media_changed, }; @@ -202,9 +217,8 @@ static int viocd_open(struct cdrom_device_info *cdi, int purpose) (u64)&we, VIOVERSION << 16, ((u64)device_no << 48), 0, 0, 0); if (hvrc != 0) { - printk(VIOCD_KERN_WARNING - "bad rc on HvCallEvent_signalLpEventFast %d\n", - (int)hvrc); + pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n", + (int)hvrc); return -EIO; } @@ -213,8 +227,8 @@ static int viocd_open(struct cdrom_device_info *cdi, int purpose) if (we.rc) { const struct vio_error_entry *err = vio_lookup_rc(viocd_err_table, we.sub_result); - printk(VIOCD_KERN_WARNING "bad rc %d:0x%04X on open: %s\n", - we.rc, we.sub_result, err->msg); + pr_warning("bad rc %d:0x%04X on open: %s\n", + we.rc, we.sub_result, err->msg); return -err->errno; } @@ -234,9 +248,8 @@ static void viocd_release(struct cdrom_device_info *cdi) viopath_targetinst(viopath_hostLp), 0, VIOVERSION << 16, ((u64)device_no << 48), 0, 0, 0); if (hvrc != 0) - printk(VIOCD_KERN_WARNING - "bad rc on HvCallEvent_signalLpEventFast %d\n", - (int)hvrc); + pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n", + (int)hvrc); } /* Send a read or write request to OS/400 */ @@ -262,13 +275,12 @@ static int send_request(struct request *req) sg_init_table(&sg, 1); if (blk_rq_map_sg(req->q, req, &sg) == 0) { - printk(VIOCD_KERN_WARNING - "error setting up scatter/gather list\n"); + pr_warning("error setting up scatter/gather list\n"); return -1; } if (dma_map_sg(diskinfo->dev, &sg, 1, direction) == 0) { - printk(VIOCD_KERN_WARNING "error allocating sg tce\n"); + pr_warning("error allocating sg tce\n"); return -1; } dmaaddr = sg_dma_address(&sg); @@ -284,7 +296,7 @@ static int send_request(struct request *req) ((u64)DEVICE_NR(diskinfo) << 48) | dmaaddr, (u64)blk_rq_pos(req) * 512, len, 0); if (hvrc != HvLpEvent_Rc_Good) { - printk(VIOCD_KERN_WARNING "hv error on op %d\n", (int)hvrc); + pr_warning("hv error on op %d\n", (int)hvrc); return -1; } @@ -298,11 +310,10 @@ static void do_viocd_request(struct request_queue *q) struct request *req; while ((rwreq == 0) && ((req = blk_fetch_request(q)) != NULL)) { - if (!blk_fs_request(req)) + if (req->cmd_type != REQ_TYPE_FS) __blk_end_request_all(req, -EIO); else if (send_request(req) < 0) { - printk(VIOCD_KERN_WARNING - "unable to send message to OS/400!"); + pr_warning("unable to send message to OS/400!\n"); __blk_end_request_all(req, -EIO); } else rwreq++; @@ -327,8 +338,8 @@ static int viocd_media_changed(struct cdrom_device_info *cdi, int disc_nr) (u64)&we, VIOVERSION << 16, ((u64)device_no << 48), 0, 0, 0); if (hvrc != 0) { - printk(VIOCD_KERN_WARNING "bad rc on HvCallEvent_signalLpEventFast %d\n", - (int)hvrc); + pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n", + (int)hvrc); return -EIO; } @@ -338,9 +349,8 @@ static int viocd_media_changed(struct cdrom_device_info *cdi, int disc_nr) if (we.rc) { const struct vio_error_entry *err = vio_lookup_rc(viocd_err_table, we.sub_result); - printk(VIOCD_KERN_WARNING - "bad rc %d:0x%04X on check_change: %s; Assuming no change\n", - we.rc, we.sub_result, err->msg); + pr_warning("bad rc %d:0x%04X on check_change: %s; Assuming no change\n", + we.rc, we.sub_result, err->msg); return 0; } @@ -367,8 +377,8 @@ static int viocd_lock_door(struct cdrom_device_info *cdi, int locking) (u64)&we, VIOVERSION << 16, (device_no << 48) | (flags << 32), 0, 0, 0); if (hvrc != 0) { - printk(VIOCD_KERN_WARNING "bad rc on HvCallEvent_signalLpEventFast %d\n", - (int)hvrc); + pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n", + (int)hvrc); return -EIO; } @@ -455,8 +465,7 @@ static void vio_handle_cd_event(struct HvLpEvent *event) return; /* First, we should NEVER get an int here...only acks */ if (hvlpevent_is_int(event)) { - printk(VIOCD_KERN_WARNING - "Yikes! got an int in viocd event handler!\n"); + pr_warning("Yikes! got an int in viocd event handler!\n"); if (hvlpevent_need_ack(event)) { event->xRc = HvLpEvent_Rc_InvalidSubtype; HvCallEvent_ackLpEvent(event); @@ -510,10 +519,9 @@ return_complete: const struct vio_error_entry *err = vio_lookup_rc(viocd_err_table, bevent->sub_result); - printk(VIOCD_KERN_WARNING "request %p failed " - "with rc %d:0x%04X: %s\n", - req, event->xRc, - bevent->sub_result, err->msg); + pr_warning("request %p failed with rc %d:0x%04X: %s\n", + req, event->xRc, + bevent->sub_result, err->msg); __blk_end_request_all(req, -EIO); } else __blk_end_request_all(req, 0); @@ -524,9 +532,8 @@ return_complete: break; default: - printk(VIOCD_KERN_WARNING - "message with invalid subtype %0x04X!\n", - event->xSubtype & VIOMINOR_SUBTYPE_MASK); + pr_warning("message with invalid subtype %0x04X!\n", + event->xSubtype & VIOMINOR_SUBTYPE_MASK); if (hvlpevent_need_ack(event)) { event->xRc = HvLpEvent_Rc_InvalidSubtype; HvCallEvent_ackLpEvent(event); @@ -567,7 +574,7 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id) struct disk_info *d; struct cdrom_device_info *c; struct request_queue *q; - struct device_node *node = vdev->dev.archdata.of_node; + struct device_node *node = vdev->dev.of_node; deviceno = vdev->unit_address; if (deviceno >= VIOCD_MAX_CD) @@ -593,32 +600,27 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id) sprintf(c->name, VIOCD_DEVICE "%c", 'a' + deviceno); if (register_cdrom(c) != 0) { - printk(VIOCD_KERN_WARNING "Cannot register viocd CD-ROM %s!\n", - c->name); + pr_warning("Cannot register viocd CD-ROM %s!\n", c->name); goto out; } - printk(VIOCD_KERN_INFO "cd %s is iSeries resource %10.10s " - "type %4.4s, model %3.3s\n", - c->name, d->rsrcname, d->type, d->model); + pr_info("cd %s is iSeries resource %10.10s type %4.4s, model %3.3s\n", + c->name, d->rsrcname, d->type, d->model); q = blk_init_queue(do_viocd_request, &viocd_reqlock); if (q == NULL) { - printk(VIOCD_KERN_WARNING "Cannot allocate queue for %s!\n", - c->name); + pr_warning("Cannot allocate queue for %s!\n", c->name); goto out_unregister_cdrom; } gendisk = alloc_disk(1); if (gendisk == NULL) { - printk(VIOCD_KERN_WARNING "Cannot create gendisk for %s!\n", - c->name); + pr_warning("Cannot create gendisk for %s!\n", c->name); goto out_cleanup_queue; } gendisk->major = VIOCD_MAJOR; gendisk->first_minor = deviceno; strncpy(gendisk->disk_name, c->name, sizeof(gendisk->disk_name)); - blk_queue_max_hw_segments(q, 1); - blk_queue_max_phys_segments(q, 1); - blk_queue_max_sectors(q, 4096 / 512); + blk_queue_max_segments(q, 1); + blk_queue_max_hw_sectors(q, 4096 / 512); gendisk->queue = q; gendisk->fops = &viocd_fops; gendisk->flags = GENHD_FL_CD|GENHD_FL_REMOVABLE; @@ -683,21 +685,19 @@ static int __init viocd_init(void) return -ENODEV; } - printk(VIOCD_KERN_INFO "vers " VIOCD_VERS ", hosting partition %d\n", - viopath_hostLp); + pr_info("vers " VIOCD_VERS ", hosting partition %d\n", viopath_hostLp); if (register_blkdev(VIOCD_MAJOR, VIOCD_DEVICE) != 0) { - printk(VIOCD_KERN_WARNING "Unable to get major %d for %s\n", - VIOCD_MAJOR, VIOCD_DEVICE); + pr_warning("Unable to get major %d for %s\n", + VIOCD_MAJOR, VIOCD_DEVICE); return -EIO; } ret = viopath_open(viopath_hostLp, viomajorsubtype_cdio, MAX_CD_REQ + 2); if (ret) { - printk(VIOCD_KERN_WARNING - "error opening path to host partition %d\n", - viopath_hostLp); + pr_warning("error opening path to host partition %d\n", + viopath_hostLp); goto out_unregister; } |