blob: 30fe59cc28c9d60d7f9eb1203ec4ddc492616a06 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * drivers/s390/cio/device.c
3 * bus driver for ccw devices
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
6 * IBM Corporation
7 * Author(s): Arnd Bergmann (arndb@de.ibm.com)
Cornelia Huck4ce3b302006-01-14 13:21:04 -08008 * Cornelia Huck (cornelia.huck@de.ibm.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * Martin Schwidefsky (schwidefsky@de.ibm.com)
10 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/module.h>
12#include <linux/init.h>
13#include <linux/spinlock.h>
14#include <linux/errno.h>
15#include <linux/err.h>
16#include <linux/slab.h>
17#include <linux/list.h>
18#include <linux/device.h>
19#include <linux/workqueue.h>
20
21#include <asm/ccwdev.h>
22#include <asm/cio.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080023#include <asm/param.h> /* HZ */
Cornelia Huck1842f2b2007-10-12 16:11:22 +020024#include <asm/cmb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#include "cio.h"
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +010027#include "cio_debug.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include "css.h"
29#include "device.h"
30#include "ioasm.h"
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010031#include "io_sch.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33/******************* bus type handling ***********************/
34
35/* The Linux driver model distinguishes between a bus type and
36 * the bus itself. Of course we only have one channel
37 * subsystem driver and one channel system per machine, but
38 * we still use the abstraction. T.R. says it's a good idea. */
39static int
40ccw_bus_match (struct device * dev, struct device_driver * drv)
41{
42 struct ccw_device *cdev = to_ccwdev(dev);
43 struct ccw_driver *cdrv = to_ccwdrv(drv);
44 const struct ccw_device_id *ids = cdrv->ids, *found;
45
46 if (!ids)
47 return 0;
48
49 found = ccw_device_id_match(ids, &cdev->id);
50 if (!found)
51 return 0;
52
53 cdev->id.driver_info = found->driver_info;
54
55 return 1;
56}
57
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +020058/* Store modalias string delimited by prefix/suffix string into buffer with
59 * specified size. Return length of resulting string (excluding trailing '\0')
60 * even if string doesn't fit buffer (snprintf semantics). */
Cornelia Huckcfbe9bb2007-04-27 16:01:32 +020061static int snprint_alias(char *buf, size_t size,
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +020062 struct ccw_device_id *id, const char *suffix)
63{
64 int len;
65
Cornelia Huckcfbe9bb2007-04-27 16:01:32 +020066 len = snprintf(buf, size, "ccw:t%04Xm%02X", id->cu_type, id->cu_model);
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +020067 if (len > size)
68 return len;
69 buf += len;
70 size -= len;
71
72 if (id->dev_type != 0)
73 len += snprintf(buf, size, "dt%04Xdm%02X%s", id->dev_type,
74 id->dev_model, suffix);
75 else
76 len += snprintf(buf, size, "dtdm%s", suffix);
77
78 return len;
79}
80
81/* Set up environment variables for ccw device uevent. Return 0 on success,
82 * non-zero otherwise. */
Kay Sievers7eff2e72007-08-14 15:15:12 +020083static int ccw_uevent(struct device *dev, struct kobj_uevent_env *env)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084{
85 struct ccw_device *cdev = to_ccwdev(dev);
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +020086 struct ccw_device_id *id = &(cdev->id);
Cornelia Huckcfbe9bb2007-04-27 16:01:32 +020087 int ret;
88 char modalias_buf[30];
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +020090 /* CU_TYPE= */
Kay Sievers7eff2e72007-08-14 15:15:12 +020091 ret = add_uevent_var(env, "CU_TYPE=%04X", id->cu_type);
Cornelia Huckcfbe9bb2007-04-27 16:01:32 +020092 if (ret)
93 return ret;
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +020094
95 /* CU_MODEL= */
Kay Sievers7eff2e72007-08-14 15:15:12 +020096 ret = add_uevent_var(env, "CU_MODEL=%02X", id->cu_model);
Cornelia Huckcfbe9bb2007-04-27 16:01:32 +020097 if (ret)
98 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100 /* The next two can be zero, that's ok for us */
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +0200101 /* DEV_TYPE= */
Kay Sievers7eff2e72007-08-14 15:15:12 +0200102 ret = add_uevent_var(env, "DEV_TYPE=%04X", id->dev_type);
Cornelia Huckcfbe9bb2007-04-27 16:01:32 +0200103 if (ret)
104 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +0200106 /* DEV_MODEL= */
Kay Sievers7eff2e72007-08-14 15:15:12 +0200107 ret = add_uevent_var(env, "DEV_MODEL=%02X", id->dev_model);
Cornelia Huckcfbe9bb2007-04-27 16:01:32 +0200108 if (ret)
109 return ret;
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +0200110
111 /* MODALIAS= */
Cornelia Huckcfbe9bb2007-04-27 16:01:32 +0200112 snprint_alias(modalias_buf, sizeof(modalias_buf), id, "");
Kay Sievers7eff2e72007-08-14 15:15:12 +0200113 ret = add_uevent_var(env, "MODALIAS=%s", modalias_buf);
114 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115}
116
Cornelia Huck8bbace72006-01-11 10:56:22 +0100117struct bus_type ccw_bus_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Cornelia Huck602b20f2008-01-26 14:10:39 +0100119static void io_subchannel_irq(struct subchannel *);
120static int io_subchannel_probe(struct subchannel *);
121static int io_subchannel_remove(struct subchannel *);
122static int io_subchannel_notify(struct subchannel *, int);
123static void io_subchannel_verify(struct subchannel *);
124static void io_subchannel_ioterm(struct subchannel *);
Cornelia Huck8bbace72006-01-11 10:56:22 +0100125static void io_subchannel_shutdown(struct subchannel *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Cornelia Huckf7e5d672007-05-10 15:45:43 +0200127static struct css_driver io_subchannel_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 .subchannel_type = SUBCHANNEL_TYPE_IO,
Cornelia Huck25b7bb52008-01-26 14:10:41 +0100129 .name = "io_subchannel",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 .irq = io_subchannel_irq,
131 .notify = io_subchannel_notify,
132 .verify = io_subchannel_verify,
133 .termination = io_subchannel_ioterm,
Cornelia Huck8bbace72006-01-11 10:56:22 +0100134 .probe = io_subchannel_probe,
135 .remove = io_subchannel_remove,
136 .shutdown = io_subchannel_shutdown,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137};
138
139struct workqueue_struct *ccw_device_work;
140struct workqueue_struct *ccw_device_notify_work;
Peter Oberparleiter40154b82006-06-29 14:57:03 +0200141wait_queue_head_t ccw_device_init_wq;
142atomic_t ccw_device_init_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144static int __init
145init_ccw_bus_type (void)
146{
147 int ret;
148
149 init_waitqueue_head(&ccw_device_init_wq);
150 atomic_set(&ccw_device_init_count, 0);
151
152 ccw_device_work = create_singlethread_workqueue("cio");
153 if (!ccw_device_work)
154 return -ENOMEM; /* FIXME: better errno ? */
155 ccw_device_notify_work = create_singlethread_workqueue("cio_notify");
156 if (!ccw_device_notify_work) {
157 ret = -ENOMEM; /* FIXME: better errno ? */
158 goto out_err;
159 }
160 slow_path_wq = create_singlethread_workqueue("kslowcrw");
161 if (!slow_path_wq) {
162 ret = -ENOMEM; /* FIXME: better errno ? */
163 goto out_err;
164 }
165 if ((ret = bus_register (&ccw_bus_type)))
166 goto out_err;
167
Cornelia Huck25b7bb52008-01-26 14:10:41 +0100168 ret = css_driver_register(&io_subchannel_driver);
169 if (ret)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 goto out_err;
171
172 wait_event(ccw_device_init_wq,
173 atomic_read(&ccw_device_init_count) == 0);
174 flush_workqueue(ccw_device_work);
175 return 0;
176out_err:
177 if (ccw_device_work)
178 destroy_workqueue(ccw_device_work);
179 if (ccw_device_notify_work)
180 destroy_workqueue(ccw_device_notify_work);
181 if (slow_path_wq)
182 destroy_workqueue(slow_path_wq);
183 return ret;
184}
185
186static void __exit
187cleanup_ccw_bus_type (void)
188{
Cornelia Huck25b7bb52008-01-26 14:10:41 +0100189 css_driver_unregister(&io_subchannel_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 bus_unregister(&ccw_bus_type);
191 destroy_workqueue(ccw_device_notify_work);
192 destroy_workqueue(ccw_device_work);
193}
194
195subsys_initcall(init_ccw_bus_type);
196module_exit(cleanup_ccw_bus_type);
197
198/************************ device handling **************************/
199
200/*
201 * A ccw_device has some interfaces in sysfs in addition to the
202 * standard ones.
203 * The following entries are designed to export the information which
204 * resided in 2.4 in /proc/subchannels. Subchannel and device number
205 * are obvious, so they don't have an entry :)
206 * TODO: Split chpids and pimpampom up? Where is "in use" in the tree?
207 */
208static ssize_t
Yani Ioannou3fd3c0a2005-05-17 06:43:27 -0400209chpids_show (struct device * dev, struct device_attribute *attr, char * buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210{
211 struct subchannel *sch = to_subchannel(dev);
Peter Oberparleiter7ad6a242007-04-27 16:01:35 +0200212 struct chsc_ssd_info *ssd = &sch->ssd_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 ssize_t ret = 0;
214 int chp;
Peter Oberparleiter7ad6a242007-04-27 16:01:35 +0200215 int mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Peter Oberparleiter7ad6a242007-04-27 16:01:35 +0200217 for (chp = 0; chp < 8; chp++) {
218 mask = 0x80 >> chp;
219 if (ssd->path_mask & mask)
220 ret += sprintf(buf + ret, "%02x ", ssd->chpid[chp].id);
221 else
222 ret += sprintf(buf + ret, "00 ");
223 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 ret += sprintf (buf+ret, "\n");
225 return min((ssize_t)PAGE_SIZE, ret);
226}
227
228static ssize_t
Yani Ioannou3fd3c0a2005-05-17 06:43:27 -0400229pimpampom_show (struct device * dev, struct device_attribute *attr, char * buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230{
231 struct subchannel *sch = to_subchannel(dev);
232 struct pmcw *pmcw = &sch->schib.pmcw;
233
234 return sprintf (buf, "%02x %02x %02x\n",
235 pmcw->pim, pmcw->pam, pmcw->pom);
236}
237
238static ssize_t
Yani Ioannou3fd3c0a2005-05-17 06:43:27 -0400239devtype_show (struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240{
241 struct ccw_device *cdev = to_ccwdev(dev);
242 struct ccw_device_id *id = &(cdev->id);
243
244 if (id->dev_type != 0)
245 return sprintf(buf, "%04x/%02x\n",
246 id->dev_type, id->dev_model);
247 else
248 return sprintf(buf, "n/a\n");
249}
250
251static ssize_t
Yani Ioannou3fd3c0a2005-05-17 06:43:27 -0400252cutype_show (struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253{
254 struct ccw_device *cdev = to_ccwdev(dev);
255 struct ccw_device_id *id = &(cdev->id);
256
257 return sprintf(buf, "%04x/%02x\n",
258 id->cu_type, id->cu_model);
259}
260
261static ssize_t
Bastian Blankf1fc78a2005-10-30 15:00:12 -0800262modalias_show (struct device *dev, struct device_attribute *attr, char *buf)
263{
264 struct ccw_device *cdev = to_ccwdev(dev);
265 struct ccw_device_id *id = &(cdev->id);
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +0200266 int len;
Bastian Blankf1fc78a2005-10-30 15:00:12 -0800267
Cornelia Huck086a6c62007-07-17 13:36:08 +0200268 len = snprint_alias(buf, PAGE_SIZE, id, "\n");
Peter Oberparleiterdb0c2d52006-09-20 15:59:49 +0200269
270 return len > PAGE_SIZE ? PAGE_SIZE : len;
Bastian Blankf1fc78a2005-10-30 15:00:12 -0800271}
272
273static ssize_t
Yani Ioannou3fd3c0a2005-05-17 06:43:27 -0400274online_show (struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275{
276 struct ccw_device *cdev = to_ccwdev(dev);
277
278 return sprintf(buf, cdev->online ? "1\n" : "0\n");
279}
280
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100281int ccw_device_is_orphan(struct ccw_device *cdev)
282{
283 return sch_is_pseudo_sch(to_subchannel(cdev->dev.parent));
284}
285
Cornelia Huckef995162007-04-27 16:01:39 +0200286static void ccw_device_unregister(struct ccw_device *cdev)
Cornelia Huck7674da72006-12-08 15:54:21 +0100287{
Cornelia Huck7674da72006-12-08 15:54:21 +0100288 if (test_and_clear_bit(1, &cdev->private->registered))
Cornelia Huckef995162007-04-27 16:01:39 +0200289 device_del(&cdev->dev);
Cornelia Huck7674da72006-12-08 15:54:21 +0100290}
291
Cornelia Huck59a8a6e2007-05-31 17:38:06 +0200292static void ccw_device_remove_orphan_cb(struct device *dev)
293{
294 struct ccw_device *cdev = to_ccwdev(dev);
295
296 ccw_device_unregister(cdev);
297 put_device(&cdev->dev);
298}
299
300static void ccw_device_remove_sch_cb(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301{
302 struct subchannel *sch;
Cornelia Huck59a8a6e2007-05-31 17:38:06 +0200303
304 sch = to_subchannel(dev);
Cornelia Huck6ab48792006-07-12 16:39:50 +0200305 css_sch_device_unregister(sch);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 /* Reset intparm to zeroes. */
307 sch->schib.pmcw.intparm = 0;
308 cio_modify(sch);
309 put_device(&sch->dev);
310}
311
Cornelia Huck59a8a6e2007-05-31 17:38:06 +0200312static void
313ccw_device_remove_disconnected(struct ccw_device *cdev)
314{
315 unsigned long flags;
316 int rc;
317
318 /*
319 * Forced offline in disconnected state means
320 * 'throw away device'.
321 */
322 if (ccw_device_is_orphan(cdev)) {
323 /*
324 * Deregister ccw device.
325 * Unfortunately, we cannot do this directly from the
326 * attribute method.
327 */
328 spin_lock_irqsave(cdev->ccwlock, flags);
329 cdev->private->state = DEV_STATE_NOT_OPER;
330 spin_unlock_irqrestore(cdev->ccwlock, flags);
331 rc = device_schedule_callback(&cdev->dev,
332 ccw_device_remove_orphan_cb);
333 if (rc)
Cornelia Hucke556bbb2007-07-27 12:29:19 +0200334 CIO_MSG_EVENT(2, "Couldn't unregister orphan "
335 "0.%x.%04x\n",
336 cdev->private->dev_id.ssid,
337 cdev->private->dev_id.devno);
Cornelia Huck59a8a6e2007-05-31 17:38:06 +0200338 return;
339 }
340 /* Deregister subchannel, which will kill the ccw device. */
341 rc = device_schedule_callback(cdev->dev.parent,
342 ccw_device_remove_sch_cb);
343 if (rc)
Cornelia Hucke556bbb2007-07-27 12:29:19 +0200344 CIO_MSG_EVENT(2, "Couldn't unregister disconnected device "
345 "0.%x.%04x\n",
346 cdev->private->dev_id.ssid,
347 cdev->private->dev_id.devno);
Cornelia Huck59a8a6e2007-05-31 17:38:06 +0200348}
349
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200350/**
351 * ccw_device_set_offline() - disable a ccw device for I/O
352 * @cdev: target ccw device
353 *
354 * This function calls the driver's set_offline() function for @cdev, if
355 * given, and then disables @cdev.
356 * Returns:
357 * %0 on success and a negative error value on failure.
358 * Context:
359 * enabled, ccw device lock not held
360 */
361int ccw_device_set_offline(struct ccw_device *cdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362{
363 int ret;
364
365 if (!cdev)
366 return -ENODEV;
367 if (!cdev->online || !cdev->drv)
368 return -EINVAL;
369
370 if (cdev->drv->set_offline) {
371 ret = cdev->drv->set_offline(cdev);
372 if (ret != 0)
373 return ret;
374 }
375 cdev->online = 0;
376 spin_lock_irq(cdev->ccwlock);
377 ret = ccw_device_offline(cdev);
378 if (ret == -ENODEV) {
379 if (cdev->private->state != DEV_STATE_NOT_OPER) {
380 cdev->private->state = DEV_STATE_OFFLINE;
381 dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
382 }
383 spin_unlock_irq(cdev->ccwlock);
384 return ret;
385 }
386 spin_unlock_irq(cdev->ccwlock);
387 if (ret == 0)
388 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
389 else {
Cornelia Hucke556bbb2007-07-27 12:29:19 +0200390 CIO_MSG_EVENT(2, "ccw_device_offline returned %d, "
391 "device 0.%x.%04x\n",
392 ret, cdev->private->dev_id.ssid,
393 cdev->private->dev_id.devno);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 cdev->online = 1;
395 }
396 return ret;
397}
398
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +0200399/**
400 * ccw_device_set_online() - enable a ccw device for I/O
401 * @cdev: target ccw device
402 *
403 * This function first enables @cdev and then calls the driver's set_online()
404 * function for @cdev, if given. If set_online() returns an error, @cdev is
405 * disabled again.
406 * Returns:
407 * %0 on success and a negative error value on failure.
408 * Context:
409 * enabled, ccw device lock not held
410 */
411int ccw_device_set_online(struct ccw_device *cdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412{
413 int ret;
414
415 if (!cdev)
416 return -ENODEV;
417 if (cdev->online || !cdev->drv)
418 return -EINVAL;
419
420 spin_lock_irq(cdev->ccwlock);
421 ret = ccw_device_online(cdev);
422 spin_unlock_irq(cdev->ccwlock);
423 if (ret == 0)
424 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
425 else {
Cornelia Hucke556bbb2007-07-27 12:29:19 +0200426 CIO_MSG_EVENT(2, "ccw_device_online returned %d, "
427 "device 0.%x.%04x\n",
428 ret, cdev->private->dev_id.ssid,
429 cdev->private->dev_id.devno);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 return ret;
431 }
432 if (cdev->private->state != DEV_STATE_ONLINE)
433 return -ENODEV;
434 if (!cdev->drv->set_online || cdev->drv->set_online(cdev) == 0) {
435 cdev->online = 1;
436 return 0;
437 }
438 spin_lock_irq(cdev->ccwlock);
439 ret = ccw_device_offline(cdev);
440 spin_unlock_irq(cdev->ccwlock);
441 if (ret == 0)
442 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
Cornelia Hucke556bbb2007-07-27 12:29:19 +0200443 else
444 CIO_MSG_EVENT(2, "ccw_device_offline returned %d, "
445 "device 0.%x.%04x\n",
446 ret, cdev->private->dev_id.ssid,
447 cdev->private->dev_id.devno);
Cornelia Huck6cadb782006-02-17 13:52:49 -0800448 return (ret == 0) ? -ENODEV : ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449}
450
Cornelia Huckf5ba6c82007-04-27 16:01:30 +0200451static void online_store_handle_offline(struct ccw_device *cdev)
452{
453 if (cdev->private->state == DEV_STATE_DISCONNECTED)
454 ccw_device_remove_disconnected(cdev);
455 else if (cdev->drv && cdev->drv->set_offline)
456 ccw_device_set_offline(cdev);
457}
458
459static int online_store_recog_and_online(struct ccw_device *cdev)
460{
461 int ret;
462
463 /* Do device recognition, if needed. */
464 if (cdev->id.cu_type == 0) {
465 ret = ccw_device_recognition(cdev);
466 if (ret) {
Cornelia Hucke556bbb2007-07-27 12:29:19 +0200467 CIO_MSG_EVENT(0, "Couldn't start recognition "
468 "for device 0.%x.%04x (ret=%d)\n",
469 cdev->private->dev_id.ssid,
470 cdev->private->dev_id.devno, ret);
Cornelia Huckf5ba6c82007-04-27 16:01:30 +0200471 return ret;
472 }
473 wait_event(cdev->private->wait_q,
474 cdev->private->flags.recog_done);
475 }
476 if (cdev->drv && cdev->drv->set_online)
477 ccw_device_set_online(cdev);
478 return 0;
479}
480static void online_store_handle_online(struct ccw_device *cdev, int force)
481{
482 int ret;
483
484 ret = online_store_recog_and_online(cdev);
485 if (ret)
486 return;
487 if (force && cdev->private->state == DEV_STATE_BOXED) {
488 ret = ccw_device_stlck(cdev);
489 if (ret) {
Cornelia Hucke556bbb2007-07-27 12:29:19 +0200490 dev_warn(&cdev->dev,
491 "ccw_device_stlck returned %d!\n", ret);
Cornelia Huckf5ba6c82007-04-27 16:01:30 +0200492 return;
493 }
494 if (cdev->id.cu_type == 0)
495 cdev->private->state = DEV_STATE_NOT_OPER;
496 online_store_recog_and_online(cdev);
497 }
498
499}
500
501static ssize_t online_store (struct device *dev, struct device_attribute *attr,
502 const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503{
504 struct ccw_device *cdev = to_ccwdev(dev);
Cornelia Huckf5ba6c82007-04-27 16:01:30 +0200505 int i, force;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 char *tmp;
507
Martin Schwidefsky973bd992006-01-06 00:19:07 -0800508 if (atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 return -EAGAIN;
510
511 if (cdev->drv && !try_module_get(cdev->drv->owner)) {
512 atomic_set(&cdev->private->onoff, 0);
513 return -EINVAL;
514 }
515 if (!strncmp(buf, "force\n", count)) {
516 force = 1;
517 i = 1;
518 } else {
519 force = 0;
520 i = simple_strtoul(buf, &tmp, 16);
521 }
Cornelia Huckf5ba6c82007-04-27 16:01:30 +0200522
523 switch (i) {
524 case 0:
525 online_store_handle_offline(cdev);
526 break;
527 case 1:
528 online_store_handle_online(cdev, force);
529 break;
530 default:
531 count = -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 if (cdev->drv)
534 module_put(cdev->drv->owner);
535 atomic_set(&cdev->private->onoff, 0);
536 return count;
537}
538
539static ssize_t
Yani Ioannou3fd3c0a2005-05-17 06:43:27 -0400540available_show (struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541{
542 struct ccw_device *cdev = to_ccwdev(dev);
543 struct subchannel *sch;
544
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100545 if (ccw_device_is_orphan(cdev))
546 return sprintf(buf, "no device\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 switch (cdev->private->state) {
548 case DEV_STATE_BOXED:
549 return sprintf(buf, "boxed\n");
550 case DEV_STATE_DISCONNECTED:
551 case DEV_STATE_DISCONNECTED_SENSE_ID:
552 case DEV_STATE_NOT_OPER:
553 sch = to_subchannel(dev->parent);
554 if (!sch->lpm)
555 return sprintf(buf, "no path\n");
556 else
557 return sprintf(buf, "no device\n");
558 default:
559 /* All other states considered fine. */
560 return sprintf(buf, "good\n");
561 }
562}
563
564static DEVICE_ATTR(chpids, 0444, chpids_show, NULL);
565static DEVICE_ATTR(pimpampom, 0444, pimpampom_show, NULL);
566static DEVICE_ATTR(devtype, 0444, devtype_show, NULL);
567static DEVICE_ATTR(cutype, 0444, cutype_show, NULL);
Bastian Blankf1fc78a2005-10-30 15:00:12 -0800568static DEVICE_ATTR(modalias, 0444, modalias_show, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569static DEVICE_ATTR(online, 0644, online_show, online_store);
570extern struct device_attribute dev_attr_cmb_enable;
571static DEVICE_ATTR(availability, 0444, available_show, NULL);
572
573static struct attribute * subch_attrs[] = {
574 &dev_attr_chpids.attr,
575 &dev_attr_pimpampom.attr,
576 NULL,
577};
578
579static struct attribute_group subch_attr_group = {
580 .attrs = subch_attrs,
581};
582
Cornelia Huck529192f2006-12-08 15:55:57 +0100583struct attribute_group *subch_attr_groups[] = {
584 &subch_attr_group,
585 NULL,
586};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587
588static struct attribute * ccwdev_attrs[] = {
589 &dev_attr_devtype.attr,
590 &dev_attr_cutype.attr,
Bastian Blankf1fc78a2005-10-30 15:00:12 -0800591 &dev_attr_modalias.attr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 &dev_attr_online.attr,
593 &dev_attr_cmb_enable.attr,
594 &dev_attr_availability.attr,
595 NULL,
596};
597
598static struct attribute_group ccwdev_attr_group = {
599 .attrs = ccwdev_attrs,
600};
601
Cornelia Huckf7e5d672007-05-10 15:45:43 +0200602static struct attribute_group *ccwdev_attr_groups[] = {
Cornelia Huckef995162007-04-27 16:01:39 +0200603 &ccwdev_attr_group,
604 NULL,
605};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606
607/* this is a simple abstraction for device_register that sets the
608 * correct bus type and adds the bus specific files */
Cornelia Huck3c9da7b2006-10-27 12:39:33 +0200609static int ccw_device_register(struct ccw_device *cdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610{
611 struct device *dev = &cdev->dev;
612 int ret;
613
614 dev->bus = &ccw_bus_type;
615
616 if ((ret = device_add(dev)))
617 return ret;
618
619 set_bit(1, &cdev->private->registered);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 return ret;
621}
622
Cornelia Huckb0744bd2005-06-25 14:55:27 -0700623struct match_data {
Cornelia Huck78964262006-10-11 15:31:38 +0200624 struct ccw_dev_id dev_id;
Cornelia Huckb0744bd2005-06-25 14:55:27 -0700625 struct ccw_device * sibling;
626};
627
628static int
629match_devno(struct device * dev, void * data)
630{
Cornelia Huck78964262006-10-11 15:31:38 +0200631 struct match_data * d = data;
Cornelia Huckb0744bd2005-06-25 14:55:27 -0700632 struct ccw_device * cdev;
633
634 cdev = to_ccwdev(dev);
635 if ((cdev->private->state == DEV_STATE_DISCONNECTED) &&
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100636 !ccw_device_is_orphan(cdev) &&
Cornelia Huck78964262006-10-11 15:31:38 +0200637 ccw_dev_id_is_equal(&cdev->private->dev_id, &d->dev_id) &&
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100638 (cdev != d->sibling))
Cornelia Huckb0744bd2005-06-25 14:55:27 -0700639 return 1;
Cornelia Huckb0744bd2005-06-25 14:55:27 -0700640 return 0;
641}
642
Cornelia Huck78964262006-10-11 15:31:38 +0200643static struct ccw_device * get_disc_ccwdev_by_dev_id(struct ccw_dev_id *dev_id,
644 struct ccw_device *sibling)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 struct device *dev;
Heiko Carstens292888c2006-08-30 14:33:35 +0200647 struct match_data data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648
Cornelia Huck78964262006-10-11 15:31:38 +0200649 data.dev_id = *dev_id;
Heiko Carstens292888c2006-08-30 14:33:35 +0200650 data.sibling = sibling;
Cornelia Hucke5945b42005-10-11 08:28:59 -0700651 dev = bus_find_device(&ccw_bus_type, NULL, &data, match_devno);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652
Cornelia Huckb0744bd2005-06-25 14:55:27 -0700653 return dev ? to_ccwdev(dev) : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654}
655
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100656static int match_orphan(struct device *dev, void *data)
657{
658 struct ccw_dev_id *dev_id;
659 struct ccw_device *cdev;
660
661 dev_id = data;
662 cdev = to_ccwdev(dev);
663 return ccw_dev_id_is_equal(&cdev->private->dev_id, dev_id);
664}
665
666static struct ccw_device *
667get_orphaned_ccwdev_by_dev_id(struct channel_subsystem *css,
668 struct ccw_dev_id *dev_id)
669{
670 struct device *dev;
671
672 dev = device_find_child(&css->pseudo_subchannel->dev, dev_id,
673 match_orphan);
674
675 return dev ? to_ccwdev(dev) : NULL;
676}
677
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678static void
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100679ccw_device_add_changed(struct work_struct *work)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680{
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100681 struct ccw_device_private *priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 struct ccw_device *cdev;
683
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100684 priv = container_of(work, struct ccw_device_private, kick_work);
685 cdev = priv->cdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 if (device_add(&cdev->dev)) {
687 put_device(&cdev->dev);
688 return;
689 }
690 set_bit(1, &cdev->private->registered);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691}
692
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100693void ccw_device_do_unreg_rereg(struct work_struct *work)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694{
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100695 struct ccw_device_private *priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 struct ccw_device *cdev;
697 struct subchannel *sch;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100699 priv = container_of(work, struct ccw_device_private, kick_work);
700 cdev = priv->cdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 sch = to_subchannel(cdev->dev.parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702
Cornelia Huckef995162007-04-27 16:01:39 +0200703 ccw_device_unregister(cdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 PREPARE_WORK(&cdev->private->kick_work,
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100705 ccw_device_add_changed);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 queue_work(ccw_device_work, &cdev->private->kick_work);
707}
708
709static void
710ccw_device_release(struct device *dev)
711{
712 struct ccw_device *cdev;
713
714 cdev = to_ccwdev(dev);
715 kfree(cdev->private);
716 kfree(cdev);
717}
718
Cornelia Huck7674da72006-12-08 15:54:21 +0100719static struct ccw_device * io_subchannel_allocate_dev(struct subchannel *sch)
720{
721 struct ccw_device *cdev;
722
723 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
724 if (cdev) {
725 cdev->private = kzalloc(sizeof(struct ccw_device_private),
726 GFP_KERNEL | GFP_DMA);
727 if (cdev->private)
728 return cdev;
729 }
730 kfree(cdev);
731 return ERR_PTR(-ENOMEM);
732}
733
734static int io_subchannel_initialize_dev(struct subchannel *sch,
735 struct ccw_device *cdev)
736{
737 cdev->private->cdev = cdev;
738 atomic_set(&cdev->private->onoff, 0);
739 cdev->dev.parent = &sch->dev;
740 cdev->dev.release = ccw_device_release;
Heiko Carstens33583c32007-11-05 11:10:07 +0100741 INIT_WORK(&cdev->private->kick_work, NULL);
Cornelia Huckef995162007-04-27 16:01:39 +0200742 cdev->dev.groups = ccwdev_attr_groups;
Cornelia Huck7674da72006-12-08 15:54:21 +0100743 /* Do first half of device_register. */
744 device_initialize(&cdev->dev);
745 if (!get_device(&sch->dev)) {
746 if (cdev->dev.release)
747 cdev->dev.release(&cdev->dev);
748 return -ENODEV;
749 }
750 return 0;
751}
752
753static struct ccw_device * io_subchannel_create_ccwdev(struct subchannel *sch)
754{
755 struct ccw_device *cdev;
756 int ret;
757
758 cdev = io_subchannel_allocate_dev(sch);
759 if (!IS_ERR(cdev)) {
760 ret = io_subchannel_initialize_dev(sch, cdev);
761 if (ret) {
762 kfree(cdev);
763 cdev = ERR_PTR(ret);
764 }
765 }
766 return cdev;
767}
768
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100769static int io_subchannel_recog(struct ccw_device *, struct subchannel *);
770
771static void sch_attach_device(struct subchannel *sch,
772 struct ccw_device *cdev)
773{
Cornelia Huck82b7ac02007-04-27 16:01:36 +0200774 css_update_ssd_info(sch);
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +0100775 spin_lock_irq(sch->lock);
776 sch->dev.driver_data = cdev;
777 cdev->private->schid = sch->schid;
778 cdev->ccwlock = sch->lock;
779 device_trigger_reprobe(sch);
780 spin_unlock_irq(sch->lock);
781}
782
783static void sch_attach_disconnected_device(struct subchannel *sch,
784 struct ccw_device *cdev)
785{
786 struct subchannel *other_sch;
787 int ret;
788
789 other_sch = to_subchannel(get_device(cdev->dev.parent));
790 ret = device_move(&cdev->dev, &sch->dev);
791 if (ret) {
792 CIO_MSG_EVENT(2, "Moving disconnected device 0.%x.%04x failed "
793 "(ret=%d)!\n", cdev->private->dev_id.ssid,
794 cdev->private->dev_id.devno, ret);
795 put_device(&other_sch->dev);
796 return;
797 }
798 other_sch->dev.driver_data = NULL;
799 /* No need to keep a subchannel without ccw device around. */
800 css_sch_device_unregister(other_sch);
801 put_device(&other_sch->dev);
802 sch_attach_device(sch, cdev);
803}
804
805static void sch_attach_orphaned_device(struct subchannel *sch,
806 struct ccw_device *cdev)
807{
808 int ret;
809
810 /* Try to move the ccw device to its new subchannel. */
811 ret = device_move(&cdev->dev, &sch->dev);
812 if (ret) {
813 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x from orphanage "
814 "failed (ret=%d)!\n",
815 cdev->private->dev_id.ssid,
816 cdev->private->dev_id.devno, ret);
817 return;
818 }
819 sch_attach_device(sch, cdev);
820}
821
822static void sch_create_and_recog_new_device(struct subchannel *sch)
823{
824 struct ccw_device *cdev;
825
826 /* Need to allocate a new ccw device. */
827 cdev = io_subchannel_create_ccwdev(sch);
828 if (IS_ERR(cdev)) {
829 /* OK, we did everything we could... */
830 css_sch_device_unregister(sch);
831 return;
832 }
833 spin_lock_irq(sch->lock);
834 sch->dev.driver_data = cdev;
835 spin_unlock_irq(sch->lock);
836 /* Start recognition for the new ccw device. */
837 if (io_subchannel_recog(cdev, sch)) {
838 spin_lock_irq(sch->lock);
839 sch->dev.driver_data = NULL;
840 spin_unlock_irq(sch->lock);
841 if (cdev->dev.release)
842 cdev->dev.release(&cdev->dev);
843 css_sch_device_unregister(sch);
844 }
845}
846
847
848void ccw_device_move_to_orphanage(struct work_struct *work)
849{
850 struct ccw_device_private *priv;
851 struct ccw_device *cdev;
852 struct ccw_device *replacing_cdev;
853 struct subchannel *sch;
854 int ret;
855 struct channel_subsystem *css;
856 struct ccw_dev_id dev_id;
857
858 priv = container_of(work, struct ccw_device_private, kick_work);
859 cdev = priv->cdev;
860 sch = to_subchannel(cdev->dev.parent);
861 css = to_css(sch->dev.parent);
862 dev_id.devno = sch->schib.pmcw.dev;
863 dev_id.ssid = sch->schid.ssid;
864
865 /*
866 * Move the orphaned ccw device to the orphanage so the replacing
867 * ccw device can take its place on the subchannel.
868 */
869 ret = device_move(&cdev->dev, &css->pseudo_subchannel->dev);
870 if (ret) {
871 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x to orphanage failed "
872 "(ret=%d)!\n", cdev->private->dev_id.ssid,
873 cdev->private->dev_id.devno, ret);
874 return;
875 }
876 cdev->ccwlock = css->pseudo_subchannel->lock;
877 /*
878 * Search for the replacing ccw device
879 * - among the disconnected devices
880 * - in the orphanage
881 */
882 replacing_cdev = get_disc_ccwdev_by_dev_id(&dev_id, cdev);
883 if (replacing_cdev) {
884 sch_attach_disconnected_device(sch, replacing_cdev);
885 return;
886 }
887 replacing_cdev = get_orphaned_ccwdev_by_dev_id(css, &dev_id);
888 if (replacing_cdev) {
889 sch_attach_orphaned_device(sch, replacing_cdev);
890 return;
891 }
892 sch_create_and_recog_new_device(sch);
893}
894
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895/*
896 * Register recognized device.
897 */
898static void
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100899io_subchannel_register(struct work_struct *work)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900{
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100901 struct ccw_device_private *priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 struct ccw_device *cdev;
903 struct subchannel *sch;
904 int ret;
905 unsigned long flags;
906
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100907 priv = container_of(work, struct ccw_device_private, kick_work);
908 cdev = priv->cdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 sch = to_subchannel(cdev->dev.parent);
Cornelia Huck82b7ac02007-04-27 16:01:36 +0200910 css_update_ssd_info(sch);
Cornelia Huck47af5512006-12-04 15:41:07 +0100911 /*
912 * io_subchannel_register() will also be called after device
913 * recognition has been done for a boxed device (which will already
914 * be registered). We need to reprobe since we may now have sense id
915 * information.
916 */
Cornelia Huckb0744bd2005-06-25 14:55:27 -0700917 if (klist_node_attached(&cdev->dev.knode_parent)) {
Cornelia Huck47af5512006-12-04 15:41:07 +0100918 if (!cdev->drv) {
919 ret = device_reprobe(&cdev->dev);
920 if (ret)
921 /* We can't do much here. */
Cornelia Hucke556bbb2007-07-27 12:29:19 +0200922 CIO_MSG_EVENT(2, "device_reprobe() returned"
923 " %d for 0.%x.%04x\n", ret,
924 cdev->private->dev_id.ssid,
925 cdev->private->dev_id.devno);
Cornelia Huck47af5512006-12-04 15:41:07 +0100926 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 goto out;
928 }
Cornelia Huckfa1a8c22007-04-26 00:12:03 -0700929 /*
930 * Now we know this subchannel will stay, we can throw
931 * our delayed uevent.
932 */
933 sch->dev.uevent_suppress = 0;
934 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935 /* make it known to the system */
936 ret = ccw_device_register(cdev);
937 if (ret) {
Cornelia Hucke556bbb2007-07-27 12:29:19 +0200938 CIO_MSG_EVENT(0, "Could not register ccw dev 0.%x.%04x: %d\n",
939 cdev->private->dev_id.ssid,
940 cdev->private->dev_id.devno, ret);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941 put_device(&cdev->dev);
Cornelia Huck2ec22982006-12-08 15:54:26 +0100942 spin_lock_irqsave(sch->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943 sch->dev.driver_data = NULL;
Cornelia Huck2ec22982006-12-08 15:54:26 +0100944 spin_unlock_irqrestore(sch->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945 kfree (cdev->private);
946 kfree (cdev);
947 put_device(&sch->dev);
948 if (atomic_dec_and_test(&ccw_device_init_count))
949 wake_up(&ccw_device_init_wq);
950 return;
951 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952 put_device(&cdev->dev);
953out:
954 cdev->private->flags.recog_done = 1;
955 put_device(&sch->dev);
956 wake_up(&cdev->private->wait_q);
957 if (atomic_dec_and_test(&ccw_device_init_count))
958 wake_up(&ccw_device_init_wq);
959}
960
Cornelia Huck3f4cf6e2007-10-12 16:11:26 +0200961static void ccw_device_call_sch_unregister(struct work_struct *work)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962{
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100963 struct ccw_device_private *priv;
964 struct ccw_device *cdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965 struct subchannel *sch;
966
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100967 priv = container_of(work, struct ccw_device_private, kick_work);
968 cdev = priv->cdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 sch = to_subchannel(cdev->dev.parent);
Cornelia Huck6ab48792006-07-12 16:39:50 +0200970 css_sch_device_unregister(sch);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971 /* Reset intparm to zeroes. */
972 sch->schib.pmcw.intparm = 0;
973 cio_modify(sch);
974 put_device(&cdev->dev);
975 put_device(&sch->dev);
976}
977
978/*
979 * subchannel recognition done. Called from the state machine.
980 */
981void
982io_subchannel_recog_done(struct ccw_device *cdev)
983{
984 struct subchannel *sch;
985
986 if (css_init_done == 0) {
987 cdev->private->flags.recog_done = 1;
988 return;
989 }
990 switch (cdev->private->state) {
991 case DEV_STATE_NOT_OPER:
992 cdev->private->flags.recog_done = 1;
993 /* Remove device found not operational. */
994 if (!get_device(&cdev->dev))
995 break;
996 sch = to_subchannel(cdev->dev.parent);
997 PREPARE_WORK(&cdev->private->kick_work,
Martin Schwidefskyc1637532006-12-08 15:53:57 +0100998 ccw_device_call_sch_unregister);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 queue_work(slow_path_wq, &cdev->private->kick_work);
1000 if (atomic_dec_and_test(&ccw_device_init_count))
1001 wake_up(&ccw_device_init_wq);
1002 break;
1003 case DEV_STATE_BOXED:
1004 /* Device did not respond in time. */
1005 case DEV_STATE_OFFLINE:
1006 /*
1007 * We can't register the device in interrupt context so
1008 * we schedule a work item.
1009 */
1010 if (!get_device(&cdev->dev))
1011 break;
1012 PREPARE_WORK(&cdev->private->kick_work,
Martin Schwidefskyc1637532006-12-08 15:53:57 +01001013 io_subchannel_register);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014 queue_work(slow_path_wq, &cdev->private->kick_work);
1015 break;
1016 }
1017}
1018
1019static int
1020io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch)
1021{
1022 int rc;
1023 struct ccw_device_private *priv;
1024
1025 sch->dev.driver_data = cdev;
1026 sch->driver = &io_subchannel_driver;
Cornelia Huck2ec22982006-12-08 15:54:26 +01001027 cdev->ccwlock = sch->lock;
Cornelia Huckfb6958a2006-01-06 00:19:25 -08001028
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029 /* Init private data. */
1030 priv = cdev->private;
Cornelia Huck78964262006-10-11 15:31:38 +02001031 priv->dev_id.devno = sch->schib.pmcw.dev;
1032 priv->dev_id.ssid = sch->schid.ssid;
1033 priv->schid = sch->schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 priv->state = DEV_STATE_NOT_OPER;
1035 INIT_LIST_HEAD(&priv->cmb_list);
1036 init_waitqueue_head(&priv->wait_q);
1037 init_timer(&priv->timer);
1038
1039 /* Set an initial name for the device. */
Cornelia Huckfb6958a2006-01-06 00:19:25 -08001040 snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x",
1041 sch->schid.ssid, sch->schib.pmcw.dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042
1043 /* Increase counter of devices currently in recognition. */
1044 atomic_inc(&ccw_device_init_count);
1045
1046 /* Start async. device sensing. */
Cornelia Huck2ec22982006-12-08 15:54:26 +01001047 spin_lock_irq(sch->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 rc = ccw_device_recognition(cdev);
Cornelia Huck2ec22982006-12-08 15:54:26 +01001049 spin_unlock_irq(sch->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 if (rc) {
1051 if (atomic_dec_and_test(&ccw_device_init_count))
1052 wake_up(&ccw_device_init_wq);
1053 }
1054 return rc;
1055}
1056
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +01001057static void ccw_device_move_to_sch(struct work_struct *work)
1058{
1059 struct ccw_device_private *priv;
1060 int rc;
1061 struct subchannel *sch;
1062 struct ccw_device *cdev;
1063 struct subchannel *former_parent;
1064
1065 priv = container_of(work, struct ccw_device_private, kick_work);
1066 sch = priv->sch;
1067 cdev = priv->cdev;
1068 former_parent = ccw_device_is_orphan(cdev) ?
1069 NULL : to_subchannel(get_device(cdev->dev.parent));
1070 mutex_lock(&sch->reg_mutex);
1071 /* Try to move the ccw device to its new subchannel. */
1072 rc = device_move(&cdev->dev, &sch->dev);
1073 mutex_unlock(&sch->reg_mutex);
1074 if (rc) {
1075 CIO_MSG_EVENT(2, "Moving device 0.%x.%04x to subchannel "
1076 "0.%x.%04x failed (ret=%d)!\n",
1077 cdev->private->dev_id.ssid,
1078 cdev->private->dev_id.devno, sch->schid.ssid,
1079 sch->schid.sch_no, rc);
1080 css_sch_device_unregister(sch);
1081 goto out;
1082 }
1083 if (former_parent) {
1084 spin_lock_irq(former_parent->lock);
1085 former_parent->dev.driver_data = NULL;
1086 spin_unlock_irq(former_parent->lock);
1087 css_sch_device_unregister(former_parent);
1088 /* Reset intparm to zeroes. */
1089 former_parent->schib.pmcw.intparm = 0;
1090 cio_modify(former_parent);
1091 }
1092 sch_attach_device(sch, cdev);
1093out:
1094 if (former_parent)
1095 put_device(&former_parent->dev);
1096 put_device(&cdev->dev);
1097}
1098
Cornelia Huck602b20f2008-01-26 14:10:39 +01001099static void io_subchannel_irq(struct subchannel *sch)
1100{
1101 struct ccw_device *cdev;
1102
1103 cdev = sch->dev.driver_data;
1104
1105 CIO_TRACE_EVENT(3, "IRQ");
1106 CIO_TRACE_EVENT(3, sch->dev.bus_id);
1107 if (cdev)
1108 dev_fsm_event(cdev, DEV_EVENT_INTERRUPT);
1109}
1110
Linus Torvalds1da177e2005-04-16 15:20:36 -07001111static int
Cornelia Huck8bbace72006-01-11 10:56:22 +01001112io_subchannel_probe (struct subchannel *sch)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 struct ccw_device *cdev;
1115 int rc;
1116 unsigned long flags;
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +01001117 struct ccw_dev_id dev_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 if (sch->dev.driver_data) {
1120 /*
1121 * This subchannel already has an associated ccw_device.
1122 * Register it and exit. This happens for all early
1123 * device, e.g. the console.
1124 */
1125 cdev = sch->dev.driver_data;
Cornelia Hucke1031782007-10-12 16:11:23 +02001126 cdev->dev.groups = ccwdev_attr_groups;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 device_initialize(&cdev->dev);
1128 ccw_device_register(cdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 /*
1130 * Check if the device is already online. If it is
1131 * the reference count needs to be corrected
1132 * (see ccw_device_online and css_init_done for the
1133 * ugly details).
1134 */
1135 if (cdev->private->state != DEV_STATE_NOT_OPER &&
1136 cdev->private->state != DEV_STATE_OFFLINE &&
1137 cdev->private->state != DEV_STATE_BOXED)
1138 get_device(&cdev->dev);
1139 return 0;
1140 }
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +01001141 /*
1142 * First check if a fitting device may be found amongst the
1143 * disconnected devices or in the orphanage.
1144 */
1145 dev_id.devno = sch->schib.pmcw.dev;
1146 dev_id.ssid = sch->schid.ssid;
Cornelia Huckcd6b4f22008-01-26 14:10:43 +01001147 /* Allocate I/O subchannel private data. */
1148 sch->private = kzalloc(sizeof(struct io_subchannel_private),
1149 GFP_KERNEL | GFP_DMA);
1150 if (!sch->private)
1151 return -ENOMEM;
Cornelia Huckd7b5a4c92006-12-08 15:54:28 +01001152 cdev = get_disc_ccwdev_by_dev_id(&dev_id, NULL);
1153 if (!cdev)
1154 cdev = get_orphaned_ccwdev_by_dev_id(to_css(sch->dev.parent),
1155 &dev_id);
1156 if (cdev) {
1157 /*
1158 * Schedule moving the device until when we have a registered
1159 * subchannel to move to and succeed the probe. We can
1160 * unregister later again, when the probe is through.
1161 */
1162 cdev->private->sch = sch;
1163 PREPARE_WORK(&cdev->private->kick_work,
1164 ccw_device_move_to_sch);
1165 queue_work(slow_path_wq, &cdev->private->kick_work);
1166 return 0;
1167 }
Cornelia Huck7674da72006-12-08 15:54:21 +01001168 cdev = io_subchannel_create_ccwdev(sch);
Cornelia Huckcd6b4f22008-01-26 14:10:43 +01001169 if (IS_ERR(cdev)) {
1170 kfree(sch->private);
Cornelia Huck7674da72006-12-08 15:54:21 +01001171 return PTR_ERR(cdev);
Cornelia Huckcd6b4f22008-01-26 14:10:43 +01001172 }
Cornelia Huck8bbace72006-01-11 10:56:22 +01001173 rc = io_subchannel_recog(cdev, sch);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 if (rc) {
Cornelia Huck2ec22982006-12-08 15:54:26 +01001175 spin_lock_irqsave(sch->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 sch->dev.driver_data = NULL;
Cornelia Huck2ec22982006-12-08 15:54:26 +01001177 spin_unlock_irqrestore(sch->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 if (cdev->dev.release)
1179 cdev->dev.release(&cdev->dev);
Cornelia Huckcd6b4f22008-01-26 14:10:43 +01001180 kfree(sch->private);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 }
1182
1183 return rc;
1184}
1185
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186static int
Cornelia Huck8bbace72006-01-11 10:56:22 +01001187io_subchannel_remove (struct subchannel *sch)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188{
1189 struct ccw_device *cdev;
1190 unsigned long flags;
1191
Cornelia Huck8bbace72006-01-11 10:56:22 +01001192 if (!sch->dev.driver_data)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 return 0;
Cornelia Huck8bbace72006-01-11 10:56:22 +01001194 cdev = sch->dev.driver_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 /* Set ccw device to not operational and drop reference. */
1196 spin_lock_irqsave(cdev->ccwlock, flags);
Cornelia Huck8bbace72006-01-11 10:56:22 +01001197 sch->dev.driver_data = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198 cdev->private->state = DEV_STATE_NOT_OPER;
1199 spin_unlock_irqrestore(cdev->ccwlock, flags);
Cornelia Huckef995162007-04-27 16:01:39 +02001200 ccw_device_unregister(cdev);
1201 put_device(&cdev->dev);
Cornelia Huckcd6b4f22008-01-26 14:10:43 +01001202 kfree(sch->private);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 return 0;
1204}
1205
Cornelia Huck602b20f2008-01-26 14:10:39 +01001206static int io_subchannel_notify(struct subchannel *sch, int event)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207{
1208 struct ccw_device *cdev;
1209
Cornelia Huck602b20f2008-01-26 14:10:39 +01001210 cdev = sch->dev.driver_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 if (!cdev)
1212 return 0;
1213 if (!cdev->drv)
1214 return 0;
1215 if (!cdev->online)
1216 return 0;
1217 return cdev->drv->notify ? cdev->drv->notify(cdev, event) : 0;
1218}
1219
Cornelia Huck602b20f2008-01-26 14:10:39 +01001220static void io_subchannel_verify(struct subchannel *sch)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221{
1222 struct ccw_device *cdev;
1223
Cornelia Huck602b20f2008-01-26 14:10:39 +01001224 cdev = sch->dev.driver_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 if (cdev)
1226 dev_fsm_event(cdev, DEV_EVENT_VERIFY);
1227}
1228
Cornelia Huck602b20f2008-01-26 14:10:39 +01001229static void io_subchannel_ioterm(struct subchannel *sch)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230{
1231 struct ccw_device *cdev;
1232
Cornelia Huck602b20f2008-01-26 14:10:39 +01001233 cdev = sch->dev.driver_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 if (!cdev)
1235 return;
Cornelia Huckd23861f2006-12-04 15:41:04 +01001236 /* Internal I/O will be retried by the interrupt handler. */
1237 if (cdev->private->flags.intretry)
1238 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239 cdev->private->state = DEV_STATE_CLEAR_VERIFY;
1240 if (cdev->handler)
1241 cdev->handler(cdev, cdev->private->intparm,
1242 ERR_PTR(-EIO));
1243}
1244
1245static void
Cornelia Huck8bbace72006-01-11 10:56:22 +01001246io_subchannel_shutdown(struct subchannel *sch)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 struct ccw_device *cdev;
1249 int ret;
1250
Cornelia Huck8bbace72006-01-11 10:56:22 +01001251 cdev = sch->dev.driver_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252
Cornelia Hucka8237fc2006-01-06 00:19:21 -08001253 if (cio_is_console(sch->schid))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 return;
1255 if (!sch->schib.pmcw.ena)
1256 /* Nothing to do. */
1257 return;
1258 ret = cio_disable_subchannel(sch);
1259 if (ret != -EBUSY)
1260 /* Subchannel is disabled, we're done. */
1261 return;
1262 cdev->private->state = DEV_STATE_QUIESCE;
1263 if (cdev->handler)
1264 cdev->handler(cdev, cdev->private->intparm,
1265 ERR_PTR(-EIO));
1266 ret = ccw_device_cancel_halt_clear(cdev);
1267 if (ret == -EBUSY) {
1268 ccw_device_set_timeout(cdev, HZ/10);
1269 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
1270 }
1271 cio_disable_subchannel(sch);
1272}
1273
1274#ifdef CONFIG_CCW_CONSOLE
1275static struct ccw_device console_cdev;
1276static struct ccw_device_private console_private;
1277static int console_cdev_in_use;
1278
Cornelia Huck2ec22982006-12-08 15:54:26 +01001279static DEFINE_SPINLOCK(ccw_console_lock);
1280
1281spinlock_t * cio_get_console_lock(void)
1282{
1283 return &ccw_console_lock;
1284}
1285
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286static int
1287ccw_device_console_enable (struct ccw_device *cdev, struct subchannel *sch)
1288{
1289 int rc;
1290
Cornelia Huckcd6b4f22008-01-26 14:10:43 +01001291 /* Attach subchannel private data. */
1292 sch->private = cio_get_console_priv();
1293 memset(sch->private, 0, sizeof(struct io_subchannel_private));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294 /* Initialize the ccw_device structure. */
Heiko Carstens292888c2006-08-30 14:33:35 +02001295 cdev->dev.parent= &sch->dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 rc = io_subchannel_recog(cdev, sch);
1297 if (rc)
1298 return rc;
1299
1300 /* Now wait for the async. recognition to come to an end. */
1301 spin_lock_irq(cdev->ccwlock);
1302 while (!dev_fsm_final_state(cdev))
1303 wait_cons_dev();
1304 rc = -EIO;
1305 if (cdev->private->state != DEV_STATE_OFFLINE)
1306 goto out_unlock;
1307 ccw_device_online(cdev);
1308 while (!dev_fsm_final_state(cdev))
1309 wait_cons_dev();
1310 if (cdev->private->state != DEV_STATE_ONLINE)
1311 goto out_unlock;
1312 rc = 0;
1313out_unlock:
1314 spin_unlock_irq(cdev->ccwlock);
1315 return 0;
1316}
1317
1318struct ccw_device *
1319ccw_device_probe_console(void)
1320{
1321 struct subchannel *sch;
1322 int ret;
1323
1324 if (xchg(&console_cdev_in_use, 1) != 0)
Peter Oberparleiter600b5d12006-02-01 03:06:35 -08001325 return ERR_PTR(-EBUSY);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001326 sch = cio_probe_console();
1327 if (IS_ERR(sch)) {
1328 console_cdev_in_use = 0;
1329 return (void *) sch;
1330 }
1331 memset(&console_cdev, 0, sizeof(struct ccw_device));
1332 memset(&console_private, 0, sizeof(struct ccw_device_private));
1333 console_cdev.private = &console_private;
Martin Schwidefskyc1637532006-12-08 15:53:57 +01001334 console_private.cdev = &console_cdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335 ret = ccw_device_console_enable(&console_cdev, sch);
1336 if (ret) {
1337 cio_release_console();
1338 console_cdev_in_use = 0;
1339 return ERR_PTR(ret);
1340 }
1341 console_cdev.online = 1;
1342 return &console_cdev;
1343}
1344#endif
1345
1346/*
1347 * get ccw_device matching the busid, but only if owned by cdrv
1348 */
Cornelia Huckb0744bd2005-06-25 14:55:27 -07001349static int
1350__ccwdev_check_busid(struct device *dev, void *id)
1351{
1352 char *bus_id;
1353
Cornelia Huck12975ae2006-10-11 15:31:47 +02001354 bus_id = id;
Cornelia Huckb0744bd2005-06-25 14:55:27 -07001355
1356 return (strncmp(bus_id, dev->bus_id, BUS_ID_SIZE) == 0);
1357}
1358
1359
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +02001360/**
1361 * get_ccwdev_by_busid() - obtain device from a bus id
1362 * @cdrv: driver the device is owned by
1363 * @bus_id: bus id of the device to be searched
1364 *
1365 * This function searches all devices owned by @cdrv for a device with a bus
1366 * id matching @bus_id.
1367 * Returns:
1368 * If a match is found, its reference count of the found device is increased
1369 * and it is returned; else %NULL is returned.
1370 */
1371struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv,
1372 const char *bus_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373{
Cornelia Huckb0744bd2005-06-25 14:55:27 -07001374 struct device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375 struct device_driver *drv;
1376
1377 drv = get_driver(&cdrv->driver);
1378 if (!drv)
Cornelia Huckb0744bd2005-06-25 14:55:27 -07001379 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380
Cornelia Huckb0744bd2005-06-25 14:55:27 -07001381 dev = driver_find_device(drv, NULL, (void *)bus_id,
1382 __ccwdev_check_busid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383 put_driver(drv);
1384
Heiko Carstensd2c993d2006-07-12 16:41:55 +02001385 return dev ? to_ccwdev(dev) : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386}
1387
1388/************************** device driver handling ************************/
1389
1390/* This is the implementation of the ccw_driver class. The probe, remove
1391 * and release methods are initially very similar to the device_driver
1392 * implementations, with the difference that they have ccw_device
1393 * arguments.
1394 *
1395 * A ccw driver also contains the information that is needed for
1396 * device matching.
1397 */
1398static int
1399ccw_device_probe (struct device *dev)
1400{
1401 struct ccw_device *cdev = to_ccwdev(dev);
1402 struct ccw_driver *cdrv = to_ccwdrv(dev->driver);
1403 int ret;
1404
1405 cdev->drv = cdrv; /* to let the driver call _set_online */
1406
1407 ret = cdrv->probe ? cdrv->probe(cdev) : -ENODEV;
1408
1409 if (ret) {
Heiko Carstensd2c993d2006-07-12 16:41:55 +02001410 cdev->drv = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 return ret;
1412 }
1413
1414 return 0;
1415}
1416
1417static int
1418ccw_device_remove (struct device *dev)
1419{
1420 struct ccw_device *cdev = to_ccwdev(dev);
1421 struct ccw_driver *cdrv = cdev->drv;
1422 int ret;
1423
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 if (cdrv->remove)
1425 cdrv->remove(cdev);
1426 if (cdev->online) {
1427 cdev->online = 0;
1428 spin_lock_irq(cdev->ccwlock);
1429 ret = ccw_device_offline(cdev);
1430 spin_unlock_irq(cdev->ccwlock);
1431 if (ret == 0)
1432 wait_event(cdev->private->wait_q,
1433 dev_fsm_final_state(cdev));
1434 else
1435 //FIXME: we can't fail!
Cornelia Hucke556bbb2007-07-27 12:29:19 +02001436 CIO_MSG_EVENT(2, "ccw_device_offline returned %d, "
1437 "device 0.%x.%04x\n",
1438 ret, cdev->private->dev_id.ssid,
1439 cdev->private->dev_id.devno);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440 }
1441 ccw_device_set_timeout(cdev, 0);
Heiko Carstensd2c993d2006-07-12 16:41:55 +02001442 cdev->drv = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443 return 0;
1444}
1445
Cornelia Huck958974fb2007-10-12 16:11:21 +02001446static void ccw_device_shutdown(struct device *dev)
1447{
1448 struct ccw_device *cdev;
1449
1450 cdev = to_ccwdev(dev);
1451 if (cdev->drv && cdev->drv->shutdown)
1452 cdev->drv->shutdown(cdev);
Cornelia Huck1842f2b2007-10-12 16:11:22 +02001453 disable_cmf(cdev);
Cornelia Huck958974fb2007-10-12 16:11:21 +02001454}
1455
Cornelia Huck8bbace72006-01-11 10:56:22 +01001456struct bus_type ccw_bus_type = {
1457 .name = "ccw",
1458 .match = ccw_bus_match,
1459 .uevent = ccw_uevent,
1460 .probe = ccw_device_probe,
1461 .remove = ccw_device_remove,
Cornelia Huck958974fb2007-10-12 16:11:21 +02001462 .shutdown = ccw_device_shutdown,
Cornelia Huck8bbace72006-01-11 10:56:22 +01001463};
1464
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +02001465/**
1466 * ccw_driver_register() - register a ccw driver
1467 * @cdriver: driver to be registered
1468 *
1469 * This function is mainly a wrapper around driver_register().
1470 * Returns:
1471 * %0 on success and a negative error value on failure.
1472 */
1473int ccw_driver_register(struct ccw_driver *cdriver)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474{
1475 struct device_driver *drv = &cdriver->driver;
1476
1477 drv->bus = &ccw_bus_type;
1478 drv->name = cdriver->name;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479
1480 return driver_register(drv);
1481}
1482
Cornelia Huckb2ffd8e2007-10-12 16:11:17 +02001483/**
1484 * ccw_driver_unregister() - deregister a ccw driver
1485 * @cdriver: driver to be deregistered
1486 *
1487 * This function is mainly a wrapper around driver_unregister().
1488 */
1489void ccw_driver_unregister(struct ccw_driver *cdriver)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490{
1491 driver_unregister(&cdriver->driver);
1492}
1493
Cornelia Hucka8237fc2006-01-06 00:19:21 -08001494/* Helper func for qdio. */
1495struct subchannel_id
1496ccw_device_get_subchannel_id(struct ccw_device *cdev)
1497{
1498 struct subchannel *sch;
1499
1500 sch = to_subchannel(cdev->dev.parent);
1501 return sch->schid;
1502}
1503
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504MODULE_LICENSE("GPL");
1505EXPORT_SYMBOL(ccw_device_set_online);
1506EXPORT_SYMBOL(ccw_device_set_offline);
1507EXPORT_SYMBOL(ccw_driver_register);
1508EXPORT_SYMBOL(ccw_driver_unregister);
1509EXPORT_SYMBOL(get_ccwdev_by_busid);
1510EXPORT_SYMBOL(ccw_bus_type);
1511EXPORT_SYMBOL(ccw_device_work);
1512EXPORT_SYMBOL(ccw_device_notify_work);
Cornelia Hucka8237fc2006-01-06 00:19:21 -08001513EXPORT_SYMBOL_GPL(ccw_device_get_subchannel_id);