Ejemplo n.º 1
0
/*
 * Medium sense for 34xx tapes. There is no 'real' medium sense call.
 * So we just do a normal sense.
 */
static void __tape_34xx_medium_sense(struct tape_request *request)
{
	struct tape_device *device = request->device;
	unsigned char *sense;

	if (request->rc == 0) {
		sense = request->cpdata;

		/*
		 * This isn't quite correct. But since INTERVENTION_REQUIRED
		 * means that the drive is 'neither ready nor on-line' it is
		 * only slightly inaccurate to say there is no tape loaded if
		 * the drive isn't online...
		 */
		if (sense[0] & SENSE_INTERVENTION_REQUIRED)
			tape_med_state_set(device, MS_UNLOADED);
		else
			tape_med_state_set(device, MS_LOADED);

		if (sense[1] & SENSE_WRITE_PROTECT)
			device->tape_generic_status |= GMT_WR_PROT(~0);
		else
			device->tape_generic_status &= ~GMT_WR_PROT(~0);
	} else
		DBF_EVENT(4, "tape_34xx: medium sense failed with rc=%d\n",
			request->rc);
	tape_free_request(request);
}
Ejemplo n.º 2
0
/*
 * Medium sense for 34xx tapes. There is no 'real' medium sense call.
 * So we just do a normal sense.
 */
static int
tape_34xx_medium_sense(struct tape_device *device)
{
    struct tape_request *request;
    unsigned char       *sense;
    int                  rc;

    request = tape_alloc_request(1, 32);
    if (IS_ERR(request)) {
        DBF_EXCEPTION(6, "MSEN fail\n");
        return PTR_ERR(request);
    }

    request->op = TO_MSEN;
    tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata);

    rc = tape_do_io_interruptible(device, request);
    if (request->rc == 0) {
        sense = request->cpdata;

        /*
         * This isn't quite correct. But since INTERVENTION_REQUIRED
         * means that the drive is 'neither ready nor on-line' it is
         * only slightly inaccurate to say there is no tape loaded if
         * the drive isn't online...
         */
        if (sense[0] & SENSE_INTERVENTION_REQUIRED)
            tape_med_state_set(device, MS_UNLOADED);
        else
            tape_med_state_set(device, MS_LOADED);

        if (sense[1] & SENSE_WRITE_PROTECT)
            device->tape_generic_status |= GMT_WR_PROT(~0);
        else
            device->tape_generic_status &= ~GMT_WR_PROT(~0);
    } else {
        DBF_EVENT(4, "tape_34xx: medium sense failed with rc=%d\n",
                  request->rc);
    }
    tape_free_request(request);

    return rc;
}
Ejemplo n.º 3
0
/*
 * Query KEKLs
 */
static int tape_3592_kekl_query(struct tape_device *device,
				struct tape390_kekl_pair *ext_kekls)
{
	struct tape_request *request;
	struct tape3592_kekl_query_order *order;
	struct tape3592_kekl_query_data *int_kekls;
	int rc;

	DBF_EVENT(6, "tape3592_kekl_query\n");
	int_kekls = kmalloc(sizeof(*int_kekls), GFP_KERNEL|GFP_DMA);
	if (!int_kekls)
		return -ENOMEM;
	request = tape_alloc_request(2, sizeof(*order));
	if (IS_ERR(request)) {
		rc = PTR_ERR(request);
		goto fail_malloc;
	}
	order = request->cpdata;
	memset(order,0,sizeof(*order));
	order->code = 0xe2;
	order->max_count = 2;
	request->op = TO_KEKL_QUERY;
	tape_ccw_cc(request->cpaddr, PERF_SUBSYS_FUNC, sizeof(*order), order);
	tape_ccw_end(request->cpaddr + 1, READ_SS_DATA, sizeof(*int_kekls),
		     int_kekls);
	rc = tape_do_io(device, request);
	if (rc)
		goto fail_request;
	int_to_ext_kekl_pair(&int_kekls->kekls, ext_kekls);

	rc = 0;
fail_request:
	tape_free_request(request);
fail_malloc:
	kfree(int_kekls);
	return rc;
}