Lines Matching full:device
3 * character device frontend for tape device driver
63 tapechar_setup_device(struct tape_device * device) in tapechar_setup_device() argument
67 sprintf(device_name, "ntibm%i", device->first_minor / 2); in tapechar_setup_device()
68 device->nt = register_tape_dev( in tapechar_setup_device()
69 &device->cdev->dev, in tapechar_setup_device()
70 MKDEV(tapechar_major, device->first_minor), in tapechar_setup_device()
76 device->rt = register_tape_dev( in tapechar_setup_device()
77 &device->cdev->dev, in tapechar_setup_device()
78 MKDEV(tapechar_major, device->first_minor + 1), in tapechar_setup_device()
88 tapechar_cleanup_device(struct tape_device *device) in tapechar_cleanup_device() argument
90 unregister_tape_dev(&device->cdev->dev, device->rt); in tapechar_cleanup_device()
91 device->rt = NULL; in tapechar_cleanup_device()
92 unregister_tape_dev(&device->cdev->dev, device->nt); in tapechar_cleanup_device()
93 device->nt = NULL; in tapechar_cleanup_device()
97 tapechar_check_idalbuffer(struct tape_device *device, size_t block_size) in tapechar_check_idalbuffer() argument
101 if (device->char_data.idal_buf != NULL && in tapechar_check_idalbuffer()
102 device->char_data.idal_buf->size == block_size) in tapechar_check_idalbuffer()
116 if (device->char_data.idal_buf != NULL) in tapechar_check_idalbuffer()
117 idal_buffer_free(device->char_data.idal_buf); in tapechar_check_idalbuffer()
119 device->char_data.idal_buf = new; in tapechar_check_idalbuffer()
125 * Tape device read function
130 struct tape_device *device; in tapechar_read() local
136 device = (struct tape_device *) filp->private_data; in tapechar_read()
143 if(device->required_tapemarks) { in tapechar_read()
144 return tape_std_terminate_write(device); in tapechar_read()
148 if (device->char_data.block_size != 0) { in tapechar_read()
149 if (count < device->char_data.block_size) { in tapechar_read()
154 block_size = device->char_data.block_size; in tapechar_read()
159 rc = tapechar_check_idalbuffer(device, block_size); in tapechar_read()
165 request = device->discipline->read_block(device, block_size); in tapechar_read()
169 rc = tape_do_io(device, request); in tapechar_read()
174 if (idal_buffer_to_user(device->char_data.idal_buf, in tapechar_read()
183 * Tape device write function
188 struct tape_device *device; in tapechar_write() local
196 device = (struct tape_device *) filp->private_data; in tapechar_write()
198 if (device->char_data.block_size != 0) { in tapechar_write()
199 if (count < device->char_data.block_size) { in tapechar_write()
204 block_size = device->char_data.block_size; in tapechar_write()
211 rc = tapechar_check_idalbuffer(device, block_size); in tapechar_write()
218 request = device->discipline->write_block(device, block_size); in tapechar_write()
225 if (idal_buffer_from_user(device->char_data.idal_buf, in tapechar_write()
230 rc = tape_do_io(device, request); in tapechar_write()
243 * Ok, the device has no more space. It has NOT written in tapechar_write()
246 if (device->discipline->process_eov) in tapechar_write()
247 device->discipline->process_eov(device); in tapechar_write()
261 device->required_tapemarks = 2; in tapechar_write()
267 * Character frontend tape device open function.
272 struct tape_device *device; in tapechar_open() local
283 device = tape_find_device(minor / TAPE_MINORS_PER_DEV); in tapechar_open()
284 if (IS_ERR(device)) { in tapechar_open()
286 return PTR_ERR(device); in tapechar_open()
289 rc = tape_open(device); in tapechar_open()
291 filp->private_data = device; in tapechar_open()
294 tape_put_device(device); in tapechar_open()
300 * Character frontend tape device release function.
306 struct tape_device *device; in tapechar_release() local
309 device = (struct tape_device *) filp->private_data; in tapechar_release()
317 if (device->required_tapemarks) in tapechar_release()
318 tape_std_terminate_write(device); in tapechar_release()
319 tape_mtop(device, MTREW, 1); in tapechar_release()
321 if (device->required_tapemarks > 1) { in tapechar_release()
322 if (tape_mtop(device, MTWEOF, 1) == 0) in tapechar_release()
323 device->required_tapemarks--; in tapechar_release()
327 if (device->char_data.idal_buf != NULL) { in tapechar_release()
328 idal_buffer_free(device->char_data.idal_buf); in tapechar_release()
329 device->char_data.idal_buf = NULL; in tapechar_release()
331 tape_release(device); in tapechar_release()
333 tape_put_device(device); in tapechar_release()
339 * Tape device io controls.
342 __tapechar_ioctl(struct tape_device *device, in __tapechar_ioctl() argument
371 if (device->required_tapemarks) in __tapechar_ioctl()
372 tape_std_terminate_write(device); in __tapechar_ioctl()
374 rc = tape_mtop(device, op.mt_op, op.mt_count); in __tapechar_ioctl()
377 if (op.mt_count > device->required_tapemarks) in __tapechar_ioctl()
378 device->required_tapemarks = 0; in __tapechar_ioctl()
380 device->required_tapemarks -= op.mt_count; in __tapechar_ioctl()
388 rc = tape_mtop(device, MTTELL, 1); in __tapechar_ioctl()
400 get.mt_resid = 0 /* device->devstat.rescnt */; in __tapechar_ioctl()
402 ((device->char_data.block_size << MT_ST_BLKSIZE_SHIFT) in __tapechar_ioctl()
408 get.mt_gstat = device->tape_generic_status; in __tapechar_ioctl()
410 if (device->medium_state == MS_LOADED) { in __tapechar_ioctl()
411 rc = tape_mtop(device, MTTELL, 1); in __tapechar_ioctl()
425 if (device->discipline->ioctl_fn == NULL) in __tapechar_ioctl()
427 return device->discipline->ioctl_fn(device, no, (unsigned long)data); in __tapechar_ioctl()
433 struct tape_device *device; in tapechar_ioctl() local
438 device = (struct tape_device *) filp->private_data; in tapechar_ioctl()
439 mutex_lock(&device->mutex); in tapechar_ioctl()
440 rc = __tapechar_ioctl(device, no, (void __user *)data); in tapechar_ioctl()
441 mutex_unlock(&device->mutex); in tapechar_ioctl()
449 struct tape_device *device = filp->private_data; in tapechar_compat_ioctl() local
457 mutex_lock(&device->mutex); in tapechar_compat_ioctl()
458 rc = __tapechar_ioctl(device, no, compat_ptr(data)); in tapechar_compat_ioctl()
459 mutex_unlock(&device->mutex); in tapechar_compat_ioctl()
465 * Initialize character device frontend.