Lines Matching refs:device
3 * character device frontend for tape device driver
64 tapechar_setup_device(struct tape_device * device)
68 sprintf(device_name, "ntibm%i", device->first_minor / 2);
69 device->nt = register_tape_dev(
70 &device->cdev->dev,
71 MKDEV(tapechar_major, device->first_minor),
77 device->rt = register_tape_dev(
78 &device->cdev->dev,
79 MKDEV(tapechar_major, device->first_minor + 1),
89 tapechar_cleanup_device(struct tape_device *device)
91 unregister_tape_dev(&device->cdev->dev, device->rt);
92 device->rt = NULL;
93 unregister_tape_dev(&device->cdev->dev, device->nt);
94 device->nt = NULL;
98 tapechar_check_idalbuffer(struct tape_device *device, size_t block_size)
102 if (device->char_data.idal_buf != NULL &&
103 device->char_data.idal_buf->size == block_size)
117 if (device->char_data.idal_buf != NULL)
118 idal_buffer_free(device->char_data.idal_buf);
120 device->char_data.idal_buf = new;
126 * Tape device read function
131 struct tape_device *device;
137 device = (struct tape_device *) filp->private_data;
144 if(device->required_tapemarks) {
145 return tape_std_terminate_write(device);
149 if (device->char_data.block_size != 0) {
150 if (count < device->char_data.block_size) {
155 block_size = device->char_data.block_size;
160 rc = tapechar_check_idalbuffer(device, block_size);
166 request = device->discipline->read_block(device, block_size);
170 rc = tape_do_io(device, request);
175 if (idal_buffer_to_user(device->char_data.idal_buf,
184 * Tape device write function
189 struct tape_device *device;
197 device = (struct tape_device *) filp->private_data;
199 if (device->char_data.block_size != 0) {
200 if (count < device->char_data.block_size) {
205 block_size = device->char_data.block_size;
212 rc = tapechar_check_idalbuffer(device, block_size);
219 request = device->discipline->write_block(device, block_size);
226 if (idal_buffer_from_user(device->char_data.idal_buf,
231 rc = tape_do_io(device, request);
244 * Ok, the device has no more space. It has NOT written
247 if (device->discipline->process_eov)
248 device->discipline->process_eov(device);
262 device->required_tapemarks = 2;
268 * Character frontend tape device open function.
273 struct tape_device *device;
284 device = tape_find_device(minor / TAPE_MINORS_PER_DEV);
285 if (IS_ERR(device)) {
287 return PTR_ERR(device);
290 rc = tape_open(device);
292 filp->private_data = device;
295 tape_put_device(device);
301 * Character frontend tape device release function.
307 struct tape_device *device;
310 device = (struct tape_device *) filp->private_data;
318 if (device->required_tapemarks)
319 tape_std_terminate_write(device);
320 tape_mtop(device, MTREW, 1);
322 if (device->required_tapemarks > 1) {
323 if (tape_mtop(device, MTWEOF, 1) == 0)
324 device->required_tapemarks--;
328 if (device->char_data.idal_buf != NULL) {
329 idal_buffer_free(device->char_data.idal_buf);
330 device->char_data.idal_buf = NULL;
332 tape_release(device);
334 tape_put_device(device);
340 * Tape device io controls.
343 __tapechar_ioctl(struct tape_device *device,
372 if (device->required_tapemarks)
373 tape_std_terminate_write(device);
377 rc = tape_mtop(device, op.mt_op, op.mt_count);
380 if (op.mt_count > device->required_tapemarks)
381 device->required_tapemarks = 0;
383 device->required_tapemarks -= op.mt_count;
391 rc = tape_mtop(device, MTTELL, 1);
403 get.mt_resid = 0 /* device->devstat.rescnt */;
405 ((device->char_data.block_size << MT_ST_BLKSIZE_SHIFT)
411 get.mt_gstat = device->tape_generic_status;
413 if (device->medium_state == MS_LOADED) {
414 rc = tape_mtop(device, MTTELL, 1);
428 if (device->discipline->ioctl_fn == NULL)
430 return device->discipline->ioctl_fn(device, no, (unsigned long)data);
436 struct tape_device *device;
441 device = (struct tape_device *) filp->private_data;
442 mutex_lock(&device->mutex);
443 rc = __tapechar_ioctl(device, no, (void __user *)data);
444 mutex_unlock(&device->mutex);
452 struct tape_device *device = filp->private_data;
460 mutex_lock(&device->mutex);
461 rc = __tapechar_ioctl(device, no, compat_ptr(data));
462 mutex_unlock(&device->mutex);
468 * Initialize character device frontend.