]> err.no Git - linux-2.6/blob - drivers/s390/net/cu3088.c
Merge branch 'for-2.6.26' of master.kernel.org:/pub/scm/linux/kernel/git/jwboyer...
[linux-2.6] / drivers / s390 / net / cu3088.c
1 /*
2  * CTC / LCS ccw_device driver
3  *
4  * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
5  * Author(s): Arnd Bergmann <arndb@de.ibm.com>
6  *            Cornelia Huck <cornelia.huck@de.ibm.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */
23
24 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/err.h>
27
28 #include <asm/s390_rdev.h>
29 #include <asm/ccwdev.h>
30 #include <asm/ccwgroup.h>
31
32 #include "cu3088.h"
33
34 const char *cu3088_type[] = {
35         "not a channel",
36         "CTC/A",
37         "ESCON channel",
38         "FICON channel",
39         "P390 LCS card",
40         "OSA LCS card",
41         "CLAW channel device",
42         "unknown channel type",
43         "unsupported channel type",
44 };
45
46 /* static definitions */
47
48 static struct ccw_device_id cu3088_ids[] = {
49         { CCW_DEVICE(0x3088, 0x08), .driver_info = channel_type_parallel },
50         { CCW_DEVICE(0x3088, 0x1f), .driver_info = channel_type_escon },
51         { CCW_DEVICE(0x3088, 0x1e), .driver_info = channel_type_ficon },
52         { CCW_DEVICE(0x3088, 0x01), .driver_info = channel_type_p390 },
53         { CCW_DEVICE(0x3088, 0x60), .driver_info = channel_type_osa2 },
54         { CCW_DEVICE(0x3088, 0x61), .driver_info = channel_type_claw },
55         { /* end of list */ }
56 };
57
58 static struct ccw_driver cu3088_driver;
59
60 static struct device *cu3088_root_dev;
61
62 static ssize_t
63 group_write(struct device_driver *drv, const char *buf, size_t count)
64 {
65         int ret;
66         struct ccwgroup_driver *cdrv;
67
68         cdrv = to_ccwgroupdrv(drv);
69         if (!cdrv)
70                 return -EINVAL;
71         ret = ccwgroup_create_from_string(cu3088_root_dev, cdrv->driver_id,
72                                           &cu3088_driver, 2, buf);
73
74         return (ret == 0) ? count : ret;
75 }
76
77 static DRIVER_ATTR(group, 0200, NULL, group_write);
78
79 /* Register-unregister for ctc&lcs */
80 int
81 register_cu3088_discipline(struct ccwgroup_driver *dcp)
82 {
83         int rc;
84
85         if (!dcp)
86                 return -EINVAL;
87
88         /* Register discipline.*/
89         rc = ccwgroup_driver_register(dcp);
90         if (rc)
91                 return rc;
92
93         rc = driver_create_file(&dcp->driver, &driver_attr_group);
94         if (rc)
95                 ccwgroup_driver_unregister(dcp);
96
97         return rc;
98
99 }
100
101 void
102 unregister_cu3088_discipline(struct ccwgroup_driver *dcp)
103 {
104         if (!dcp)
105                 return;
106
107         driver_remove_file(&dcp->driver, &driver_attr_group);
108         ccwgroup_driver_unregister(dcp);
109 }
110
111 static struct ccw_driver cu3088_driver = {
112         .owner       = THIS_MODULE,
113         .ids         = cu3088_ids,
114         .name        = "cu3088",
115         .probe       = ccwgroup_probe_ccwdev,
116         .remove      = ccwgroup_remove_ccwdev,
117 };
118
119 /* module setup */
120 static int __init
121 cu3088_init (void)
122 {
123         int rc;
124
125         cu3088_root_dev = s390_root_dev_register("cu3088");
126         if (IS_ERR(cu3088_root_dev))
127                 return PTR_ERR(cu3088_root_dev);
128         rc = ccw_driver_register(&cu3088_driver);
129         if (rc)
130                 s390_root_dev_unregister(cu3088_root_dev);
131
132         return rc;
133 }
134
135 static void __exit
136 cu3088_exit (void)
137 {
138         ccw_driver_unregister(&cu3088_driver);
139         s390_root_dev_unregister(cu3088_root_dev);
140 }
141
142 MODULE_DEVICE_TABLE(ccw,cu3088_ids);
143 MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
144 MODULE_LICENSE("GPL");
145
146 module_init(cu3088_init);
147 module_exit(cu3088_exit);
148
149 EXPORT_SYMBOL_GPL(cu3088_type);
150 EXPORT_SYMBOL_GPL(register_cu3088_discipline);
151 EXPORT_SYMBOL_GPL(unregister_cu3088_discipline);