diff options
author | Joe Perches <joe@perches.com> | 2014-05-04 20:05:12 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-05-05 16:58:06 -0400 |
commit | 40569c6144242087c9663c5d0c93138882dd52e8 (patch) | |
tree | a8f10d3d206e549add93ac77b2c315e76c73f228 | |
parent | a803393bf8b2b0dd69d9aa87471e7afee91fbdc0 (diff) |
cdrom: Remove unnecessary prototype for cdrom_mrw_exit
Move the function to appropriate locations instead.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | drivers/cdrom/cdrom.c | 238 |
1 files changed, 121 insertions, 117 deletions
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index f614847aad8f..c8ca3426c5b0 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -338,8 +338,6 @@ do { \ | |||
338 | 338 | ||
339 | /* Not-exported routines. */ | 339 | /* Not-exported routines. */ |
340 | 340 | ||
341 | static int cdrom_mrw_exit(struct cdrom_device_info *cdi); | ||
342 | |||
343 | static int cdrom_get_disc_info(struct cdrom_device_info *cdi, disc_information *di); | 341 | static int cdrom_get_disc_info(struct cdrom_device_info *cdi, disc_information *di); |
344 | 342 | ||
345 | static void cdrom_sysctl_register(void); | 343 | static void cdrom_sysctl_register(void); |
@@ -359,113 +357,29 @@ static int cdrom_dummy_generic_packet(struct cdrom_device_info *cdi, | |||
359 | return -EIO; | 357 | return -EIO; |
360 | } | 358 | } |
361 | 359 | ||
362 | /* This macro makes sure we don't have to check on cdrom_device_ops | 360 | static int cdrom_flush_cache(struct cdrom_device_info *cdi) |
363 | * existence in the run-time routines below. Change_capability is a | ||
364 | * hack to have the capability flags defined const, while we can still | ||
365 | * change it here without gcc complaining at every line. | ||
366 | */ | ||
367 | #define ENSURE(call, bits) if (cdo->call == NULL) *change_capability &= ~(bits) | ||
368 | |||
369 | int register_cdrom(struct cdrom_device_info *cdi) | ||
370 | { | ||
371 | static char banner_printed; | ||
372 | struct cdrom_device_ops *cdo = cdi->ops; | ||
373 | int *change_capability = (int *)&cdo->capability; /* hack */ | ||
374 | |||
375 | cd_dbg(CD_OPEN, "entering register_cdrom\n"); | ||
376 | |||
377 | if (cdo->open == NULL || cdo->release == NULL) | ||
378 | return -EINVAL; | ||
379 | if (!banner_printed) { | ||
380 | pr_info("Uniform CD-ROM driver " REVISION "\n"); | ||
381 | banner_printed = 1; | ||
382 | cdrom_sysctl_register(); | ||
383 | } | ||
384 | |||
385 | ENSURE(drive_status, CDC_DRIVE_STATUS ); | ||
386 | if (cdo->check_events == NULL && cdo->media_changed == NULL) | ||
387 | *change_capability = ~(CDC_MEDIA_CHANGED | CDC_SELECT_DISC); | ||
388 | ENSURE(tray_move, CDC_CLOSE_TRAY | CDC_OPEN_TRAY); | ||
389 | ENSURE(lock_door, CDC_LOCK); | ||
390 | ENSURE(select_speed, CDC_SELECT_SPEED); | ||
391 | ENSURE(get_last_session, CDC_MULTI_SESSION); | ||
392 | ENSURE(get_mcn, CDC_MCN); | ||
393 | ENSURE(reset, CDC_RESET); | ||
394 | ENSURE(generic_packet, CDC_GENERIC_PACKET); | ||
395 | cdi->mc_flags = 0; | ||
396 | cdo->n_minors = 0; | ||
397 | cdi->options = CDO_USE_FFLAGS; | ||
398 | |||
399 | if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY)) | ||
400 | cdi->options |= (int) CDO_AUTO_CLOSE; | ||
401 | if (autoeject==1 && CDROM_CAN(CDC_OPEN_TRAY)) | ||
402 | cdi->options |= (int) CDO_AUTO_EJECT; | ||
403 | if (lockdoor==1) | ||
404 | cdi->options |= (int) CDO_LOCK; | ||
405 | if (check_media_type==1) | ||
406 | cdi->options |= (int) CDO_CHECK_TYPE; | ||
407 | |||
408 | if (CDROM_CAN(CDC_MRW_W)) | ||
409 | cdi->exit = cdrom_mrw_exit; | ||
410 | |||
411 | if (cdi->disk) | ||
412 | cdi->cdda_method = CDDA_BPC_FULL; | ||
413 | else | ||
414 | cdi->cdda_method = CDDA_OLD; | ||
415 | |||
416 | if (!cdo->generic_packet) | ||
417 | cdo->generic_packet = cdrom_dummy_generic_packet; | ||
418 | |||
419 | cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name); | ||
420 | mutex_lock(&cdrom_mutex); | ||
421 | list_add(&cdi->list, &cdrom_list); | ||
422 | mutex_unlock(&cdrom_mutex); | ||
423 | return 0; | ||
424 | } | ||
425 | #undef ENSURE | ||
426 | |||
427 | void unregister_cdrom(struct cdrom_device_info *cdi) | ||
428 | { | ||
429 | cd_dbg(CD_OPEN, "entering unregister_cdrom\n"); | ||
430 | |||
431 | mutex_lock(&cdrom_mutex); | ||
432 | list_del(&cdi->list); | ||
433 | mutex_unlock(&cdrom_mutex); | ||
434 | |||
435 | if (cdi->exit) | ||
436 | cdi->exit(cdi); | ||
437 | |||
438 | cdi->ops->n_minors--; | ||
439 | cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name); | ||
440 | } | ||
441 | |||
442 | int cdrom_get_media_event(struct cdrom_device_info *cdi, | ||
443 | struct media_event_desc *med) | ||
444 | { | 361 | { |
445 | struct packet_command cgc; | 362 | struct packet_command cgc; |
446 | unsigned char buffer[8]; | ||
447 | struct event_header *eh = (struct event_header *) buffer; | ||
448 | |||
449 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ); | ||
450 | cgc.cmd[0] = GPCMD_GET_EVENT_STATUS_NOTIFICATION; | ||
451 | cgc.cmd[1] = 1; /* IMMED */ | ||
452 | cgc.cmd[4] = 1 << 4; /* media event */ | ||
453 | cgc.cmd[8] = sizeof(buffer); | ||
454 | cgc.quiet = 1; | ||
455 | |||
456 | if (cdi->ops->generic_packet(cdi, &cgc)) | ||
457 | return 1; | ||
458 | 363 | ||
459 | if (be16_to_cpu(eh->data_len) < sizeof(*med)) | 364 | init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE); |
460 | return 1; | 365 | cgc.cmd[0] = GPCMD_FLUSH_CACHE; |
461 | 366 | ||
462 | if (eh->nea || eh->notification_class != 0x4) | 367 | cgc.timeout = 5 * 60 * HZ; |
463 | return 1; | ||
464 | 368 | ||
465 | memcpy(med, &buffer[sizeof(*eh)], sizeof(*med)); | 369 | return cdi->ops->generic_packet(cdi, &cgc); |
466 | return 0; | ||
467 | } | 370 | } |
468 | 371 | ||
372 | /* This macro makes sure we don't have to check on cdrom_device_ops | ||
373 | * existence in the run-time routines below. Change_capability is a | ||
374 | * hack to have the capability flags defined const, while we can still | ||
375 | * change it here without gcc complaining at every line. | ||
376 | */ | ||
377 | #define ENSURE(call, bits) \ | ||
378 | do { \ | ||
379 | if (cdo->call == NULL) \ | ||
380 | *change_capability &= ~(bits); \ | ||
381 | } while (0) | ||
382 | |||
469 | /* | 383 | /* |
470 | * the first prototypes used 0x2c as the page code for the mrw mode page, | 384 | * the first prototypes used 0x2c as the page code for the mrw mode page, |
471 | * subsequently this was changed to 0x03. probe the one used by this drive | 385 | * subsequently this was changed to 0x03. probe the one used by this drive |
@@ -582,18 +496,6 @@ static int cdrom_mrw_bgformat_susp(struct cdrom_device_info *cdi, int immed) | |||
582 | return cdi->ops->generic_packet(cdi, &cgc); | 496 | return cdi->ops->generic_packet(cdi, &cgc); |
583 | } | 497 | } |
584 | 498 | ||
585 | static int cdrom_flush_cache(struct cdrom_device_info *cdi) | ||
586 | { | ||
587 | struct packet_command cgc; | ||
588 | |||
589 | init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE); | ||
590 | cgc.cmd[0] = GPCMD_FLUSH_CACHE; | ||
591 | |||
592 | cgc.timeout = 5 * 60 * HZ; | ||
593 | |||
594 | return cdi->ops->generic_packet(cdi, &cgc); | ||
595 | } | ||
596 | |||
597 | static int cdrom_mrw_exit(struct cdrom_device_info *cdi) | 499 | static int cdrom_mrw_exit(struct cdrom_device_info *cdi) |
598 | { | 500 | { |
599 | disc_information di; | 501 | disc_information di; |
@@ -627,17 +529,19 @@ static int cdrom_mrw_set_lba_space(struct cdrom_device_info *cdi, int space) | |||
627 | cgc.buffer = buffer; | 529 | cgc.buffer = buffer; |
628 | cgc.buflen = sizeof(buffer); | 530 | cgc.buflen = sizeof(buffer); |
629 | 531 | ||
630 | if ((ret = cdrom_mode_sense(cdi, &cgc, cdi->mrw_mode_page, 0))) | 532 | ret = cdrom_mode_sense(cdi, &cgc, cdi->mrw_mode_page, 0); |
533 | if (ret) | ||
631 | return ret; | 534 | return ret; |
632 | 535 | ||
633 | mph = (struct mode_page_header *) buffer; | 536 | mph = (struct mode_page_header *)buffer; |
634 | offset = be16_to_cpu(mph->desc_length); | 537 | offset = be16_to_cpu(mph->desc_length); |
635 | size = be16_to_cpu(mph->mode_data_length) + 2; | 538 | size = be16_to_cpu(mph->mode_data_length) + 2; |
636 | 539 | ||
637 | buffer[offset + 3] = space; | 540 | buffer[offset + 3] = space; |
638 | cgc.buflen = size; | 541 | cgc.buflen = size; |
639 | 542 | ||
640 | if ((ret = cdrom_mode_select(cdi, &cgc))) | 543 | ret = cdrom_mode_select(cdi, &cgc); |
544 | if (ret) | ||
641 | return ret; | 545 | return ret; |
642 | 546 | ||
643 | pr_info("%s: mrw address space %s selected\n", | 547 | pr_info("%s: mrw address space %s selected\n", |
@@ -645,6 +549,106 @@ static int cdrom_mrw_set_lba_space(struct cdrom_device_info *cdi, int space) | |||
645 | return 0; | 549 | return 0; |
646 | } | 550 | } |
647 | 551 | ||
552 | int register_cdrom(struct cdrom_device_info *cdi) | ||
553 | { | ||
554 | static char banner_printed; | ||
555 | struct cdrom_device_ops *cdo = cdi->ops; | ||
556 | int *change_capability = (int *)&cdo->capability; /* hack */ | ||
557 | |||
558 | cd_dbg(CD_OPEN, "entering register_cdrom\n"); | ||
559 | |||
560 | if (cdo->open == NULL || cdo->release == NULL) | ||
561 | return -EINVAL; | ||
562 | if (!banner_printed) { | ||
563 | pr_info("Uniform CD-ROM driver " REVISION "\n"); | ||
564 | banner_printed = 1; | ||
565 | cdrom_sysctl_register(); | ||
566 | } | ||
567 | |||
568 | ENSURE(drive_status, CDC_DRIVE_STATUS); | ||
569 | if (cdo->check_events == NULL && cdo->media_changed == NULL) | ||
570 | *change_capability = ~(CDC_MEDIA_CHANGED | CDC_SELECT_DISC); | ||
571 | ENSURE(tray_move, CDC_CLOSE_TRAY | CDC_OPEN_TRAY); | ||
572 | ENSURE(lock_door, CDC_LOCK); | ||
573 | ENSURE(select_speed, CDC_SELECT_SPEED); | ||
574 | ENSURE(get_last_session, CDC_MULTI_SESSION); | ||
575 | ENSURE(get_mcn, CDC_MCN); | ||
576 | ENSURE(reset, CDC_RESET); | ||
577 | ENSURE(generic_packet, CDC_GENERIC_PACKET); | ||
578 | cdi->mc_flags = 0; | ||
579 | cdo->n_minors = 0; | ||
580 | cdi->options = CDO_USE_FFLAGS; | ||
581 | |||
582 | if (autoclose == 1 && CDROM_CAN(CDC_CLOSE_TRAY)) | ||
583 | cdi->options |= (int) CDO_AUTO_CLOSE; | ||
584 | if (autoeject == 1 && CDROM_CAN(CDC_OPEN_TRAY)) | ||
585 | cdi->options |= (int) CDO_AUTO_EJECT; | ||
586 | if (lockdoor == 1) | ||
587 | cdi->options |= (int) CDO_LOCK; | ||
588 | if (check_media_type == 1) | ||
589 | cdi->options |= (int) CDO_CHECK_TYPE; | ||
590 | |||
591 | if (CDROM_CAN(CDC_MRW_W)) | ||
592 | cdi->exit = cdrom_mrw_exit; | ||
593 | |||
594 | if (cdi->disk) | ||
595 | cdi->cdda_method = CDDA_BPC_FULL; | ||
596 | else | ||
597 | cdi->cdda_method = CDDA_OLD; | ||
598 | |||
599 | if (!cdo->generic_packet) | ||
600 | cdo->generic_packet = cdrom_dummy_generic_packet; | ||
601 | |||
602 | cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name); | ||
603 | mutex_lock(&cdrom_mutex); | ||
604 | list_add(&cdi->list, &cdrom_list); | ||
605 | mutex_unlock(&cdrom_mutex); | ||
606 | return 0; | ||
607 | } | ||
608 | #undef ENSURE | ||
609 | |||
610 | void unregister_cdrom(struct cdrom_device_info *cdi) | ||
611 | { | ||
612 | cd_dbg(CD_OPEN, "entering unregister_cdrom\n"); | ||
613 | |||
614 | mutex_lock(&cdrom_mutex); | ||
615 | list_del(&cdi->list); | ||
616 | mutex_unlock(&cdrom_mutex); | ||
617 | |||
618 | if (cdi->exit) | ||
619 | cdi->exit(cdi); | ||
620 | |||
621 | cdi->ops->n_minors--; | ||
622 | cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name); | ||
623 | } | ||
624 | |||
625 | int cdrom_get_media_event(struct cdrom_device_info *cdi, | ||
626 | struct media_event_desc *med) | ||
627 | { | ||
628 | struct packet_command cgc; | ||
629 | unsigned char buffer[8]; | ||
630 | struct event_header *eh = (struct event_header *)buffer; | ||
631 | |||
632 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ); | ||
633 | cgc.cmd[0] = GPCMD_GET_EVENT_STATUS_NOTIFICATION; | ||
634 | cgc.cmd[1] = 1; /* IMMED */ | ||
635 | cgc.cmd[4] = 1 << 4; /* media event */ | ||
636 | cgc.cmd[8] = sizeof(buffer); | ||
637 | cgc.quiet = 1; | ||
638 | |||
639 | if (cdi->ops->generic_packet(cdi, &cgc)) | ||
640 | return 1; | ||
641 | |||
642 | if (be16_to_cpu(eh->data_len) < sizeof(*med)) | ||
643 | return 1; | ||
644 | |||
645 | if (eh->nea || eh->notification_class != 0x4) | ||
646 | return 1; | ||
647 | |||
648 | memcpy(med, &buffer[sizeof(*eh)], sizeof(*med)); | ||
649 | return 0; | ||
650 | } | ||
651 | |||
648 | static int cdrom_get_random_writable(struct cdrom_device_info *cdi, | 652 | static int cdrom_get_random_writable(struct cdrom_device_info *cdi, |
649 | struct rwrt_feature_desc *rfd) | 653 | struct rwrt_feature_desc *rfd) |
650 | { | 654 | { |