]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/s390/cio/device_ops.c
[S390] cio: incorrect status check in interrogate function
[net-next-2.6.git] / drivers / s390 / cio / device_ops.c
CommitLineData
1da177e4
LT
1/*
2 * drivers/s390/cio/device_ops.c
3 *
1da177e4
LT
4 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
5 * IBM Corporation
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
4ce3b30c 7 * Cornelia Huck (cornelia.huck@de.ibm.com)
1da177e4 8 */
1da177e4
LT
9#include <linux/module.h>
10#include <linux/init.h>
11#include <linux/errno.h>
12#include <linux/slab.h>
13#include <linux/list.h>
14#include <linux/device.h>
15#include <linux/delay.h>
16
17#include <asm/ccwdev.h>
18#include <asm/idals.h>
e5854a58 19#include <asm/chpid.h>
83262d63 20#include <asm/fcx.h>
1da177e4
LT
21
22#include "cio.h"
23#include "cio_debug.h"
24#include "css.h"
25#include "chsc.h"
26#include "device.h"
e6b6e10a 27#include "chp.h"
1da177e4 28
b2ffd8e9
CH
29/**
30 * ccw_device_set_options_mask() - set some options and unset the rest
31 * @cdev: device for which the options are to be set
32 * @flags: options to be set
33 *
34 * All flags specified in @flags are set, all flags not specified in @flags
35 * are cleared.
36 * Returns:
37 * %0 on success, -%EINVAL on an invalid flag combination.
38 */
4dd3cc5c 39int ccw_device_set_options_mask(struct ccw_device *cdev, unsigned long flags)
1da177e4
LT
40{
41 /*
42 * The flag usage is mutal exclusive ...
43 */
44 if ((flags & CCWDEV_EARLY_NOTIFICATION) &&
45 (flags & CCWDEV_REPORT_ALL))
46 return -EINVAL;
47 cdev->private->options.fast = (flags & CCWDEV_EARLY_NOTIFICATION) != 0;
48 cdev->private->options.repall = (flags & CCWDEV_REPORT_ALL) != 0;
49 cdev->private->options.pgroup = (flags & CCWDEV_DO_PATHGROUP) != 0;
50 cdev->private->options.force = (flags & CCWDEV_ALLOW_FORCE) != 0;
51 return 0;
52}
53
b2ffd8e9
CH
54/**
55 * ccw_device_set_options() - set some options
56 * @cdev: device for which the options are to be set
57 * @flags: options to be set
58 *
59 * All flags specified in @flags are set, the remainder is left untouched.
60 * Returns:
61 * %0 on success, -%EINVAL if an invalid flag combination would ensue.
62 */
4dd3cc5c
CH
63int ccw_device_set_options(struct ccw_device *cdev, unsigned long flags)
64{
65 /*
66 * The flag usage is mutal exclusive ...
67 */
68 if (((flags & CCWDEV_EARLY_NOTIFICATION) &&
69 (flags & CCWDEV_REPORT_ALL)) ||
70 ((flags & CCWDEV_EARLY_NOTIFICATION) &&
71 cdev->private->options.repall) ||
72 ((flags & CCWDEV_REPORT_ALL) &&
73 cdev->private->options.fast))
74 return -EINVAL;
75 cdev->private->options.fast |= (flags & CCWDEV_EARLY_NOTIFICATION) != 0;
76 cdev->private->options.repall |= (flags & CCWDEV_REPORT_ALL) != 0;
77 cdev->private->options.pgroup |= (flags & CCWDEV_DO_PATHGROUP) != 0;
78 cdev->private->options.force |= (flags & CCWDEV_ALLOW_FORCE) != 0;
79 return 0;
80}
81
b2ffd8e9
CH
82/**
83 * ccw_device_clear_options() - clear some options
84 * @cdev: device for which the options are to be cleared
85 * @flags: options to be cleared
86 *
87 * All flags specified in @flags are cleared, the remainder is left untouched.
88 */
4dd3cc5c
CH
89void ccw_device_clear_options(struct ccw_device *cdev, unsigned long flags)
90{
91 cdev->private->options.fast &= (flags & CCWDEV_EARLY_NOTIFICATION) == 0;
92 cdev->private->options.repall &= (flags & CCWDEV_REPORT_ALL) == 0;
93 cdev->private->options.pgroup &= (flags & CCWDEV_DO_PATHGROUP) == 0;
94 cdev->private->options.force &= (flags & CCWDEV_ALLOW_FORCE) == 0;
95}
96
b2ffd8e9
CH
97/**
98 * ccw_device_clear() - terminate I/O request processing
99 * @cdev: target ccw device
100 * @intparm: interruption parameter; value is only used if no I/O is
101 * outstanding, otherwise the intparm associated with the I/O request
102 * is returned
103 *
104 * ccw_device_clear() calls csch on @cdev's subchannel.
105 * Returns:
106 * %0 on success,
107 * -%ENODEV on device not operational,
108 * -%EINVAL on invalid device state.
109 * Context:
110 * Interrupts disabled, ccw device lock held
111 */
112int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
1da177e4
LT
113{
114 struct subchannel *sch;
115 int ret;
116
117 if (!cdev)
118 return -ENODEV;
119 if (cdev->private->state == DEV_STATE_NOT_OPER)
120 return -ENODEV;
121 if (cdev->private->state != DEV_STATE_ONLINE &&
1da177e4
LT
122 cdev->private->state != DEV_STATE_W4SENSE)
123 return -EINVAL;
124 sch = to_subchannel(cdev->dev.parent);
125 if (!sch)
126 return -ENODEV;
127 ret = cio_clear(sch);
128 if (ret == 0)
129 cdev->private->intparm = intparm;
130 return ret;
131}
132
b2ffd8e9
CH
133/**
134 * ccw_device_start_key() - start a s390 channel program with key
135 * @cdev: target ccw device
136 * @cpa: logical start address of channel program
137 * @intparm: user specific interruption parameter; will be presented back to
138 * @cdev's interrupt handler. Allows a device driver to associate
139 * the interrupt with a particular I/O request.
140 * @lpm: defines the channel path to be used for a specific I/O request. A
141 * value of 0 will make cio use the opm.
142 * @key: storage key to be used for the I/O
143 * @flags: additional flags; defines the action to be performed for I/O
144 * processing.
145 *
146 * Start a S/390 channel program. When the interrupt arrives, the
147 * IRQ handler is called, either immediately, delayed (dev-end missing,
148 * or sense required) or never (no IRQ handler registered).
149 * Returns:
150 * %0, if the operation was successful;
151 * -%EBUSY, if the device is busy, or status pending;
152 * -%EACCES, if no path specified in @lpm is operational;
153 * -%ENODEV, if the device is not operational.
154 * Context:
155 * Interrupts disabled, ccw device lock held
156 */
157int ccw_device_start_key(struct ccw_device *cdev, struct ccw1 *cpa,
158 unsigned long intparm, __u8 lpm, __u8 key,
159 unsigned long flags)
1da177e4
LT
160{
161 struct subchannel *sch;
162 int ret;
163
164 if (!cdev)
165 return -ENODEV;
166 sch = to_subchannel(cdev->dev.parent);
167 if (!sch)
168 return -ENODEV;
169 if (cdev->private->state == DEV_STATE_NOT_OPER)
170 return -ENODEV;
b4f7b1ee
CH
171 if (cdev->private->state == DEV_STATE_VERIFY ||
172 cdev->private->state == DEV_STATE_CLEAR_VERIFY) {
1da177e4
LT
173 /* Remember to fake irb when finished. */
174 if (!cdev->private->flags.fake_irb) {
175 cdev->private->flags.fake_irb = 1;
176 cdev->private->intparm = intparm;
177 return 0;
178 } else
179 /* There's already a fake I/O around. */
180 return -EBUSY;
181 }
182 if (cdev->private->state != DEV_STATE_ONLINE ||
23d805b6
PO
183 ((sch->schib.scsw.cmd.stctl & SCSW_STCTL_PRIM_STATUS) &&
184 !(sch->schib.scsw.cmd.stctl & SCSW_STCTL_SEC_STATUS)) ||
1da177e4
LT
185 cdev->private->flags.doverify)
186 return -EBUSY;
187 ret = cio_set_options (sch, flags);
188 if (ret)
189 return ret;
e0e32c8e
PO
190 /* Adjust requested path mask to excluded varied off paths. */
191 if (lpm) {
192 lpm &= sch->opm;
193 if (lpm == 0)
194 return -EACCES;
195 }
1da177e4 196 ret = cio_start_key (sch, cpa, lpm, key);
fe6173d9
CH
197 switch (ret) {
198 case 0:
1da177e4 199 cdev->private->intparm = intparm;
fe6173d9
CH
200 break;
201 case -EACCES:
202 case -ENODEV:
203 dev_fsm_event(cdev, DEV_EVENT_VERIFY);
204 break;
205 }
1da177e4
LT
206 return ret;
207}
208
b2ffd8e9
CH
209/**
210 * ccw_device_start_timeout_key() - start a s390 channel program with timeout and key
211 * @cdev: target ccw device
212 * @cpa: logical start address of channel program
213 * @intparm: user specific interruption parameter; will be presented back to
214 * @cdev's interrupt handler. Allows a device driver to associate
215 * the interrupt with a particular I/O request.
216 * @lpm: defines the channel path to be used for a specific I/O request. A
217 * value of 0 will make cio use the opm.
218 * @key: storage key to be used for the I/O
219 * @flags: additional flags; defines the action to be performed for I/O
220 * processing.
221 * @expires: timeout value in jiffies
222 *
223 * Start a S/390 channel program. When the interrupt arrives, the
224 * IRQ handler is called, either immediately, delayed (dev-end missing,
225 * or sense required) or never (no IRQ handler registered).
226 * This function notifies the device driver if the channel program has not
227 * completed during the time specified by @expires. If a timeout occurs, the
228 * channel program is terminated via xsch, hsch or csch, and the device's
229 * interrupt handler will be called with an irb containing ERR_PTR(-%ETIMEDOUT).
230 * Returns:
231 * %0, if the operation was successful;
232 * -%EBUSY, if the device is busy, or status pending;
233 * -%EACCES, if no path specified in @lpm is operational;
234 * -%ENODEV, if the device is not operational.
235 * Context:
236 * Interrupts disabled, ccw device lock held
237 */
238int ccw_device_start_timeout_key(struct ccw_device *cdev, struct ccw1 *cpa,
239 unsigned long intparm, __u8 lpm, __u8 key,
240 unsigned long flags, int expires)
1da177e4
LT
241{
242 int ret;
243
244 if (!cdev)
245 return -ENODEV;
246 ccw_device_set_timeout(cdev, expires);
247 ret = ccw_device_start_key(cdev, cpa, intparm, lpm, key, flags);
248 if (ret != 0)
249 ccw_device_set_timeout(cdev, 0);
250 return ret;
251}
252
b2ffd8e9
CH
253/**
254 * ccw_device_start() - start a s390 channel program
255 * @cdev: target ccw device
256 * @cpa: logical start address of channel program
257 * @intparm: user specific interruption parameter; will be presented back to
258 * @cdev's interrupt handler. Allows a device driver to associate
259 * the interrupt with a particular I/O request.
260 * @lpm: defines the channel path to be used for a specific I/O request. A
261 * value of 0 will make cio use the opm.
262 * @flags: additional flags; defines the action to be performed for I/O
263 * processing.
264 *
265 * Start a S/390 channel program. When the interrupt arrives, the
266 * IRQ handler is called, either immediately, delayed (dev-end missing,
267 * or sense required) or never (no IRQ handler registered).
268 * Returns:
269 * %0, if the operation was successful;
270 * -%EBUSY, if the device is busy, or status pending;
271 * -%EACCES, if no path specified in @lpm is operational;
272 * -%ENODEV, if the device is not operational.
273 * Context:
274 * Interrupts disabled, ccw device lock held
275 */
276int ccw_device_start(struct ccw_device *cdev, struct ccw1 *cpa,
277 unsigned long intparm, __u8 lpm, unsigned long flags)
1da177e4
LT
278{
279 return ccw_device_start_key(cdev, cpa, intparm, lpm,
0b642ede 280 PAGE_DEFAULT_KEY, flags);
1da177e4
LT
281}
282
b2ffd8e9
CH
283/**
284 * ccw_device_start_timeout() - start a s390 channel program with timeout
285 * @cdev: target ccw device
286 * @cpa: logical start address of channel program
287 * @intparm: user specific interruption parameter; will be presented back to
288 * @cdev's interrupt handler. Allows a device driver to associate
289 * the interrupt with a particular I/O request.
290 * @lpm: defines the channel path to be used for a specific I/O request. A
291 * value of 0 will make cio use the opm.
292 * @flags: additional flags; defines the action to be performed for I/O
293 * processing.
294 * @expires: timeout value in jiffies
295 *
296 * Start a S/390 channel program. When the interrupt arrives, the
297 * IRQ handler is called, either immediately, delayed (dev-end missing,
298 * or sense required) or never (no IRQ handler registered).
299 * This function notifies the device driver if the channel program has not
300 * completed during the time specified by @expires. If a timeout occurs, the
301 * channel program is terminated via xsch, hsch or csch, and the device's
302 * interrupt handler will be called with an irb containing ERR_PTR(-%ETIMEDOUT).
303 * Returns:
304 * %0, if the operation was successful;
305 * -%EBUSY, if the device is busy, or status pending;
306 * -%EACCES, if no path specified in @lpm is operational;
307 * -%ENODEV, if the device is not operational.
308 * Context:
309 * Interrupts disabled, ccw device lock held
310 */
311int ccw_device_start_timeout(struct ccw_device *cdev, struct ccw1 *cpa,
312 unsigned long intparm, __u8 lpm,
313 unsigned long flags, int expires)
1da177e4
LT
314{
315 return ccw_device_start_timeout_key(cdev, cpa, intparm, lpm,
0b642ede 316 PAGE_DEFAULT_KEY, flags,
1da177e4
LT
317 expires);
318}
319
320
b2ffd8e9
CH
321/**
322 * ccw_device_halt() - halt I/O request processing
323 * @cdev: target ccw device
324 * @intparm: interruption parameter; value is only used if no I/O is
325 * outstanding, otherwise the intparm associated with the I/O request
326 * is returned
327 *
328 * ccw_device_halt() calls hsch on @cdev's subchannel.
329 * Returns:
330 * %0 on success,
331 * -%ENODEV on device not operational,
332 * -%EINVAL on invalid device state,
333 * -%EBUSY on device busy or interrupt pending.
334 * Context:
335 * Interrupts disabled, ccw device lock held
336 */
337int ccw_device_halt(struct ccw_device *cdev, unsigned long intparm)
1da177e4
LT
338{
339 struct subchannel *sch;
340 int ret;
341
342 if (!cdev)
343 return -ENODEV;
344 if (cdev->private->state == DEV_STATE_NOT_OPER)
345 return -ENODEV;
346 if (cdev->private->state != DEV_STATE_ONLINE &&
1da177e4
LT
347 cdev->private->state != DEV_STATE_W4SENSE)
348 return -EINVAL;
349 sch = to_subchannel(cdev->dev.parent);
350 if (!sch)
351 return -ENODEV;
352 ret = cio_halt(sch);
353 if (ret == 0)
354 cdev->private->intparm = intparm;
355 return ret;
356}
357
b2ffd8e9
CH
358/**
359 * ccw_device_resume() - resume channel program execution
360 * @cdev: target ccw device
361 *
362 * ccw_device_resume() calls rsch on @cdev's subchannel.
363 * Returns:
364 * %0 on success,
365 * -%ENODEV on device not operational,
366 * -%EINVAL on invalid device state,
367 * -%EBUSY on device busy or interrupt pending.
368 * Context:
369 * Interrupts disabled, ccw device lock held
370 */
371int ccw_device_resume(struct ccw_device *cdev)
1da177e4
LT
372{
373 struct subchannel *sch;
374
375 if (!cdev)
376 return -ENODEV;
377 sch = to_subchannel(cdev->dev.parent);
378 if (!sch)
379 return -ENODEV;
380 if (cdev->private->state == DEV_STATE_NOT_OPER)
381 return -ENODEV;
382 if (cdev->private->state != DEV_STATE_ONLINE ||
23d805b6 383 !(sch->schib.scsw.cmd.actl & SCSW_ACTL_SUSPENDED))
1da177e4
LT
384 return -EINVAL;
385 return cio_resume(sch);
386}
387
388/*
389 * Pass interrupt to device driver.
390 */
391int
392ccw_device_call_handler(struct ccw_device *cdev)
393{
394 struct subchannel *sch;
395 unsigned int stctl;
396 int ending_status;
397
398 sch = to_subchannel(cdev->dev.parent);
399
400 /*
401 * we allow for the device action handler if .
402 * - we received ending status
403 * - the action handler requested to see all interrupts
404 * - we received an intermediate status
405 * - fast notification was requested (primary status)
406 * - unsolicited interrupts
407 */
23d805b6 408 stctl = scsw_stctl(&cdev->private->irb.scsw);
1da177e4
LT
409 ending_status = (stctl & SCSW_STCTL_SEC_STATUS) ||
410 (stctl == (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND)) ||
411 (stctl == SCSW_STCTL_STATUS_PEND);
412 if (!ending_status &&
413 !cdev->private->options.repall &&
414 !(stctl & SCSW_STCTL_INTER_STATUS) &&
415 !(cdev->private->options.fast &&
416 (stctl & SCSW_STCTL_PRIM_STATUS)))
417 return 0;
418
f1ee3281
CH
419 /* Clear pending timers for device driver initiated I/O. */
420 if (ending_status)
421 ccw_device_set_timeout(cdev, 0);
1da177e4
LT
422 /*
423 * Now we are ready to call the device driver interrupt handler.
424 */
425 if (cdev->handler)
426 cdev->handler(cdev, cdev->private->intparm,
427 &cdev->private->irb);
428
429 /*
430 * Clear the old and now useless interrupt response block.
431 */
432 memset(&cdev->private->irb, 0, sizeof(struct irb));
433
434 return 1;
435}
436
b2ffd8e9
CH
437/**
438 * ccw_device_get_ciw() - Search for CIW command in extended sense data.
439 * @cdev: ccw device to inspect
440 * @ct: command type to look for
441 *
442 * During SenseID, command information words (CIWs) describing special
443 * commands available to the device may have been stored in the extended
444 * sense data. This function searches for CIWs of a specified command
445 * type in the extended sense data.
446 * Returns:
447 * %NULL if no extended sense data has been stored or if no CIW of the
448 * specified command type could be found,
449 * else a pointer to the CIW of the specified command type.
1da177e4 450 */
b2ffd8e9 451struct ciw *ccw_device_get_ciw(struct ccw_device *cdev, __u32 ct)
1da177e4
LT
452{
453 int ciw_cnt;
454
455 if (cdev->private->flags.esid == 0)
456 return NULL;
457 for (ciw_cnt = 0; ciw_cnt < MAX_CIWS; ciw_cnt++)
458 if (cdev->private->senseid.ciw[ciw_cnt].ct == ct)
459 return cdev->private->senseid.ciw + ciw_cnt;
460 return NULL;
461}
462
b2ffd8e9
CH
463/**
464 * ccw_device_get_path_mask() - get currently available paths
465 * @cdev: ccw device to be queried
466 * Returns:
467 * %0 if no subchannel for the device is available,
468 * else the mask of currently available paths for the ccw device's subchannel.
469 */
470__u8 ccw_device_get_path_mask(struct ccw_device *cdev)
1da177e4
LT
471{
472 struct subchannel *sch;
473
474 sch = to_subchannel(cdev->dev.parent);
475 if (!sch)
476 return 0;
477 else
28bdc6f6 478 return sch->lpm;
1da177e4
LT
479}
480
1da177e4
LT
481/*
482 * Try to break the lock on a boxed device.
483 */
484int
485ccw_device_stlck(struct ccw_device *cdev)
486{
487 void *buf, *buf2;
488 unsigned long flags;
489 struct subchannel *sch;
490 int ret;
491
492 if (!cdev)
493 return -ENODEV;
494
495 if (cdev->drv && !cdev->private->options.force)
496 return -EINVAL;
497
498 sch = to_subchannel(cdev->dev.parent);
499
500 CIO_TRACE_EVENT(2, "stl lock");
2a0217d5 501 CIO_TRACE_EVENT(2, dev_name(&cdev->dev));
1da177e4
LT
502
503 buf = kmalloc(32*sizeof(char), GFP_DMA|GFP_KERNEL);
504 if (!buf)
505 return -ENOMEM;
506 buf2 = kmalloc(32*sizeof(char), GFP_DMA|GFP_KERNEL);
507 if (!buf2) {
508 kfree(buf);
509 return -ENOMEM;
510 }
2ec22984 511 spin_lock_irqsave(sch->lock, flags);
edf22096 512 ret = cio_enable_subchannel(sch, (u32)(addr_t)sch);
1da177e4
LT
513 if (ret)
514 goto out_unlock;
515 /*
516 * Setup ccw. We chain an unconditional reserve and a release so we
517 * only break the lock.
518 */
519 cdev->private->iccws[0].cmd_code = CCW_CMD_STLCK;
520 cdev->private->iccws[0].cda = (__u32) __pa(buf);
521 cdev->private->iccws[0].count = 32;
522 cdev->private->iccws[0].flags = CCW_FLAG_CC;
523 cdev->private->iccws[1].cmd_code = CCW_CMD_RELEASE;
524 cdev->private->iccws[1].cda = (__u32) __pa(buf2);
525 cdev->private->iccws[1].count = 32;
526 cdev->private->iccws[1].flags = 0;
527 ret = cio_start(sch, cdev->private->iccws, 0);
528 if (ret) {
529 cio_disable_subchannel(sch); //FIXME: return code?
530 goto out_unlock;
531 }
23d805b6 532 cdev->private->irb.scsw.cmd.actl |= SCSW_ACTL_START_PEND;
2ec22984 533 spin_unlock_irqrestore(sch->lock, flags);
23d805b6
PO
534 wait_event(cdev->private->wait_q,
535 cdev->private->irb.scsw.cmd.actl == 0);
2ec22984 536 spin_lock_irqsave(sch->lock, flags);
1da177e4 537 cio_disable_subchannel(sch); //FIXME: return code?
23d805b6 538 if ((cdev->private->irb.scsw.cmd.dstat !=
1da177e4 539 (DEV_STAT_CHN_END|DEV_STAT_DEV_END)) ||
23d805b6 540 (cdev->private->irb.scsw.cmd.cstat != 0))
1da177e4
LT
541 ret = -EIO;
542 /* Clear irb. */
543 memset(&cdev->private->irb, 0, sizeof(struct irb));
544out_unlock:
17fd682e
JJ
545 kfree(buf);
546 kfree(buf2);
2ec22984 547 spin_unlock_irqrestore(sch->lock, flags);
1da177e4
LT
548 return ret;
549}
550
b2ffd8e9 551void *ccw_device_get_chp_desc(struct ccw_device *cdev, int chp_no)
1da177e4
LT
552{
553 struct subchannel *sch;
e6b6e10a 554 struct chp_id chpid;
1da177e4
LT
555
556 sch = to_subchannel(cdev->dev.parent);
e6b6e10a
PO
557 chp_id_init(&chpid);
558 chpid.id = sch->schib.pmcw.chpid[chp_no];
559 return chp_get_chp_desc(chpid);
1da177e4
LT
560}
561
9a92fe48
CH
562/**
563 * ccw_device_get_id - obtain a ccw device id
564 * @cdev: device to obtain the id for
565 * @dev_id: where to fill in the values
566 */
567void ccw_device_get_id(struct ccw_device *cdev, struct ccw_dev_id *dev_id)
568{
569 *dev_id = cdev->private->dev_id;
570}
571EXPORT_SYMBOL(ccw_device_get_id);
572
83262d63
PO
573/**
574 * ccw_device_tm_start_key - perform start function
575 * @cdev: ccw device on which to perform the start function
576 * @tcw: transport-command word to be started
577 * @intparm: user defined parameter to be passed to the interrupt handler
578 * @lpm: mask of paths to use
579 * @key: storage key to use for storage access
580 *
581 * Start the tcw on the given ccw device. Return zero on success, non-zero
582 * otherwise.
583 */
584int ccw_device_tm_start_key(struct ccw_device *cdev, struct tcw *tcw,
585 unsigned long intparm, u8 lpm, u8 key)
586{
587 struct subchannel *sch;
588 int rc;
589
590 sch = to_subchannel(cdev->dev.parent);
591 if (cdev->private->state != DEV_STATE_ONLINE)
592 return -EIO;
593 /* Adjust requested path mask to excluded varied off paths. */
594 if (lpm) {
595 lpm &= sch->opm;
596 if (lpm == 0)
597 return -EACCES;
598 }
599 rc = cio_tm_start_key(sch, tcw, lpm, key);
600 if (rc == 0)
601 cdev->private->intparm = intparm;
602 return rc;
603}
604EXPORT_SYMBOL(ccw_device_tm_start_key);
605
606/**
607 * ccw_device_tm_start_timeout_key - perform start function
608 * @cdev: ccw device on which to perform the start function
609 * @tcw: transport-command word to be started
610 * @intparm: user defined parameter to be passed to the interrupt handler
611 * @lpm: mask of paths to use
612 * @key: storage key to use for storage access
613 * @expires: time span in jiffies after which to abort request
614 *
615 * Start the tcw on the given ccw device. Return zero on success, non-zero
616 * otherwise.
617 */
618int ccw_device_tm_start_timeout_key(struct ccw_device *cdev, struct tcw *tcw,
619 unsigned long intparm, u8 lpm, u8 key,
620 int expires)
621{
622 int ret;
623
624 ccw_device_set_timeout(cdev, expires);
625 ret = ccw_device_tm_start_key(cdev, tcw, intparm, lpm, key);
626 if (ret != 0)
627 ccw_device_set_timeout(cdev, 0);
628 return ret;
629}
630EXPORT_SYMBOL(ccw_device_tm_start_timeout_key);
631
632/**
633 * ccw_device_tm_start - perform start function
634 * @cdev: ccw device on which to perform the start function
635 * @tcw: transport-command word to be started
636 * @intparm: user defined parameter to be passed to the interrupt handler
637 * @lpm: mask of paths to use
638 *
639 * Start the tcw on the given ccw device. Return zero on success, non-zero
640 * otherwise.
641 */
642int ccw_device_tm_start(struct ccw_device *cdev, struct tcw *tcw,
643 unsigned long intparm, u8 lpm)
644{
645 return ccw_device_tm_start_key(cdev, tcw, intparm, lpm,
646 PAGE_DEFAULT_KEY);
647}
648EXPORT_SYMBOL(ccw_device_tm_start);
649
650/**
651 * ccw_device_tm_start_timeout - perform start function
652 * @cdev: ccw device on which to perform the start function
653 * @tcw: transport-command word to be started
654 * @intparm: user defined parameter to be passed to the interrupt handler
655 * @lpm: mask of paths to use
656 * @expires: time span in jiffies after which to abort request
657 *
658 * Start the tcw on the given ccw device. Return zero on success, non-zero
659 * otherwise.
660 */
661int ccw_device_tm_start_timeout(struct ccw_device *cdev, struct tcw *tcw,
662 unsigned long intparm, u8 lpm, int expires)
663{
664 return ccw_device_tm_start_timeout_key(cdev, tcw, intparm, lpm,
665 PAGE_DEFAULT_KEY, expires);
666}
667EXPORT_SYMBOL(ccw_device_tm_start_timeout);
668
669/**
670 * ccw_device_tm_intrg - perform interrogate function
671 * @cdev: ccw device on which to perform the interrogate function
672 *
673 * Perform an interrogate function on the given ccw device. Return zero on
674 * success, non-zero otherwise.
675 */
676int ccw_device_tm_intrg(struct ccw_device *cdev)
677{
678 struct subchannel *sch = to_subchannel(cdev->dev.parent);
679
680 if (cdev->private->state != DEV_STATE_ONLINE)
681 return -EIO;
682 if (!scsw_is_tm(&sch->schib.scsw) ||
7a968f05 683 !(scsw_actl(&sch->schib.scsw) & SCSW_ACTL_START_PEND))
83262d63
PO
684 return -EINVAL;
685 return cio_tm_intrg(sch);
686}
687EXPORT_SYMBOL(ccw_device_tm_intrg);
688
1da177e4
LT
689// FIXME: these have to go:
690
691int
692_ccw_device_get_subchannel_number(struct ccw_device *cdev)
693{
78964268 694 return cdev->private->schid.sch_no;
1da177e4
LT
695}
696
1da177e4
LT
697
698MODULE_LICENSE("GPL");
4dd3cc5c 699EXPORT_SYMBOL(ccw_device_set_options_mask);
1da177e4 700EXPORT_SYMBOL(ccw_device_set_options);
4dd3cc5c 701EXPORT_SYMBOL(ccw_device_clear_options);
1da177e4
LT
702EXPORT_SYMBOL(ccw_device_clear);
703EXPORT_SYMBOL(ccw_device_halt);
704EXPORT_SYMBOL(ccw_device_resume);
705EXPORT_SYMBOL(ccw_device_start_timeout);
706EXPORT_SYMBOL(ccw_device_start);
707EXPORT_SYMBOL(ccw_device_start_timeout_key);
708EXPORT_SYMBOL(ccw_device_start_key);
709EXPORT_SYMBOL(ccw_device_get_ciw);
710EXPORT_SYMBOL(ccw_device_get_path_mask);
1da177e4 711EXPORT_SYMBOL(_ccw_device_get_subchannel_number);
1da177e4 712EXPORT_SYMBOL_GPL(ccw_device_get_chp_desc);