blob: 48383459e99be7cee09bbb1fbaeb90bbce8b7f8e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * 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>
Cornelia Huck4ce3b302006-01-14 13:21:04 -08006 * Cornelia Huck <cornelia.huck@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
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 */
Jeff Garzike82b0f22006-05-26 21:58:38 -040023
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/init.h>
25#include <linux/module.h>
26#include <linux/err.h>
27
28#include <asm/ccwdev.h>
29#include <asm/ccwgroup.h>
30
31#include "cu3088.h"
32
33const char *cu3088_type[] = {
34 "not a channel",
35 "CTC/A",
36 "ESCON channel",
37 "FICON channel",
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 "OSA LCS card",
Frank Pavlic321de3c2005-05-12 20:17:46 +020039 "CLAW channel device",
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 "unknown channel type",
41 "unsupported channel type",
42};
43
44/* static definitions */
45
46static struct ccw_device_id cu3088_ids[] = {
47 { CCW_DEVICE(0x3088, 0x08), .driver_info = channel_type_parallel },
48 { CCW_DEVICE(0x3088, 0x1f), .driver_info = channel_type_escon },
49 { CCW_DEVICE(0x3088, 0x1e), .driver_info = channel_type_ficon },
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 { CCW_DEVICE(0x3088, 0x60), .driver_info = channel_type_osa2 },
Frank Pavlic321de3c2005-05-12 20:17:46 +020051 { CCW_DEVICE(0x3088, 0x61), .driver_info = channel_type_claw },
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 { /* end of list */ }
53};
54
55static struct ccw_driver cu3088_driver;
56
Heiko Carstens2b67fc42007-02-05 21:16:47 +010057static struct device *cu3088_root_dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59static ssize_t
60group_write(struct device_driver *drv, const char *buf, size_t count)
61{
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 int ret;
63 struct ccwgroup_driver *cdrv;
64
65 cdrv = to_ccwgroupdrv(drv);
66 if (!cdrv)
67 return -EINVAL;
Ursula Braun022b6602008-04-24 10:15:20 +020068 ret = ccwgroup_create_from_string(cu3088_root_dev, cdrv->driver_id,
69 &cu3088_driver, 2, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71 return (ret == 0) ? count : ret;
72}
73
74static DRIVER_ATTR(group, 0200, NULL, group_write);
75
76/* Register-unregister for ctc&lcs */
77int
Jeff Garzike82b0f22006-05-26 21:58:38 -040078register_cu3088_discipline(struct ccwgroup_driver *dcp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079{
80 int rc;
81
82 if (!dcp)
83 return -EINVAL;
84
85 /* Register discipline.*/
86 rc = ccwgroup_driver_register(dcp);
87 if (rc)
88 return rc;
89
90 rc = driver_create_file(&dcp->driver, &driver_attr_group);
91 if (rc)
92 ccwgroup_driver_unregister(dcp);
Jeff Garzike82b0f22006-05-26 21:58:38 -040093
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 return rc;
95
96}
97
98void
99unregister_cu3088_discipline(struct ccwgroup_driver *dcp)
100{
101 if (!dcp)
102 return;
103
104 driver_remove_file(&dcp->driver, &driver_attr_group);
105 ccwgroup_driver_unregister(dcp);
106}
107
108static struct ccw_driver cu3088_driver = {
109 .owner = THIS_MODULE,
110 .ids = cu3088_ids,
111 .name = "cu3088",
112 .probe = ccwgroup_probe_ccwdev,
113 .remove = ccwgroup_remove_ccwdev,
114};
115
116/* module setup */
117static int __init
118cu3088_init (void)
119{
120 int rc;
Jeff Garzike82b0f22006-05-26 21:58:38 -0400121
Mark McLoughlin035da162008-12-15 12:58:29 +0000122 cu3088_root_dev = root_device_register("cu3088");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 if (IS_ERR(cu3088_root_dev))
124 return PTR_ERR(cu3088_root_dev);
125 rc = ccw_driver_register(&cu3088_driver);
126 if (rc)
Mark McLoughlin035da162008-12-15 12:58:29 +0000127 root_device_unregister(cu3088_root_dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129 return rc;
130}
131
132static void __exit
133cu3088_exit (void)
134{
135 ccw_driver_unregister(&cu3088_driver);
Mark McLoughlin035da162008-12-15 12:58:29 +0000136 root_device_unregister(cu3088_root_dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137}
138
139MODULE_DEVICE_TABLE(ccw,cu3088_ids);
140MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
141MODULE_LICENSE("GPL");
142
143module_init(cu3088_init);
144module_exit(cu3088_exit);
145
146EXPORT_SYMBOL_GPL(cu3088_type);
147EXPORT_SYMBOL_GPL(register_cu3088_discipline);
148EXPORT_SYMBOL_GPL(unregister_cu3088_discipline);