Ejemplo n.º 1
0
static int tape_34xx_medium_sense(struct tape_device *device)
{
	struct tape_request *request;
	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);
	__tape_34xx_medium_sense(request);
	return rc;
}
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;
}