• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/s390/char/

Lines Matching defs:urd

82  * Each ur device (urd) contains a reference to its corresponding ccw device
83 * (cdev) using the urd->cdev pointer. Each ccw device has a reference to the
86 * urd references:
87 * - ur_probe gets a urd reference, ur_remove drops the reference
89 * - ur_open gets a urd reference, ur_relase drops the reference
90 * (urf->urd)
93 * - urdev_alloc get a cdev reference (urd->cdev)
94 * - urdev_free drops the cdev reference (urd->cdev)
100 struct urdev *urd;
102 urd = kzalloc(sizeof(struct urdev), GFP_KERNEL);
103 if (!urd)
105 urd->reclen = cdev->id.driver_info;
106 ccw_device_get_id(cdev, &urd->dev_id);
107 mutex_init(&urd->io_mutex);
108 init_waitqueue_head(&urd->wait);
109 spin_lock_init(&urd->open_lock);
110 atomic_set(&urd->ref_count, 1);
111 urd->cdev = cdev;
113 return urd;
116 static void urdev_free(struct urdev *urd)
118 TRACE("urdev_free: %p\n", urd);
119 if (urd->cdev)
120 put_device(&urd->cdev->dev);
121 kfree(urd);
124 static void urdev_get(struct urdev *urd)
126 atomic_inc(&urd->ref_count);
131 struct urdev *urd;
135 urd = dev_get_drvdata(&cdev->dev);
136 if (urd)
137 urdev_get(urd);
139 return urd;
146 struct urdev *urd;
152 urd = urdev_get_from_cdev(cdev);
154 return urd;
157 static void urdev_put(struct urdev *urd)
159 if (atomic_dec_and_test(&urd->ref_count))
160 urdev_free(urd);
174 struct urdev *urd = dev_get_drvdata(&cdev->dev);
177 if (urd->open_flag) {
196 * on a completion event it publishes at urd->io_done. The function
267 static int do_ur_io(struct urdev *urd, struct ccw1 *cpa)
270 struct ccw_device *cdev = urd->cdev;
275 rc = mutex_lock_interruptible(&urd->io_mutex);
279 urd->io_done = &event;
294 mutex_unlock(&urd->io_mutex);
304 struct urdev *urd;
314 urd = dev_get_drvdata(&cdev->dev);
315 BUG_ON(!urd);
318 urd->io_request_rc = PTR_ERR(irb);
320 urd->io_request_rc = 0;
322 urd->io_request_rc = -EIO;
324 complete(urd->io_done);
333 struct urdev *urd;
336 urd = urdev_get_from_cdev(to_ccwdev(dev));
337 if (!urd)
339 rc = sprintf(buf, "%zu\n", urd->reclen);
340 urdev_put(urd);
363 static int get_urd_class(struct urdev *urd)
368 ur_diag210.vrdcdvno = urd->dev_id.devno;
387 static struct urfile *urfile_alloc(struct urdev *urd)
394 urf->urd = urd;
396 TRACE("urfile_alloc: urd=%p urf=%p rl=%zu\n", urd, urf,
404 TRACE("urfile_free: urf=%p urd=%p\n", urf, urf->urd);
411 static ssize_t do_write(struct urdev *urd, const char __user *udata,
421 rc = do_ur_io(urd, cpa);
425 if (urd->io_request_rc) {
426 rc = urd->io_request_rc;
453 return do_write(urf->urd, udata, count, urf->dev_reclen, ppos);
512 struct urdev *urd;
514 urd = ((struct urfile *) file->private_data)->urd;
517 rc = diag_position_to_record(urd->dev_id.devno, *offs / PAGE_SIZE + 1);
531 rc = diag_read_file(urd->dev_id.devno, buf);
558 struct urdev *urd;
566 urd = ((struct urfile *) file->private_data)->urd;
567 rc = mutex_lock_interruptible(&urd->io_mutex);
571 mutex_unlock(&urd->io_mutex);
594 static int verify_uri_device(struct urdev *urd)
621 rc = diag_read_file(urd->dev_id.devno, buf);
642 static int verify_device(struct urdev *urd)
644 switch (urd->class) {
648 return verify_uri_device(urd);
654 static int get_uri_file_reclen(struct urdev *urd)
675 static int get_file_reclen(struct urdev *urd)
677 switch (urd->class) {
681 return get_uri_file_reclen(urd);
690 struct urdev *urd;
705 urd = urdev_get_from_devno(devno);
706 if (!urd) {
711 spin_lock(&urd->open_lock);
712 while (urd->open_flag) {
713 spin_unlock(&urd->open_lock);
718 if (wait_event_interruptible(urd->wait, urd->open_flag == 0)) {
722 spin_lock(&urd->open_lock);
724 urd->open_flag++;
725 spin_unlock(&urd->open_lock);
729 if (((accmode == O_RDONLY) && (urd->class != DEV_CLASS_UR_I)) ||
730 ((accmode == O_WRONLY) && (urd->class != DEV_CLASS_UR_O))) {
731 TRACE("ur_open: unsupported dev class (%d)\n", urd->class);
736 rc = verify_device(urd);
740 urf = urfile_alloc(urd);
746 urf->dev_reclen = urd->reclen;
747 rc = get_file_reclen(urd);
757 spin_lock(&urd->open_lock);
758 urd->open_flag--;
759 spin_unlock(&urd->open_lock);
761 urdev_put(urd);
771 spin_lock(&urf->urd->open_lock);
772 urf->urd->open_flag--;
773 spin_unlock(&urf->urd->open_lock);
774 wake_up_interruptible(&urf->urd->wait);
775 urdev_put(urf->urd);
822 * urd->char_device is used as indication that the online function has
827 struct urdev *urd;
833 urd = urdev_alloc(cdev);
834 if (!urd) {
847 urd->class = get_urd_class(urd);
848 if (urd->class < 0) {
849 rc = urd->class;
852 if ((urd->class != DEV_CLASS_UR_I) && (urd->class != DEV_CLASS_UR_O)) {
857 dev_set_drvdata(&cdev->dev, urd);
866 urdev_put(urd);
874 struct urdev *urd;
881 urd = urdev_get_from_cdev(cdev);
882 if (!urd) {
883 /* ur_remove already deleted our urd */
888 if (urd->char_device) {
894 minor = urd->dev_id.devno;
897 urd->char_device = cdev_alloc();
898 if (!urd->char_device) {
903 cdev_init(urd->char_device, &ur_fops);
904 urd->char_device->dev = MKDEV(major, minor);
905 urd->char_device->owner = ur_fops.owner;
907 rc = cdev_add(urd->char_device, urd->char_device->dev, 1);
910 if (urd->cdev->id.cu_type == READER_PUNCH_DEVTYPE) {
911 if (urd->class == DEV_CLASS_UR_I)
913 if (urd->class == DEV_CLASS_UR_O)
915 } else if (urd->cdev->id.cu_type == PRINTER_DEVTYPE) {
922 urd->device = device_create(vmur_class, NULL, urd->char_device->dev,
924 if (IS_ERR(urd->device)) {
925 rc = PTR_ERR(urd->device);
929 urdev_put(urd);
934 cdev_del(urd->char_device);
935 urd->char_device = NULL;
937 urdev_put(urd);
945 struct urdev *urd;
949 urd = urdev_get_from_cdev(cdev);
950 if (!urd)
951 /* ur_remove already deleted our urd */
953 if (!urd->char_device) {
958 if (!force && (atomic_read(&urd->ref_count) > 2)) {
959 /* There is still a user of urd (e.g. ur_open) */
964 device_destroy(vmur_class, urd->char_device->dev);
965 cdev_del(urd->char_device);
966 urd->char_device = NULL;
970 urdev_put(urd);