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.c83
1 files changed, 34 insertions, 49 deletions
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index 14e420168764..1fa6628d150b 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>
@@ -53,9 +55,6 @@
53 55
54#define VIOCD_VERS "1.06" 56#define VIOCD_VERS "1.06"
55 57
56#define VIOCD_KERN_WARNING KERN_WARNING "viocd: "
57#define VIOCD_KERN_INFO KERN_INFO "viocd: "
58
59/* 58/*
60 * Should probably make this a module parameter....sigh 59 * Should probably make this a module parameter....sigh
61 */ 60 */
@@ -202,9 +201,8 @@ static int viocd_open(struct cdrom_device_info *cdi, int purpose)
202 (u64)&we, VIOVERSION << 16, ((u64)device_no << 48), 201 (u64)&we, VIOVERSION << 16, ((u64)device_no << 48),
203 0, 0, 0); 202 0, 0, 0);
204 if (hvrc != 0) { 203 if (hvrc != 0) {
205 printk(VIOCD_KERN_WARNING 204 pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n",
206 "bad rc on HvCallEvent_signalLpEventFast %d\n", 205 (int)hvrc);
207 (int)hvrc);
208 return -EIO; 206 return -EIO;
209 } 207 }
210 208
@@ -213,8 +211,8 @@ static int viocd_open(struct cdrom_device_info *cdi, int purpose)
213 if (we.rc) { 211 if (we.rc) {
214 const struct vio_error_entry *err = 212 const struct vio_error_entry *err =
215 vio_lookup_rc(viocd_err_table, we.sub_result); 213 vio_lookup_rc(viocd_err_table, we.sub_result);
216 printk(VIOCD_KERN_WARNING "bad rc %d:0x%04X on open: %s\n", 214 pr_warning("bad rc %d:0x%04X on open: %s\n",
217 we.rc, we.sub_result, err->msg); 215 we.rc, we.sub_result, err->msg);
218 return -err->errno; 216 return -err->errno;
219 } 217 }
220 218
@@ -234,9 +232,8 @@ static void viocd_release(struct cdrom_device_info *cdi)
234 viopath_targetinst(viopath_hostLp), 0, 232 viopath_targetinst(viopath_hostLp), 0,
235 VIOVERSION << 16, ((u64)device_no << 48), 0, 0, 0); 233 VIOVERSION << 16, ((u64)device_no << 48), 0, 0, 0);
236 if (hvrc != 0) 234 if (hvrc != 0)
237 printk(VIOCD_KERN_WARNING 235 pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n",
238 "bad rc on HvCallEvent_signalLpEventFast %d\n", 236 (int)hvrc);
239 (int)hvrc);
240} 237}
241 238
242/* Send a read or write request to OS/400 */ 239/* Send a read or write request to OS/400 */
@@ -262,13 +259,12 @@ static int send_request(struct request *req)
262 259
263 sg_init_table(&sg, 1); 260 sg_init_table(&sg, 1);
264 if (blk_rq_map_sg(req->q, req, &sg) == 0) { 261 if (blk_rq_map_sg(req->q, req, &sg) == 0) {
265 printk(VIOCD_KERN_WARNING 262 pr_warning("error setting up scatter/gather list\n");
266 "error setting up scatter/gather list\n");
267 return -1; 263 return -1;
268 } 264 }
269 265
270 if (dma_map_sg(diskinfo->dev, &sg, 1, direction) == 0) { 266 if (dma_map_sg(diskinfo->dev, &sg, 1, direction) == 0) {
271 printk(VIOCD_KERN_WARNING "error allocating sg tce\n"); 267 pr_warning("error allocating sg tce\n");
272 return -1; 268 return -1;
273 } 269 }
274 dmaaddr = sg_dma_address(&sg); 270 dmaaddr = sg_dma_address(&sg);
@@ -284,7 +280,7 @@ static int send_request(struct request *req)
284 ((u64)DEVICE_NR(diskinfo) << 48) | dmaaddr, 280 ((u64)DEVICE_NR(diskinfo) << 48) | dmaaddr,
285 (u64)blk_rq_pos(req) * 512, len, 0); 281 (u64)blk_rq_pos(req) * 512, len, 0);
286 if (hvrc != HvLpEvent_Rc_Good) { 282 if (hvrc != HvLpEvent_Rc_Good) {
287 printk(VIOCD_KERN_WARNING "hv error on op %d\n", (int)hvrc); 283 pr_warning("hv error on op %d\n", (int)hvrc);
288 return -1; 284 return -1;
289 } 285 }
290 286
@@ -301,8 +297,7 @@ static void do_viocd_request(struct request_queue *q)
301 if (req->cmd_type != REQ_TYPE_FS) 297 if (req->cmd_type != REQ_TYPE_FS)
302 __blk_end_request_all(req, -EIO); 298 __blk_end_request_all(req, -EIO);
303 else if (send_request(req) < 0) { 299 else if (send_request(req) < 0) {
304 printk(VIOCD_KERN_WARNING 300 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); 301 __blk_end_request_all(req, -EIO);
307 } else 302 } else
308 rwreq++; 303 rwreq++;
@@ -327,8 +322,8 @@ static int viocd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
327 (u64)&we, VIOVERSION << 16, ((u64)device_no << 48), 322 (u64)&we, VIOVERSION << 16, ((u64)device_no << 48),
328 0, 0, 0); 323 0, 0, 0);
329 if (hvrc != 0) { 324 if (hvrc != 0) {
330 printk(VIOCD_KERN_WARNING "bad rc on HvCallEvent_signalLpEventFast %d\n", 325 pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n",
331 (int)hvrc); 326 (int)hvrc);
332 return -EIO; 327 return -EIO;
333 } 328 }
334 329
@@ -338,9 +333,8 @@ static int viocd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
338 if (we.rc) { 333 if (we.rc) {
339 const struct vio_error_entry *err = 334 const struct vio_error_entry *err =
340 vio_lookup_rc(viocd_err_table, we.sub_result); 335 vio_lookup_rc(viocd_err_table, we.sub_result);
341 printk(VIOCD_KERN_WARNING 336 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", 337 we.rc, we.sub_result, err->msg);
343 we.rc, we.sub_result, err->msg);
344 return 0; 338 return 0;
345 } 339 }
346 340
@@ -367,8 +361,8 @@ static int viocd_lock_door(struct cdrom_device_info *cdi, int locking)
367 (u64)&we, VIOVERSION << 16, 361 (u64)&we, VIOVERSION << 16,
368 (device_no << 48) | (flags << 32), 0, 0, 0); 362 (device_no << 48) | (flags << 32), 0, 0, 0);
369 if (hvrc != 0) { 363 if (hvrc != 0) {
370 printk(VIOCD_KERN_WARNING "bad rc on HvCallEvent_signalLpEventFast %d\n", 364 pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n",
371 (int)hvrc); 365 (int)hvrc);
372 return -EIO; 366 return -EIO;
373 } 367 }
374 368
@@ -455,8 +449,7 @@ static void vio_handle_cd_event(struct HvLpEvent *event)
455 return; 449 return;
456 /* First, we should NEVER get an int here...only acks */ 450 /* First, we should NEVER get an int here...only acks */
457 if (hvlpevent_is_int(event)) { 451 if (hvlpevent_is_int(event)) {
458 printk(VIOCD_KERN_WARNING 452 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)) { 453 if (hvlpevent_need_ack(event)) {
461 event->xRc = HvLpEvent_Rc_InvalidSubtype; 454 event->xRc = HvLpEvent_Rc_InvalidSubtype;
462 HvCallEvent_ackLpEvent(event); 455 HvCallEvent_ackLpEvent(event);
@@ -510,10 +503,9 @@ return_complete:
510 const struct vio_error_entry *err = 503 const struct vio_error_entry *err =
511 vio_lookup_rc(viocd_err_table, 504 vio_lookup_rc(viocd_err_table,
512 bevent->sub_result); 505 bevent->sub_result);
513 printk(VIOCD_KERN_WARNING "request %p failed " 506 pr_warning("request %p failed with rc %d:0x%04X: %s\n",
514 "with rc %d:0x%04X: %s\n", 507 req, event->xRc,
515 req, event->xRc, 508 bevent->sub_result, err->msg);
516 bevent->sub_result, err->msg);
517 __blk_end_request_all(req, -EIO); 509 __blk_end_request_all(req, -EIO);
518 } else 510 } else
519 __blk_end_request_all(req, 0); 511 __blk_end_request_all(req, 0);
@@ -524,9 +516,8 @@ return_complete:
524 break; 516 break;
525 517
526 default: 518 default:
527 printk(VIOCD_KERN_WARNING 519 pr_warning("message with invalid subtype %0x04X!\n",
528 "message with invalid subtype %0x04X!\n", 520 event->xSubtype & VIOMINOR_SUBTYPE_MASK);
529 event->xSubtype & VIOMINOR_SUBTYPE_MASK);
530 if (hvlpevent_need_ack(event)) { 521 if (hvlpevent_need_ack(event)) {
531 event->xRc = HvLpEvent_Rc_InvalidSubtype; 522 event->xRc = HvLpEvent_Rc_InvalidSubtype;
532 HvCallEvent_ackLpEvent(event); 523 HvCallEvent_ackLpEvent(event);
@@ -593,23 +584,19 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id)
593 sprintf(c->name, VIOCD_DEVICE "%c", 'a' + deviceno); 584 sprintf(c->name, VIOCD_DEVICE "%c", 'a' + deviceno);
594 585
595 if (register_cdrom(c) != 0) { 586 if (register_cdrom(c) != 0) {
596 printk(VIOCD_KERN_WARNING "Cannot register viocd CD-ROM %s!\n", 587 pr_warning("Cannot register viocd CD-ROM %s!\n", c->name);
597 c->name);
598 goto out; 588 goto out;
599 } 589 }
600 printk(VIOCD_KERN_INFO "cd %s is iSeries resource %10.10s " 590 pr_info("cd %s is iSeries resource %10.10s type %4.4s, model %3.3s\n",
601 "type %4.4s, model %3.3s\n", 591 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); 592 q = blk_init_queue(do_viocd_request, &viocd_reqlock);
604 if (q == NULL) { 593 if (q == NULL) {
605 printk(VIOCD_KERN_WARNING "Cannot allocate queue for %s!\n", 594 pr_warning("Cannot allocate queue for %s!\n", c->name);
606 c->name);
607 goto out_unregister_cdrom; 595 goto out_unregister_cdrom;
608 } 596 }
609 gendisk = alloc_disk(1); 597 gendisk = alloc_disk(1);
610 if (gendisk == NULL) { 598 if (gendisk == NULL) {
611 printk(VIOCD_KERN_WARNING "Cannot create gendisk for %s!\n", 599 pr_warning("Cannot create gendisk for %s!\n", c->name);
612 c->name);
613 goto out_cleanup_queue; 600 goto out_cleanup_queue;
614 } 601 }
615 gendisk->major = VIOCD_MAJOR; 602 gendisk->major = VIOCD_MAJOR;
@@ -682,21 +669,19 @@ static int __init viocd_init(void)
682 return -ENODEV; 669 return -ENODEV;
683 } 670 }
684 671
685 printk(VIOCD_KERN_INFO "vers " VIOCD_VERS ", hosting partition %d\n", 672 pr_info("vers " VIOCD_VERS ", hosting partition %d\n", viopath_hostLp);
686 viopath_hostLp);
687 673
688 if (register_blkdev(VIOCD_MAJOR, VIOCD_DEVICE) != 0) { 674 if (register_blkdev(VIOCD_MAJOR, VIOCD_DEVICE) != 0) {
689 printk(VIOCD_KERN_WARNING "Unable to get major %d for %s\n", 675 pr_warning("Unable to get major %d for %s\n",
690 VIOCD_MAJOR, VIOCD_DEVICE); 676 VIOCD_MAJOR, VIOCD_DEVICE);
691 return -EIO; 677 return -EIO;
692 } 678 }
693 679
694 ret = viopath_open(viopath_hostLp, viomajorsubtype_cdio, 680 ret = viopath_open(viopath_hostLp, viomajorsubtype_cdio,
695 MAX_CD_REQ + 2); 681 MAX_CD_REQ + 2);
696 if (ret) { 682 if (ret) {
697 printk(VIOCD_KERN_WARNING 683 pr_warning("error opening path to host partition %d\n",
698 "error opening path to host partition %d\n", 684 viopath_hostLp);
699 viopath_hostLp);
700 goto out_unregister; 685 goto out_unregister;
701 } 686 }
702 687