static int scsi_write_data(SCSIDevice *d, uint32_t tag)

{

    SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d);

    SCSIGenericReq *r;

    int ret;



    DPRINTF("scsi_write_data 0x%x\n", tag);

    r = scsi_find_request(s, tag);

    if (!r) {

        BADF("Bad write tag 0x%x\n", tag);

        /* ??? This is the wrong error.  */

        scsi_command_complete(r, -EINVAL);

        return 0;

    }



    if (r->len == 0) {

        r->len = r->buflen;

        scsi_req_data(&r->req, r->len);

        return 0;

    }



    ret = execute_command(s->bs, r, SG_DXFER_TO_DEV, scsi_write_complete);

    if (ret == -1) {

        scsi_command_complete(r, -EINVAL);

        return 1;

    }



    return 0;

}

static int scsi_write_data(SCSIDevice *d, uint32_t tag)

{

    SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d);

    SCSIGenericReq *r;

    int ret;



    DPRINTF("scsi_write_data 0x%x\n", tag);

    r = scsi_find_request(s, tag);

    if (!r) {

        BADF("Bad write tag 0x%x\n", tag);

        

        scsi_command_complete(r, -EINVAL);

        return 0;

    }



    if (r->len == 0) {

        r->len = r->buflen;

        scsi_req_data(&r->req, r->len);

        return 0;

    }



    ret = execute_command(s->bs, r, SG_DXFER_TO_DEV, scsi_write_complete);

    if (ret == -1) {

        scsi_command_complete(r, -EINVAL);

        return 1;

    }



    return 0;

}

    r = scsi_find_request(s, tag);     r = scsi_find_request(s, tag);     if (!r) { static int scsi_write_data(SCSIDevice *d, uint32_t tag)     r = scsi_find_request(s, tag);     if (!r) {         BADF("Bad write tag 0x%x\n", tag);         return 1;     r = scsi_find_request(s, tag);     if (!r) {     r = scsi_find_request(s, tag);     SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d);     SCSIGenericReq *r;     r = scsi_find_request(s, tag);     SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d);     SCSIGenericReq *r;     r = scsi_find_request(s, tag);     if (!r) {         scsi_command_complete(r, -EINVAL); static int scsi_write_data(SCSIDevice *d, uint32_t tag)     SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d);     SCSIGenericReq *r;     DPRINTF("scsi_write_data 0x%x\n", tag);     r = scsi_find_request(s, tag);     if (!r) {         BADF("Bad write tag 0x%x\n", tag);         scsi_command_complete(r, -EINVAL);         return 0;     SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d);     SCSIGenericReq *r;     r = scsi_find_request(s, tag);     if (!r) {     SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, d);     SCSIGenericReq *r;     r = scsi_find_request(s, tag);
static int FUNC_0(SCSIDevice *VAR_0, uint32_t VAR_1)

{

    SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, VAR_0);

    SCSIGenericReq *r;

    int VAR_2;



    DPRINTF("FUNC_0 0x%x\n", VAR_1);

    r = scsi_find_request(s, VAR_1);

    if (!r) {

        BADF("Bad write VAR_1 0x%x\n", VAR_1);

        

        scsi_command_complete(r, -EINVAL);

        return 0;

    }



    if (r->len == 0) {

        r->len = r->buflen;

        scsi_req_data(&r->req, r->len);

        return 0;

    }



    VAR_2 = execute_command(s->bs, r, SG_DXFER_TO_DEV, scsi_write_complete);

    if (VAR_2 == -1) {

        scsi_command_complete(r, -EINVAL);

        return 1;

    }



    return 0;

}

static int FUNC_0(SCSIDevice *VAR_0, uint32_t VAR_1)
{ SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, VAR_0); SCSIGenericReq *r; int VAR_2; DPRINTF("FUNC_0 0x%x\n", VAR_1); r = scsi_find_request(s, VAR_1); if (!r) { BADF("Bad write VAR_1 0x%x\n", VAR_1); scsi_command_complete(r, -EINVAL); return 0; } if (r->len == 0) { r->len = r->buflen; scsi_req_data(&r->req, r->len); return 0; } VAR_2 = execute_command(s->bs, r, SG_DXFER_TO_DEV, scsi_write_complete); if (VAR_2 == -1) { scsi_command_complete(r, -EINVAL); return 1; } return 0; }