[CONNECTOR]: async connector mode.
[linux-2.6/verdex.git] / drivers / s390 / net / cu3088.c
blob0075894c71db0e09086efd97b55111f0a374bbe0
1 /*
2 * $Id: cu3088.c,v 1.35 2005/03/30 19:28:52 richtera Exp $
4 * CTC / LCS ccw_device driver
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Arnd Bergmann <arndb@de.ibm.com>
8 * Cornelia Huck <cohuck@de.ibm.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <linux/init.h>
27 #include <linux/module.h>
28 #include <linux/err.h>
30 #include <asm/ccwdev.h>
31 #include <asm/ccwgroup.h>
33 #include "cu3088.h"
35 const char *cu3088_type[] = {
36 "not a channel",
37 "CTC/A",
38 "ESCON channel",
39 "FICON channel",
40 "P390 LCS card",
41 "OSA LCS card",
42 "CLAW channel device",
43 "unknown channel type",
44 "unsupported channel type",
47 /* static definitions */
49 static struct ccw_device_id cu3088_ids[] = {
50 { CCW_DEVICE(0x3088, 0x08), .driver_info = channel_type_parallel },
51 { CCW_DEVICE(0x3088, 0x1f), .driver_info = channel_type_escon },
52 { CCW_DEVICE(0x3088, 0x1e), .driver_info = channel_type_ficon },
53 { CCW_DEVICE(0x3088, 0x01), .driver_info = channel_type_p390 },
54 { CCW_DEVICE(0x3088, 0x60), .driver_info = channel_type_osa2 },
55 { CCW_DEVICE(0x3088, 0x61), .driver_info = channel_type_claw },
56 { /* end of list */ }
59 static struct ccw_driver cu3088_driver;
61 struct device *cu3088_root_dev;
63 static ssize_t
64 group_write(struct device_driver *drv, const char *buf, size_t count)
66 const char *start, *end;
67 char bus_ids[2][BUS_ID_SIZE], *argv[2];
68 int i;
69 int ret;
70 struct ccwgroup_driver *cdrv;
72 cdrv = to_ccwgroupdrv(drv);
73 if (!cdrv)
74 return -EINVAL;
75 start = buf;
76 for (i=0; i<2; i++) {
77 static const char delim[] = {',', '\n'};
78 int len;
80 if (!(end = strchr(start, delim[i])))
81 return count;
82 len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start + 1);
83 strlcpy (bus_ids[i], start, len);
84 argv[i] = bus_ids[i];
85 start = end + 1;
88 ret = ccwgroup_create(cu3088_root_dev, cdrv->driver_id,
89 &cu3088_driver, 2, argv);
91 return (ret == 0) ? count : ret;
94 static DRIVER_ATTR(group, 0200, NULL, group_write);
96 /* Register-unregister for ctc&lcs */
97 int
98 register_cu3088_discipline(struct ccwgroup_driver *dcp)
100 int rc;
102 if (!dcp)
103 return -EINVAL;
105 /* Register discipline.*/
106 rc = ccwgroup_driver_register(dcp);
107 if (rc)
108 return rc;
110 rc = driver_create_file(&dcp->driver, &driver_attr_group);
111 if (rc)
112 ccwgroup_driver_unregister(dcp);
114 return rc;
118 void
119 unregister_cu3088_discipline(struct ccwgroup_driver *dcp)
121 if (!dcp)
122 return;
124 driver_remove_file(&dcp->driver, &driver_attr_group);
125 ccwgroup_driver_unregister(dcp);
128 static struct ccw_driver cu3088_driver = {
129 .owner = THIS_MODULE,
130 .ids = cu3088_ids,
131 .name = "cu3088",
132 .probe = ccwgroup_probe_ccwdev,
133 .remove = ccwgroup_remove_ccwdev,
136 /* module setup */
137 static int __init
138 cu3088_init (void)
140 int rc;
142 cu3088_root_dev = s390_root_dev_register("cu3088");
143 if (IS_ERR(cu3088_root_dev))
144 return PTR_ERR(cu3088_root_dev);
145 rc = ccw_driver_register(&cu3088_driver);
146 if (rc)
147 s390_root_dev_unregister(cu3088_root_dev);
149 return rc;
152 static void __exit
153 cu3088_exit (void)
155 ccw_driver_unregister(&cu3088_driver);
156 s390_root_dev_unregister(cu3088_root_dev);
159 MODULE_DEVICE_TABLE(ccw,cu3088_ids);
160 MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
161 MODULE_LICENSE("GPL");
163 module_init(cu3088_init);
164 module_exit(cu3088_exit);
166 EXPORT_SYMBOL_GPL(cu3088_type);
167 EXPORT_SYMBOL_GPL(register_cu3088_discipline);
168 EXPORT_SYMBOL_GPL(unregister_cu3088_discipline);