aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cdrom/viocd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cdrom/viocd.c')
-rw-r--r--drivers/cdrom/viocd.c106
1 files changed, 53 insertions, 53 deletions
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index 451cd7071b1d..56bf9f44700c 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -31,6 +31,8 @@
31 * the OS/400 partition. 31 * the OS/400 partition.
32 */ 32 */
33 33
34#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
35
34#include <linux/major.h> 36#include <linux/major.h>
35#include <linux/blkdev.h> 37#include <linux/blkdev.h>
36#include <linux/cdrom.h> 38#include <linux/cdrom.h>
@@ -40,6 +42,7 @@
40#include <linux/module.h> 42#include <linux/module.h>
41#include <linux/completion.h> 43#include <linux/completion.h>
42#include <linux/proc_fs.h> 44#include <linux/proc_fs.h>
45#include <linux/smp_lock.h>
43#include <linux/seq_file.h> 46#include <linux/seq_file.h>
44#include <linux/scatterlist.h> 47#include <linux/scatterlist.h>
45 48
@@ -53,9 +56,6 @@
53 56
54#define VIOCD_VERS "1.06" 57#define VIOCD_VERS "1.06"
55 58
56#define VIOCD_KERN_WARNING KERN_WARNING "viocd: "
57#define VIOCD_KERN_INFO KERN_INFO "viocd: "
58
59/* 59/*
60 * Should probably make this a module parameter....sigh 60 * Should probably make this a module parameter....sigh
61 */ 61 */
@@ -154,13 +154,21 @@ static const struct file_operations proc_viocd_operations = {
154static int viocd_blk_open(struct block_device *bdev, fmode_t mode) 154static int viocd_blk_open(struct block_device *bdev, fmode_t mode)
155{ 155{
156 struct disk_info *di = bdev->bd_disk->private_data; 156 struct disk_info *di = bdev->bd_disk->private_data;
157 return cdrom_open(&di->viocd_info, bdev, mode); 157 int ret;
158
159 lock_kernel();
160 ret = cdrom_open(&di->viocd_info, bdev, mode);
161 unlock_kernel();
162
163 return ret;
158} 164}
159 165
160static int viocd_blk_release(struct gendisk *disk, fmode_t mode) 166static int viocd_blk_release(struct gendisk *disk, fmode_t mode)
161{ 167{
162 struct disk_info *di = disk->private_data; 168 struct disk_info *di = disk->private_data;
169 lock_kernel();
163 cdrom_release(&di->viocd_info, mode); 170 cdrom_release(&di->viocd_info, mode);
171 unlock_kernel();
164 return 0; 172 return 0;
165} 173}
166 174
@@ -168,7 +176,13 @@ static int viocd_blk_ioctl(struct block_device *bdev, fmode_t mode,
168 unsigned cmd, unsigned long arg) 176 unsigned cmd, unsigned long arg)
169{ 177{
170 struct disk_info *di = bdev->bd_disk->private_data; 178 struct disk_info *di = bdev->bd_disk->private_data;
171 return cdrom_ioctl(&di->viocd_info, bdev, mode, cmd, arg); 179 int ret;
180
181 lock_kernel();
182 ret = cdrom_ioctl(&di->viocd_info, bdev, mode, cmd, arg);
183 unlock_kernel();
184
185 return ret;
172} 186}
173 187
174static int viocd_blk_media_changed(struct gendisk *disk) 188static int viocd_blk_media_changed(struct gendisk *disk)
@@ -181,7 +195,7 @@ static const struct block_device_operations viocd_fops = {
181 .owner = THIS_MODULE, 195 .owner = THIS_MODULE,
182 .open = viocd_blk_open, 196 .open = viocd_blk_open,
183 .release = viocd_blk_release, 197 .release = viocd_blk_release,
184 .locked_ioctl = viocd_blk_ioctl, 198 .ioctl = viocd_blk_ioctl,
185 .media_changed = viocd_blk_media_changed, 199 .media_changed = viocd_blk_media_changed,
186}; 200};
187 201
@@ -202,9 +216,8 @@ static int viocd_open(struct cdrom_device_info *cdi, int purpose)
202 (u64)&we, VIOVERSION << 16, ((u64)device_no << 48), 216 (u64)&we, VIOVERSION << 16, ((u64)device_no << 48),
203 0, 0, 0); 217 0, 0, 0);
204 if (hvrc != 0) { 218 if (hvrc != 0) {
205 printk(VIOCD_KERN_WARNING 219 pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n",
206 "bad rc on HvCallEvent_signalLpEventFast %d\n", 220 (int)hvrc);
207 (int)hvrc);
208 return -EIO; 221 return -EIO;
209 } 222 }
210 223
@@ -213,8 +226,8 @@ static int viocd_open(struct cdrom_device_info *cdi, int purpose)
213 if (we.rc) { 226 if (we.rc) {
214 const struct vio_error_entry *err = 227 const struct vio_error_entry *err =
215 vio_lookup_rc(viocd_err_table, we.sub_result); 228 vio_lookup_rc(viocd_err_table, we.sub_result);
216 printk(VIOCD_KERN_WARNING "bad rc %d:0x%04X on open: %s\n", 229 pr_warning("bad rc %d:0x%04X on open: %s\n",
217 we.rc, we.sub_result, err->msg); 230 we.rc, we.sub_result, err->msg);
218 return -err->errno; 231 return -err->errno;
219 } 232 }
220 233
@@ -234,9 +247,8 @@ static void viocd_release(struct cdrom_device_info *cdi)
234 viopath_targetinst(viopath_hostLp), 0, 247 viopath_targetinst(viopath_hostLp), 0,
235 VIOVERSION << 16, ((u64)device_no << 48), 0, 0, 0); 248 VIOVERSION << 16, ((u64)device_no << 48), 0, 0, 0);
236 if (hvrc != 0) 249 if (hvrc != 0)
237 printk(VIOCD_KERN_WARNING 250 pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n",
238 "bad rc on HvCallEvent_signalLpEventFast %d\n", 251 (int)hvrc);
239 (int)hvrc);
240} 252}
241 253
242/* Send a read or write request to OS/400 */ 254/* Send a read or write request to OS/400 */
@@ -262,13 +274,12 @@ static int send_request(struct request *req)
262 274
263 sg_init_table(&sg, 1); 275 sg_init_table(&sg, 1);
264 if (blk_rq_map_sg(req->q, req, &sg) == 0) { 276 if (blk_rq_map_sg(req->q, req, &sg) == 0) {
265 printk(VIOCD_KERN_WARNING 277 pr_warning("error setting up scatter/gather list\n");
266 "error setting up scatter/gather list\n");
267 return -1; 278 return -1;
268 } 279 }
269 280
270 if (dma_map_sg(diskinfo->dev, &sg, 1, direction) == 0) { 281 if (dma_map_sg(diskinfo->dev, &sg, 1, direction) == 0) {
271 printk(VIOCD_KERN_WARNING "error allocating sg tce\n"); 282 pr_warning("error allocating sg tce\n");
272 return -1; 283 return -1;
273 } 284 }
274 dmaaddr = sg_dma_address(&sg); 285 dmaaddr = sg_dma_address(&sg);
@@ -284,7 +295,7 @@ static int send_request(struct request *req)
284 ((u64)DEVICE_NR(diskinfo) << 48) | dmaaddr, 295 ((u64)DEVICE_NR(diskinfo) << 48) | dmaaddr,
285 (u64)blk_rq_pos(req) * 512, len, 0); 296 (u64)blk_rq_pos(req) * 512, len, 0);
286 if (hvrc != HvLpEvent_Rc_Good) { 297 if (hvrc != HvLpEvent_Rc_Good) {
287 printk(VIOCD_KERN_WARNING "hv error on op %d\n", (int)hvrc); 298 pr_warning("hv error on op %d\n", (int)hvrc);
288 return -1; 299 return -1;
289 } 300 }
290 301
@@ -298,11 +309,10 @@ static void do_viocd_request(struct request_queue *q)
298 struct request *req; 309 struct request *req;
299 310
300 while ((rwreq == 0) && ((req = blk_fetch_request(q)) != NULL)) { 311 while ((rwreq == 0) && ((req = blk_fetch_request(q)) != NULL)) {
301 if (!blk_fs_request(req)) 312 if (req->cmd_type != REQ_TYPE_FS)
302 __blk_end_request_all(req, -EIO); 313 __blk_end_request_all(req, -EIO);
303 else if (send_request(req) < 0) { 314 else if (send_request(req) < 0) {
304 printk(VIOCD_KERN_WARNING 315 pr_warning("unable to send message to OS/400!\n");
305 "unable to send message to OS/400!");
306 __blk_end_request_all(req, -EIO); 316 __blk_end_request_all(req, -EIO);
307 } else 317 } else
308 rwreq++; 318 rwreq++;
@@ -327,8 +337,8 @@ static int viocd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
327 (u64)&we, VIOVERSION << 16, ((u64)device_no << 48), 337 (u64)&we, VIOVERSION << 16, ((u64)device_no << 48),
328 0, 0, 0); 338 0, 0, 0);
329 if (hvrc != 0) { 339 if (hvrc != 0) {
330 printk(VIOCD_KERN_WARNING "bad rc on HvCallEvent_signalLpEventFast %d\n", 340 pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n",
331 (int)hvrc); 341 (int)hvrc);
332 return -EIO; 342 return -EIO;
333 } 343 }
334 344
@@ -338,9 +348,8 @@ static int viocd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
338 if (we.rc) { 348 if (we.rc) {
339 const struct vio_error_entry *err = 349 const struct vio_error_entry *err =
340 vio_lookup_rc(viocd_err_table, we.sub_result); 350 vio_lookup_rc(viocd_err_table, we.sub_result);
341 printk(VIOCD_KERN_WARNING 351 pr_warning("bad rc %d:0x%04X on check_change: %s; Assuming no change\n",
342 "bad rc %d:0x%04X on check_change: %s; Assuming no change\n", 352 we.rc, we.sub_result, err->msg);
343 we.rc, we.sub_result, err->msg);
344 return 0; 353 return 0;
345 } 354 }
346 355
@@ -367,8 +376,8 @@ static int viocd_lock_door(struct cdrom_device_info *cdi, int locking)
367 (u64)&we, VIOVERSION << 16, 376 (u64)&we, VIOVERSION << 16,
368 (device_no << 48) | (flags << 32), 0, 0, 0); 377 (device_no << 48) | (flags << 32), 0, 0, 0);
369 if (hvrc != 0) { 378 if (hvrc != 0) {
370 printk(VIOCD_KERN_WARNING "bad rc on HvCallEvent_signalLpEventFast %d\n", 379 pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n",
371 (int)hvrc); 380 (int)hvrc);
372 return -EIO; 381 return -EIO;
373 } 382 }
374 383
@@ -455,8 +464,7 @@ static void vio_handle_cd_event(struct HvLpEvent *event)
455 return; 464 return;
456 /* First, we should NEVER get an int here...only acks */ 465 /* First, we should NEVER get an int here...only acks */
457 if (hvlpevent_is_int(event)) { 466 if (hvlpevent_is_int(event)) {
458 printk(VIOCD_KERN_WARNING 467 pr_warning("Yikes! got an int in viocd event handler!\n");
459 "Yikes! got an int in viocd event handler!\n");
460 if (hvlpevent_need_ack(event)) { 468 if (hvlpevent_need_ack(event)) {
461 event->xRc = HvLpEvent_Rc_InvalidSubtype; 469 event->xRc = HvLpEvent_Rc_InvalidSubtype;
462 HvCallEvent_ackLpEvent(event); 470 HvCallEvent_ackLpEvent(event);
@@ -510,10 +518,9 @@ return_complete:
510 const struct vio_error_entry *err = 518 const struct vio_error_entry *err =
511 vio_lookup_rc(viocd_err_table, 519 vio_lookup_rc(viocd_err_table,
512 bevent->sub_result); 520 bevent->sub_result);
513 printk(VIOCD_KERN_WARNING "request %p failed " 521 pr_warning("request %p failed with rc %d:0x%04X: %s\n",
514 "with rc %d:0x%04X: %s\n", 522 req, event->xRc,
515 req, event->xRc, 523 bevent->sub_result, err->msg);
516 bevent->sub_result, err->msg);
517 __blk_end_request_all(req, -EIO); 524 __blk_end_request_all(req, -EIO);
518 } else 525 } else
519 __blk_end_request_all(req, 0); 526 __blk_end_request_all(req, 0);
@@ -524,9 +531,8 @@ return_complete:
524 break; 531 break;
525 532
526 default: 533 default:
527 printk(VIOCD_KERN_WARNING 534 pr_warning("message with invalid subtype %0x04X!\n",
528 "message with invalid subtype %0x04X!\n", 535 event->xSubtype & VIOMINOR_SUBTYPE_MASK);
529 event->xSubtype & VIOMINOR_SUBTYPE_MASK);
530 if (hvlpevent_need_ack(event)) { 536 if (hvlpevent_need_ack(event)) {
531 event->xRc = HvLpEvent_Rc_InvalidSubtype; 537 event->xRc = HvLpEvent_Rc_InvalidSubtype;
532 HvCallEvent_ackLpEvent(event); 538 HvCallEvent_ackLpEvent(event);
@@ -593,23 +599,19 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id)
593 sprintf(c->name, VIOCD_DEVICE "%c", 'a' + deviceno); 599 sprintf(c->name, VIOCD_DEVICE "%c", 'a' + deviceno);
594 600
595 if (register_cdrom(c) != 0) { 601 if (register_cdrom(c) != 0) {
596 printk(VIOCD_KERN_WARNING "Cannot register viocd CD-ROM %s!\n", 602 pr_warning("Cannot register viocd CD-ROM %s!\n", c->name);
597 c->name);
598 goto out; 603 goto out;
599 } 604 }
600 printk(VIOCD_KERN_INFO "cd %s is iSeries resource %10.10s " 605 pr_info("cd %s is iSeries resource %10.10s type %4.4s, model %3.3s\n",
601 "type %4.4s, model %3.3s\n", 606 c->name, d->rsrcname, d->type, d->model);
602 c->name, d->rsrcname, d->type, d->model);
603 q = blk_init_queue(do_viocd_request, &viocd_reqlock); 607 q = blk_init_queue(do_viocd_request, &viocd_reqlock);
604 if (q == NULL) { 608 if (q == NULL) {
605 printk(VIOCD_KERN_WARNING "Cannot allocate queue for %s!\n", 609 pr_warning("Cannot allocate queue for %s!\n", c->name);
606 c->name);
607 goto out_unregister_cdrom; 610 goto out_unregister_cdrom;
608 } 611 }
609 gendisk = alloc_disk(1); 612 gendisk = alloc_disk(1);
610 if (gendisk == NULL) { 613 if (gendisk == NULL) {
611 printk(VIOCD_KERN_WARNING "Cannot create gendisk for %s!\n", 614 pr_warning("Cannot create gendisk for %s!\n", c->name);
612 c->name);
613 goto out_cleanup_queue; 615 goto out_cleanup_queue;
614 } 616 }
615 gendisk->major = VIOCD_MAJOR; 617 gendisk->major = VIOCD_MAJOR;
@@ -682,21 +684,19 @@ static int __init viocd_init(void)
682 return -ENODEV; 684 return -ENODEV;
683 } 685 }
684 686
685 printk(VIOCD_KERN_INFO "vers " VIOCD_VERS ", hosting partition %d\n", 687 pr_info("vers " VIOCD_VERS ", hosting partition %d\n", viopath_hostLp);
686 viopath_hostLp);
687 688
688 if (register_blkdev(VIOCD_MAJOR, VIOCD_DEVICE) != 0) { 689 if (register_blkdev(VIOCD_MAJOR, VIOCD_DEVICE) != 0) {
689 printk(VIOCD_KERN_WARNING "Unable to get major %d for %s\n", 690 pr_warning("Unable to get major %d for %s\n",
690 VIOCD_MAJOR, VIOCD_DEVICE); 691 VIOCD_MAJOR, VIOCD_DEVICE);
691 return -EIO; 692 return -EIO;
692 } 693 }
693 694
694 ret = viopath_open(viopath_hostLp, viomajorsubtype_cdio, 695 ret = viopath_open(viopath_hostLp, viomajorsubtype_cdio,
695 MAX_CD_REQ + 2); 696 MAX_CD_REQ + 2);
696 if (ret) { 697 if (ret) {
697 printk(VIOCD_KERN_WARNING 698 pr_warning("error opening path to host partition %d\n",
698 "error opening path to host partition %d\n", 699 viopath_hostLp);
699 viopath_hostLp);
700 goto out_unregister; 700 goto out_unregister;
701 } 701 }
702 702