dasd_cmb.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * linux/drivers/s390/block/dasd_cmb.c ($Revision: 1.9 $)
  3. *
  4. * Linux on zSeries Channel Measurement Facility support
  5. * (dasd device driver interface)
  6. *
  7. * Copyright 2000,2003 IBM Corporation
  8. *
  9. * Author: Arnd Bergmann <arndb@de.ibm.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2, or (at your option)
  14. * any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #include <linux/init.h>
  26. #include <linux/module.h>
  27. #include <asm/ccwdev.h>
  28. #include <asm/cmb.h>
  29. #include "dasd_int.h"
  30. static int
  31. dasd_ioctl_cmf_enable(struct block_device *bdev, int no, long args)
  32. {
  33. struct dasd_device *device;
  34. device = bdev->bd_disk->private_data;
  35. if (!device)
  36. return -EINVAL;
  37. return enable_cmf(device->cdev);
  38. }
  39. static int
  40. dasd_ioctl_cmf_disable(struct block_device *bdev, int no, long args)
  41. {
  42. struct dasd_device *device;
  43. device = bdev->bd_disk->private_data;
  44. if (!device)
  45. return -EINVAL;
  46. return disable_cmf(device->cdev);
  47. }
  48. static int
  49. dasd_ioctl_readall_cmb(struct block_device *bdev, int no, long args)
  50. {
  51. struct dasd_device *device;
  52. struct cmbdata __user *udata;
  53. struct cmbdata data;
  54. size_t size;
  55. int ret;
  56. device = bdev->bd_disk->private_data;
  57. if (!device)
  58. return -EINVAL;
  59. udata = (void __user *) args;
  60. size = _IOC_SIZE(no);
  61. if (!access_ok(VERIFY_WRITE, udata, size))
  62. return -EFAULT;
  63. ret = cmf_readall(device->cdev, &data);
  64. if (ret)
  65. return ret;
  66. if (copy_to_user(udata, &data, min(size, sizeof(*udata))))
  67. return -EFAULT;
  68. return 0;
  69. }
  70. /* module initialization below here. dasd already provides a mechanism
  71. * to dynamically register ioctl functions, so we simply use this. */
  72. static inline int
  73. ioctl_reg(unsigned int no, dasd_ioctl_fn_t handler)
  74. {
  75. return dasd_ioctl_no_register(THIS_MODULE, no, handler);
  76. }
  77. static inline void
  78. ioctl_unreg(unsigned int no, dasd_ioctl_fn_t handler)
  79. {
  80. dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
  81. }
  82. static void
  83. dasd_cmf_exit(void)
  84. {
  85. ioctl_unreg(BIODASDCMFENABLE, dasd_ioctl_cmf_enable);
  86. ioctl_unreg(BIODASDCMFDISABLE, dasd_ioctl_cmf_disable);
  87. ioctl_unreg(BIODASDREADALLCMB, dasd_ioctl_readall_cmb);
  88. }
  89. static int __init
  90. dasd_cmf_init(void)
  91. {
  92. int ret;
  93. ret = ioctl_reg (BIODASDCMFENABLE, dasd_ioctl_cmf_enable);
  94. if (ret)
  95. goto err;
  96. ret = ioctl_reg (BIODASDCMFDISABLE, dasd_ioctl_cmf_disable);
  97. if (ret)
  98. goto err;
  99. ret = ioctl_reg (BIODASDREADALLCMB, dasd_ioctl_readall_cmb);
  100. if (ret)
  101. goto err;
  102. return 0;
  103. err:
  104. dasd_cmf_exit();
  105. return ret;
  106. }
  107. module_init(dasd_cmf_init);
  108. module_exit(dasd_cmf_exit);
  109. MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
  110. MODULE_LICENSE("GPL");
  111. MODULE_DESCRIPTION("channel measurement facility interface for dasd\n"
  112. "Copyright 2003 IBM Corporation\n");