Searched refs:urd (Results 1 - 2 of 2) sorted by relevance

/linux-4.1.27/drivers/s390/char/
H A Dvmur.c85 * Each ur device (urd) contains a reference to its corresponding ccw device
86 * (cdev) using the urd->cdev pointer. Each ccw device has a reference to the
89 * urd references:
90 * - ur_probe gets a urd reference, ur_remove drops the reference
92 * - ur_open gets a urd reference, ur_release drops the reference
93 * (urf->urd)
96 * - urdev_alloc get a cdev reference (urd->cdev)
97 * - urdev_free drops the cdev reference (urd->cdev)
103 struct urdev *urd; urdev_alloc() local
105 urd = kzalloc(sizeof(struct urdev), GFP_KERNEL); urdev_alloc()
106 if (!urd) urdev_alloc()
108 urd->reclen = cdev->id.driver_info; urdev_alloc()
109 ccw_device_get_id(cdev, &urd->dev_id); urdev_alloc()
110 mutex_init(&urd->io_mutex); urdev_alloc()
111 init_waitqueue_head(&urd->wait); urdev_alloc()
112 spin_lock_init(&urd->open_lock); urdev_alloc()
113 atomic_set(&urd->ref_count, 1); urdev_alloc()
114 urd->cdev = cdev; urdev_alloc()
116 return urd; urdev_alloc()
119 static void urdev_free(struct urdev *urd) urdev_free() argument
121 TRACE("urdev_free: %p\n", urd); urdev_free()
122 if (urd->cdev) urdev_free()
123 put_device(&urd->cdev->dev); urdev_free()
124 kfree(urd); urdev_free()
127 static void urdev_get(struct urdev *urd) urdev_get() argument
129 atomic_inc(&urd->ref_count); urdev_get()
134 struct urdev *urd; urdev_get_from_cdev() local
138 urd = dev_get_drvdata(&cdev->dev); urdev_get_from_cdev()
139 if (urd) urdev_get_from_cdev()
140 urdev_get(urd); urdev_get_from_cdev()
142 return urd; urdev_get_from_cdev()
149 struct urdev *urd; urdev_get_from_devno() local
155 urd = urdev_get_from_cdev(cdev); urdev_get_from_devno()
157 return urd; urdev_get_from_devno()
160 static void urdev_put(struct urdev *urd) urdev_put() argument
162 if (atomic_dec_and_test(&urd->ref_count)) urdev_put()
163 urdev_free(urd); urdev_put()
177 struct urdev *urd = dev_get_drvdata(&cdev->dev); ur_pm_suspend() local
180 if (urd->open_flag) { ur_pm_suspend()
199 * on a completion event it publishes at urd->io_done. The function
270 static int do_ur_io(struct urdev *urd, struct ccw1 *cpa) do_ur_io() argument
273 struct ccw_device *cdev = urd->cdev; do_ur_io()
278 rc = mutex_lock_interruptible(&urd->io_mutex); do_ur_io()
282 urd->io_done = &event; do_ur_io()
297 mutex_unlock(&urd->io_mutex); do_ur_io()
307 struct urdev *urd; ur_int_handler() local
317 urd = dev_get_drvdata(&cdev->dev); ur_int_handler()
318 BUG_ON(!urd); ur_int_handler()
321 urd->io_request_rc = PTR_ERR(irb); ur_int_handler()
323 urd->io_request_rc = 0; ur_int_handler()
325 urd->io_request_rc = -EIO; ur_int_handler()
327 complete(urd->io_done); ur_int_handler()
336 struct urdev *urd; ur_attr_reclen_show() local
339 urd = urdev_get_from_cdev(to_ccwdev(dev)); ur_attr_reclen_show()
340 if (!urd) ur_attr_reclen_show()
342 rc = sprintf(buf, "%zu\n", urd->reclen); ur_attr_reclen_show()
343 urdev_put(urd); ur_attr_reclen_show()
366 static int get_urd_class(struct urdev *urd) get_urd_class() argument
371 ur_diag210.vrdcdvno = urd->dev_id.devno; get_urd_class()
390 static struct urfile *urfile_alloc(struct urdev *urd) urfile_alloc() argument
397 urf->urd = urd; urfile_alloc()
399 TRACE("urfile_alloc: urd=%p urf=%p rl=%zu\n", urd, urf, urfile_alloc()
407 TRACE("urfile_free: urf=%p urd=%p\n", urf, urf->urd); urfile_free()
414 static ssize_t do_write(struct urdev *urd, const char __user *udata, do_write() argument
424 rc = do_ur_io(urd, cpa); do_write()
428 if (urd->io_request_rc) { do_write()
429 rc = urd->io_request_rc; do_write()
456 return do_write(urf->urd, udata, count, urf->dev_reclen, ppos); ur_write()
515 struct urdev *urd; diag14_read() local
517 urd = ((struct urfile *) file->private_data)->urd; diag14_read()
520 rc = diag_position_to_record(urd->dev_id.devno, *offs / PAGE_SIZE + 1); diag14_read()
534 rc = diag_read_file(urd->dev_id.devno, buf); diag14_read()
561 struct urdev *urd; ur_read() local
569 urd = ((struct urfile *) file->private_data)->urd; ur_read()
570 rc = mutex_lock_interruptible(&urd->io_mutex); ur_read()
574 mutex_unlock(&urd->io_mutex); ur_read()
597 static int verify_uri_device(struct urdev *urd) verify_uri_device() argument
624 rc = diag_read_file(urd->dev_id.devno, buf); verify_uri_device()
645 static int verify_device(struct urdev *urd) verify_device() argument
647 switch (urd->class) { verify_device()
651 return verify_uri_device(urd); verify_device()
657 static int get_uri_file_reclen(struct urdev *urd) get_uri_file_reclen() argument
678 static int get_file_reclen(struct urdev *urd) get_file_reclen() argument
680 switch (urd->class) { get_file_reclen()
684 return get_uri_file_reclen(urd); get_file_reclen()
693 struct urdev *urd; ur_open() local
708 urd = urdev_get_from_devno(devno); ur_open()
709 if (!urd) { ur_open()
714 spin_lock(&urd->open_lock); ur_open()
715 while (urd->open_flag) { ur_open()
716 spin_unlock(&urd->open_lock); ur_open()
721 if (wait_event_interruptible(urd->wait, urd->open_flag == 0)) { ur_open()
725 spin_lock(&urd->open_lock); ur_open()
727 urd->open_flag++; ur_open()
728 spin_unlock(&urd->open_lock); ur_open()
732 if (((accmode == O_RDONLY) && (urd->class != DEV_CLASS_UR_I)) || ur_open()
733 ((accmode == O_WRONLY) && (urd->class != DEV_CLASS_UR_O))) { ur_open()
734 TRACE("ur_open: unsupported dev class (%d)\n", urd->class); ur_open()
739 rc = verify_device(urd); ur_open()
743 urf = urfile_alloc(urd); ur_open()
749 urf->dev_reclen = urd->reclen; ur_open()
750 rc = get_file_reclen(urd); ur_open()
760 spin_lock(&urd->open_lock); ur_open()
761 urd->open_flag--; ur_open()
762 spin_unlock(&urd->open_lock); ur_open()
764 urdev_put(urd); ur_open()
774 spin_lock(&urf->urd->open_lock); ur_release()
775 urf->urd->open_flag--; ur_release()
776 spin_unlock(&urf->urd->open_lock); ur_release()
777 wake_up_interruptible(&urf->urd->wait); ur_release()
778 urdev_put(urf->urd); ur_release()
825 * urd->char_device is used as indication that the online function has
830 struct urdev *urd; ur_probe() local
836 urd = urdev_alloc(cdev); ur_probe()
837 if (!urd) { ur_probe()
850 urd->class = get_urd_class(urd); ur_probe()
851 if (urd->class < 0) { ur_probe()
852 rc = urd->class; ur_probe()
855 if ((urd->class != DEV_CLASS_UR_I) && (urd->class != DEV_CLASS_UR_O)) { ur_probe()
860 dev_set_drvdata(&cdev->dev, urd); ur_probe()
869 urdev_put(urd); ur_probe()
877 struct urdev *urd; ur_set_online() local
884 urd = urdev_get_from_cdev(cdev); ur_set_online()
885 if (!urd) { ur_set_online()
886 /* ur_remove already deleted our urd */ ur_set_online()
891 if (urd->char_device) { ur_set_online()
897 minor = urd->dev_id.devno; ur_set_online()
900 urd->char_device = cdev_alloc(); ur_set_online()
901 if (!urd->char_device) { ur_set_online()
906 urd->char_device->ops = &ur_fops; ur_set_online()
907 urd->char_device->dev = MKDEV(major, minor); ur_set_online()
908 urd->char_device->owner = ur_fops.owner; ur_set_online()
910 rc = cdev_add(urd->char_device, urd->char_device->dev, 1); ur_set_online()
913 if (urd->cdev->id.cu_type == READER_PUNCH_DEVTYPE) { ur_set_online()
914 if (urd->class == DEV_CLASS_UR_I) ur_set_online()
916 if (urd->class == DEV_CLASS_UR_O) ur_set_online()
918 } else if (urd->cdev->id.cu_type == PRINTER_DEVTYPE) { ur_set_online()
925 urd->device = device_create(vmur_class, &cdev->dev, ur_set_online()
926 urd->char_device->dev, NULL, "%s", node_id); ur_set_online()
927 if (IS_ERR(urd->device)) { ur_set_online()
928 rc = PTR_ERR(urd->device); ur_set_online()
932 urdev_put(urd); ur_set_online()
937 cdev_del(urd->char_device); ur_set_online()
938 urd->char_device = NULL; ur_set_online()
940 urdev_put(urd); ur_set_online()
948 struct urdev *urd; ur_set_offline_force() local
952 urd = urdev_get_from_cdev(cdev); ur_set_offline_force()
953 if (!urd) ur_set_offline_force()
954 /* ur_remove already deleted our urd */ ur_set_offline_force()
956 if (!urd->char_device) { ur_set_offline_force()
961 if (!force && (atomic_read(&urd->ref_count) > 2)) { ur_set_offline_force()
962 /* There is still a user of urd (e.g. ur_open) */ ur_set_offline_force()
967 device_destroy(vmur_class, urd->char_device->dev); ur_set_offline_force()
968 cdev_del(urd->char_device); ur_set_offline_force()
969 urd->char_device = NULL; ur_set_offline_force()
973 urdev_put(urd); ur_set_offline_force()
H A Dvmur.h83 struct urdev *urd; member in struct:urfile

Completed in 79 milliseconds