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