aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/block/dasd_cmb.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/s390/block/dasd_cmb.c
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 @@
1/*
2 * linux/drivers/s390/block/dasd_cmb.c ($Revision: 1.6 $)
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/ioctl32.h>
27#include <linux/module.h>
28#include <asm/ccwdev.h>
29#include <asm/cmb.h>
30
31#include "dasd_int.h"
32
33static int
34dasd_ioctl_cmf_enable(struct block_device *bdev, int no, long args)
35{
36 struct dasd_device *device;
37
38 device = bdev->bd_disk->private_data;
39 if (!device)
40 return -EINVAL;
41
42 return enable_cmf(device->cdev);
43}
44
45static int
46dasd_ioctl_cmf_disable(struct block_device *bdev, int no, long args)
47{
48 struct dasd_device *device;
49
50 device = bdev->bd_disk->private_data;
51 if (!device)
52 return -EINVAL;
53
54 return disable_cmf(device->cdev);
55}
56
57static int
58dasd_ioctl_readall_cmb(struct block_device *bdev, int no, long args)
59{
60 struct dasd_device *device;
61 struct cmbdata __user *udata;
62 struct cmbdata data;
63 size_t size;
64 int ret;
65
66 device = bdev->bd_disk->private_data;
67 if (!device)
68 return -EINVAL;
69 udata = (void __user *) args;
70 size = _IOC_SIZE(no);
71
72 if (!access_ok(VERIFY_WRITE, udata, size))
73 return -EFAULT;
74 ret = cmf_readall(device->cdev, &data);
75 if (ret)
76 return ret;
77 if (copy_to_user(udata, &data, min(size, sizeof(*udata))))
78 return -EFAULT;
79 return 0;
80}
81
82/* module initialization below here. dasd already provides a mechanism
83 * to dynamically register ioctl functions, so we simply use this. */
84static inline int
85ioctl_reg(unsigned int no, dasd_ioctl_fn_t handler)
86{
87 int ret;
88 ret = dasd_ioctl_no_register(THIS_MODULE, no, handler);
89#ifdef CONFIG_COMPAT
90 if (ret)
91 return ret;
92
93 ret = register_ioctl32_conversion(no, NULL);
94 if (ret)
95 dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
96#endif
97 return ret;
98}
99
100static inline void
101ioctl_unreg(unsigned int no, dasd_ioctl_fn_t handler)
102{
103 dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
104#ifdef CONFIG_COMPAT
105 unregister_ioctl32_conversion(no);
106#endif
107
108}
109
110static void
111dasd_cmf_exit(void)
112{
113 ioctl_unreg(BIODASDCMFENABLE, dasd_ioctl_cmf_enable);
114 ioctl_unreg(BIODASDCMFDISABLE, dasd_ioctl_cmf_disable);
115 ioctl_unreg(BIODASDREADALLCMB, dasd_ioctl_readall_cmb);
116}
117
118static int __init
119dasd_cmf_init(void)
120{
121 int ret;
122 ret = ioctl_reg (BIODASDCMFENABLE, dasd_ioctl_cmf_enable);
123 if (ret)
124 goto err;
125 ret = ioctl_reg (BIODASDCMFDISABLE, dasd_ioctl_cmf_disable);
126 if (ret)
127 goto err;
128 ret = ioctl_reg (BIODASDREADALLCMB, dasd_ioctl_readall_cmb);
129 if (ret)
130 goto err;
131
132 return 0;
133err:
134 dasd_cmf_exit();
135
136 return ret;
137}
138
139module_init(dasd_cmf_init);
140module_exit(dasd_cmf_exit);
141
142MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
143MODULE_LICENSE("GPL");
144MODULE_DESCRIPTION("channel measurement facility interface for dasd\n"
145 "Copyright 2003 IBM Corporation\n");