summaryrefslogtreecommitdiffstats
path: root/drivers/s390/block/dasd_cmb.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-17 00:20:36 +0200
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-17 00:20:36 +0200
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/s390/block/dasd_cmb.c
downloadlinux-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.tar.xz
linux-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.zip
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/s390/block/dasd_cmb.c')
-rw-r--r--drivers/s390/block/dasd_cmb.c145
1 files changed, 145 insertions, 0 deletions
diff --git a/drivers/s390/block/dasd_cmb.c b/drivers/s390/block/dasd_cmb.c
new file mode 100644
index 000000000000..ed1ab474c0c6
--- /dev/null
+++ b/drivers/s390/block/dasd_cmb.c
@@ -0,0 +1,145 @@
+/*
+ * linux/drivers/s390/block/dasd_cmb.c ($Revision: 1.6 $)
+ *
+ * Linux on zSeries Channel Measurement Facility support
+ * (dasd device driver interface)
+ *
+ * Copyright 2000,2003 IBM Corporation
+ *
+ * Author: Arnd Bergmann <arndb@de.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <linux/init.h>
+#include <linux/ioctl32.h>
+#include <linux/module.h>
+#include <asm/ccwdev.h>
+#include <asm/cmb.h>
+
+#include "dasd_int.h"
+
+static int
+dasd_ioctl_cmf_enable(struct block_device *bdev, int no, long args)
+{
+ struct dasd_device *device;
+
+ device = bdev->bd_disk->private_data;
+ if (!device)
+ return -EINVAL;
+
+ return enable_cmf(device->cdev);
+}
+
+static int
+dasd_ioctl_cmf_disable(struct block_device *bdev, int no, long args)
+{
+ struct dasd_device *device;
+
+ device = bdev->bd_disk->private_data;
+ if (!device)
+ return -EINVAL;
+
+ return disable_cmf(device->cdev);
+}
+
+static int
+dasd_ioctl_readall_cmb(struct block_device *bdev, int no, long args)
+{
+ struct dasd_device *device;
+ struct cmbdata __user *udata;
+ struct cmbdata data;
+ size_t size;
+ int ret;
+
+ device = bdev->bd_disk->private_data;
+ if (!device)
+ return -EINVAL;
+ udata = (void __user *) args;
+ size = _IOC_SIZE(no);
+
+ if (!access_ok(VERIFY_WRITE, udata, size))
+ return -EFAULT;
+ ret = cmf_readall(device->cdev, &data);
+ if (ret)
+ return ret;
+ if (copy_to_user(udata, &data, min(size, sizeof(*udata))))
+ return -EFAULT;
+ return 0;
+}
+
+/* module initialization below here. dasd already provides a mechanism
+ * to dynamically register ioctl functions, so we simply use this. */
+static inline int
+ioctl_reg(unsigned int no, dasd_ioctl_fn_t handler)
+{
+ int ret;
+ ret = dasd_ioctl_no_register(THIS_MODULE, no, handler);
+#ifdef CONFIG_COMPAT
+ if (ret)
+ return ret;
+
+ ret = register_ioctl32_conversion(no, NULL);
+ if (ret)
+ dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
+#endif
+ return ret;
+}
+
+static inline void
+ioctl_unreg(unsigned int no, dasd_ioctl_fn_t handler)
+{
+ dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
+#ifdef CONFIG_COMPAT
+ unregister_ioctl32_conversion(no);
+#endif
+
+}
+
+static void
+dasd_cmf_exit(void)
+{
+ ioctl_unreg(BIODASDCMFENABLE, dasd_ioctl_cmf_enable);
+ ioctl_unreg(BIODASDCMFDISABLE, dasd_ioctl_cmf_disable);
+ ioctl_unreg(BIODASDREADALLCMB, dasd_ioctl_readall_cmb);
+}
+
+static int __init
+dasd_cmf_init(void)
+{
+ int ret;
+ ret = ioctl_reg (BIODASDCMFENABLE, dasd_ioctl_cmf_enable);
+ if (ret)
+ goto err;
+ ret = ioctl_reg (BIODASDCMFDISABLE, dasd_ioctl_cmf_disable);
+ if (ret)
+ goto err;
+ ret = ioctl_reg (BIODASDREADALLCMB, dasd_ioctl_readall_cmb);
+ if (ret)
+ goto err;
+
+ return 0;
+err:
+ dasd_cmf_exit();
+
+ return ret;
+}
+
+module_init(dasd_cmf_init);
+module_exit(dasd_cmf_exit);
+
+MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("channel measurement facility interface for dasd\n"
+ "Copyright 2003 IBM Corporation\n");