388 if (size < 0) {
389 error = (size == -ENOIOCTLCMD ? -EINVAL : size);
390 goto done;
391 }
392 }
393
394 if (size)
395 error = put_user(size, &sioc->length)
396 ? -EFAULT : 0;
397 else
398 error = 0;
399done:
400 atm_dev_put(dev);
401 return error;
402}
403
404static __inline__ void *dev_get_idx(loff_t left)
405{
406 struct list_head *p;
407
408 list_for_each(p, &atm_devs) {
409 if (!--left)
410 break;
411 }
412 return (p != &atm_devs) ? p : NULL;
413}
414
415void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos)
416{
417 mutex_lock(&atm_dev_mutex);
418 return *pos ? dev_get_idx(*pos) : SEQ_START_TOKEN;
419}
420
421void atm_dev_seq_stop(struct seq_file *seq, void *v)
422{
423 mutex_unlock(&atm_dev_mutex);
424}
425
426void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
427{
428 ++*pos;