summaryrefslogtreecommitdiff
path: root/drivers/s390/char/tape_std.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/char/tape_std.c')
-rw-r--r--drivers/s390/char/tape_std.c104
1 files changed, 38 insertions, 66 deletions
diff --git a/drivers/s390/char/tape_std.c b/drivers/s390/char/tape_std.c
index 981a99fd8d42..43a5586685ff 100644
--- a/drivers/s390/char/tape_std.c
+++ b/drivers/s390/char/tape_std.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* standard tape device functions for ibm tapes.
*
@@ -10,9 +11,9 @@
* Stefan Bader <shbader@de.ibm.com>
*/
-#define KMSG_COMPONENT "tape"
-#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+#define pr_fmt(fmt) "tape: " fmt
+#include <linux/export.h>
#include <linux/stddef.h>
#include <linux/kernel.h>
#include <linux/bio.h>
@@ -32,14 +33,13 @@
* tape_std_assign
*/
static void
-tape_std_assign_timeout(unsigned long data)
+tape_std_assign_timeout(struct timer_list *t)
{
- struct tape_request * request;
- struct tape_device * device;
+ struct tape_request * request = timer_container_of(request, t,
+ timer);
+ struct tape_device * device = request->device;
int rc;
- request = (struct tape_request *) data;
- device = request->device;
BUG_ON(!device);
DBF_EVENT(3, "%08x: Assignment timeout. Device busy.\n",
@@ -54,7 +54,6 @@ int
tape_std_assign(struct tape_device *device)
{
int rc;
- struct timer_list timeout;
struct tape_request *request;
request = tape_alloc_request(2, 11);
@@ -70,15 +69,12 @@ tape_std_assign(struct tape_device *device)
* to another host (actually this shouldn't happen but it does).
* So we set up a timeout for this call.
*/
- init_timer_on_stack(&timeout);
- timeout.function = tape_std_assign_timeout;
- timeout.data = (unsigned long) request;
- timeout.expires = jiffies + 2 * HZ;
- add_timer(&timeout);
+ timer_setup(&request->timer, tape_std_assign_timeout, 0);
+ mod_timer(&request->timer, jiffies + msecs_to_jiffies(2000));
rc = tape_do_io_interruptible(device, request);
- del_timer(&timeout);
+ timer_delete_sync(&request->timer);
if (rc != 0) {
DBF_EVENT(3, "%08x: assign failed - device might be busy\n",
@@ -215,7 +211,7 @@ tape_std_mtload(struct tape_device *device, int count)
int
tape_std_mtsetblk(struct tape_device *device, int count)
{
- struct idal_buffer *new;
+ int rc;
DBF_LH(6, "tape_std_mtsetblk(%d)\n", count);
if (count <= 0) {
@@ -227,26 +223,12 @@ tape_std_mtsetblk(struct tape_device *device, int count)
device->char_data.block_size = 0;
return 0;
}
- if (device->char_data.idal_buf != NULL &&
- device->char_data.idal_buf->size == count)
- /* We already have a idal buffer of that size. */
- return 0;
- if (count > MAX_BLOCKSIZE) {
- DBF_EVENT(3, "Invalid block size (%d > %d) given.\n",
- count, MAX_BLOCKSIZE);
- return -EINVAL;
- }
+ rc = tape_check_idalbuffer(device, count);
+ if (rc)
+ return rc;
- /* Allocate a new idal buffer. */
- new = idal_buffer_alloc(count, 0);
- if (IS_ERR(new))
- return -ENOMEM;
- if (device->char_data.idal_buf != NULL)
- idal_buffer_free(device->char_data.idal_buf);
- device->char_data.idal_buf = new;
device->char_data.block_size = count;
-
DBF_LH(6, "new blocksize is %d\n", device->char_data.block_size);
return 0;
@@ -644,63 +626,54 @@ tape_std_mtcompression(struct tape_device *device, int mt_count)
* Read Block
*/
struct tape_request *
-tape_std_read_block(struct tape_device *device, size_t count)
+tape_std_read_block(struct tape_device *device)
{
struct tape_request *request;
+ struct idal_buffer **ibs;
+ struct ccw1 *ccw;
+ size_t count;
- /*
- * We have to alloc 4 ccws in order to be able to transform request
- * into a read backward request in error case.
- */
- request = tape_alloc_request(4, 0);
+ ibs = device->char_data.ibs;
+ count = idal_buffer_array_size(ibs);
+ request = tape_alloc_request(count + 1 /* MODE_SET_DB */, 0);
if (IS_ERR(request)) {
DBF_EXCEPTION(6, "xrbl fail");
return request;
}
request->op = TO_RFO;
- tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
- tape_ccw_end_idal(request->cpaddr + 1, READ_FORWARD,
- device->char_data.idal_buf);
+ ccw = tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
+ while (count-- > 1)
+ ccw = tape_ccw_dc_idal(ccw, READ_FORWARD, *ibs++);
+ tape_ccw_end_idal(ccw, READ_FORWARD, *ibs);
+
DBF_EVENT(6, "xrbl ccwg\n");
return request;
}
/*
- * Read Block backward transformation function.
- */
-void
-tape_std_read_backward(struct tape_device *device, struct tape_request *request)
-{
- /*
- * We have allocated 4 ccws in tape_std_read, so we can now
- * transform the request to a read backward, followed by a
- * forward space block.
- */
- request->op = TO_RBA;
- tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
- tape_ccw_cc_idal(request->cpaddr + 1, READ_BACKWARD,
- device->char_data.idal_buf);
- tape_ccw_cc(request->cpaddr + 2, FORSPACEBLOCK, 0, NULL);
- tape_ccw_end(request->cpaddr + 3, NOP, 0, NULL);
- DBF_EVENT(6, "xrop ccwg");}
-
-/*
* Write Block
*/
struct tape_request *
-tape_std_write_block(struct tape_device *device, size_t count)
+tape_std_write_block(struct tape_device *device)
{
struct tape_request *request;
+ struct idal_buffer **ibs;
+ struct ccw1 *ccw;
+ size_t count;
- request = tape_alloc_request(2, 0);
+ count = idal_buffer_array_size(device->char_data.ibs);
+ request = tape_alloc_request(count + 1 /* MODE_SET_DB */, 0);
if (IS_ERR(request)) {
DBF_EXCEPTION(6, "xwbl fail\n");
return request;
}
request->op = TO_WRI;
- tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
- tape_ccw_end_idal(request->cpaddr + 1, WRITE_CMD,
- device->char_data.idal_buf);
+ ccw = tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
+ ibs = device->char_data.ibs;
+ while (count-- > 1)
+ ccw = tape_ccw_dc_idal(ccw, WRITE_CMD, *ibs++);
+ tape_ccw_end_idal(ccw, WRITE_CMD, *ibs);
+
DBF_EVENT(6, "xwbl ccwg\n");
return request;
}
@@ -744,6 +717,5 @@ EXPORT_SYMBOL(tape_std_mterase);
EXPORT_SYMBOL(tape_std_mtunload);
EXPORT_SYMBOL(tape_std_mtcompression);
EXPORT_SYMBOL(tape_std_read_block);
-EXPORT_SYMBOL(tape_std_read_backward);
EXPORT_SYMBOL(tape_std_write_block);
EXPORT_SYMBOL(tape_std_process_eov);