Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/cio: move ccw_device_stlck functions

device_ops.c should only contain functions that are called by ccw device
drivers. Move the cio internal functions that handle unconditional
reserve + release to device_pgid.c

Acked-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Sebastian Ott and committed by
Martin Schwidefsky
ef12cb90 8421d212

+60 -70
-3
drivers/s390/cio/device.h
··· 125 125 void ccw_device_disband_start(struct ccw_device *); 126 126 void ccw_device_disband_done(struct ccw_device *, int); 127 127 128 - void ccw_device_stlck_start(struct ccw_device *, void *, void *, void *); 129 - void ccw_device_stlck_done(struct ccw_device *, void *, int); 130 - 131 128 int ccw_device_stlck(struct ccw_device *); 132 129 133 130 /* Helper function for machine check handling. */
-61
drivers/s390/cio/device_ops.c
··· 456 456 return sch->lpm; 457 457 } 458 458 459 - struct stlck_data { 460 - struct completion done; 461 - int rc; 462 - }; 463 - 464 - void ccw_device_stlck_done(struct ccw_device *cdev, void *data, int rc) 465 - { 466 - struct stlck_data *sdata = data; 467 - 468 - sdata->rc = rc; 469 - complete(&sdata->done); 470 - } 471 - 472 - /* 473 - * Perform unconditional reserve + release. 474 - */ 475 - int ccw_device_stlck(struct ccw_device *cdev) 476 - { 477 - struct subchannel *sch = to_subchannel(cdev->dev.parent); 478 - struct stlck_data data; 479 - u8 *buffer; 480 - int rc; 481 - 482 - /* Check if steal lock operation is valid for this device. */ 483 - if (cdev->drv) { 484 - if (!cdev->private->options.force) 485 - return -EINVAL; 486 - } 487 - buffer = kzalloc(64, GFP_DMA | GFP_KERNEL); 488 - if (!buffer) 489 - return -ENOMEM; 490 - init_completion(&data.done); 491 - data.rc = -EIO; 492 - spin_lock_irq(sch->lock); 493 - rc = cio_enable_subchannel(sch, (u32) (addr_t) sch); 494 - if (rc) 495 - goto out_unlock; 496 - /* Perform operation. */ 497 - cdev->private->state = DEV_STATE_STEAL_LOCK; 498 - ccw_device_stlck_start(cdev, &data, &buffer[0], &buffer[32]); 499 - spin_unlock_irq(sch->lock); 500 - /* Wait for operation to finish. */ 501 - if (wait_for_completion_interruptible(&data.done)) { 502 - /* Got a signal. */ 503 - spin_lock_irq(sch->lock); 504 - ccw_request_cancel(cdev); 505 - spin_unlock_irq(sch->lock); 506 - wait_for_completion(&data.done); 507 - } 508 - rc = data.rc; 509 - /* Check results. */ 510 - spin_lock_irq(sch->lock); 511 - cio_disable_subchannel(sch); 512 - cdev->private->state = DEV_STATE_BOXED; 513 - out_unlock: 514 - spin_unlock_irq(sch->lock); 515 - kfree(buffer); 516 - 517 - return rc; 518 - } 519 - 520 459 /** 521 460 * chp_get_chp_desc - return newly allocated channel-path descriptor 522 461 * @cdev: device to obtain the descriptor for
+60 -6
drivers/s390/cio/device_pgid.c
··· 9 9 10 10 #include <linux/kernel.h> 11 11 #include <linux/string.h> 12 + #include <linux/bitops.h> 12 13 #include <linux/types.h> 13 14 #include <linux/errno.h> 14 - #include <linux/bitops.h> 15 + #include <linux/slab.h> 15 16 #include <asm/ccwdev.h> 16 17 #include <asm/cio.h> 17 18 ··· 617 616 ccw_request_start(cdev); 618 617 } 619 618 619 + struct stlck_data { 620 + struct completion done; 621 + int rc; 622 + }; 623 + 620 624 static void stlck_build_cp(struct ccw_device *cdev, void *buf1, void *buf2) 621 625 { 622 626 struct ccw_request *req = &cdev->private->req; ··· 640 634 641 635 static void stlck_callback(struct ccw_device *cdev, void *data, int rc) 642 636 { 643 - ccw_device_stlck_done(cdev, data, rc); 637 + struct stlck_data *sdata = data; 638 + 639 + sdata->rc = rc; 640 + complete(&sdata->done); 644 641 } 645 642 646 643 /** ··· 654 645 * @buf2: data pointer used in channel program 655 646 * 656 647 * Execute a channel program on @cdev to release an existing PGID reservation. 657 - * When finished, call ccw_device_stlck_done with a return code specifying the 658 - * result. 659 648 */ 660 - void ccw_device_stlck_start(struct ccw_device *cdev, void *data, void *buf1, 661 - void *buf2) 649 + static void ccw_device_stlck_start(struct ccw_device *cdev, void *data, 650 + void *buf1, void *buf2) 662 651 { 663 652 struct subchannel *sch = to_subchannel(cdev->dev.parent); 664 653 struct ccw_request *req = &cdev->private->req; ··· 674 667 ccw_request_start(cdev); 675 668 } 676 669 670 + /* 671 + * Perform unconditional reserve + release. 672 + */ 673 + int ccw_device_stlck(struct ccw_device *cdev) 674 + { 675 + struct subchannel *sch = to_subchannel(cdev->dev.parent); 676 + struct stlck_data data; 677 + u8 *buffer; 678 + int rc; 679 + 680 + /* Check if steal lock operation is valid for this device. */ 681 + if (cdev->drv) { 682 + if (!cdev->private->options.force) 683 + return -EINVAL; 684 + } 685 + buffer = kzalloc(64, GFP_DMA | GFP_KERNEL); 686 + if (!buffer) 687 + return -ENOMEM; 688 + init_completion(&data.done); 689 + data.rc = -EIO; 690 + spin_lock_irq(sch->lock); 691 + rc = cio_enable_subchannel(sch, (u32) (addr_t) sch); 692 + if (rc) 693 + goto out_unlock; 694 + /* Perform operation. */ 695 + cdev->private->state = DEV_STATE_STEAL_LOCK; 696 + ccw_device_stlck_start(cdev, &data, &buffer[0], &buffer[32]); 697 + spin_unlock_irq(sch->lock); 698 + /* Wait for operation to finish. */ 699 + if (wait_for_completion_interruptible(&data.done)) { 700 + /* Got a signal. */ 701 + spin_lock_irq(sch->lock); 702 + ccw_request_cancel(cdev); 703 + spin_unlock_irq(sch->lock); 704 + wait_for_completion(&data.done); 705 + } 706 + rc = data.rc; 707 + /* Check results. */ 708 + spin_lock_irq(sch->lock); 709 + cio_disable_subchannel(sch); 710 + cdev->private->state = DEV_STATE_BOXED; 711 + out_unlock: 712 + spin_unlock_irq(sch->lock); 713 + kfree(buffer); 714 + 715 + return rc; 716 + }