Consolidated several local struct command to a new member of struct burn_drive

This commit is contained in:
Thomas Schmitt 2011-06-07 14:40:31 +00:00
parent 99af1501fc
commit c96745af15
5 changed files with 499 additions and 523 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2011.06.07.084343" #define Cdrskin_timestamP "2011.06.07.143930"

File diff suppressed because it is too large Load Diff

View File

@ -54,20 +54,21 @@ static unsigned char SBC_STOP_UNIT[] = { 0x1b, 0, 0, 0, 0, 0 };
void sbc_load(struct burn_drive *d) void sbc_load(struct burn_drive *d)
{ {
struct command c; struct command *c;
c = &(d->casual_command);
if (mmc_function_spy(d, "load") <= 0) if (mmc_function_spy(d, "load") <= 0)
return; return;
scsi_init_command(&c, SBC_LOAD, sizeof(SBC_LOAD)); scsi_init_command(c, SBC_LOAD, sizeof(SBC_LOAD));
c.retry = 1; c->retry = 1;
/* ts A70921 : Had to revoke Immed because of LG GSA-4082B */ /* ts A70921 : Had to revoke Immed because of LG GSA-4082B */
/* c.opcode[1] |= 1; / * ts A70918 : Immed */ /* c->opcode[1] |= 1; / * ts A70918 : Immed */
c.dir = NO_TRANSFER; c->dir = NO_TRANSFER;
d->issue_command(d, &c); d->issue_command(d, c);
if (c.error) if (c->error)
return; return;
/* ts A70923 : Needed regardless of Immed bit. Was once 1 minute, now /* ts A70923 : Needed regardless of Immed bit. Was once 1 minute, now
5 minutes for loading. If this does not suffice then other commands 5 minutes for loading. If this does not suffice then other commands
@ -77,20 +78,21 @@ void sbc_load(struct burn_drive *d)
void sbc_eject(struct burn_drive *d) void sbc_eject(struct burn_drive *d)
{ {
struct command c; struct command *c;
c = &(d->casual_command);
if (mmc_function_spy(d, "eject") <= 0) if (mmc_function_spy(d, "eject") <= 0)
return; return;
scsi_init_command(&c, SBC_UNLOAD, sizeof(SBC_UNLOAD)); scsi_init_command(c, SBC_UNLOAD, sizeof(SBC_UNLOAD));
/* c.opcode[1] |= 1; / * ts A70918 : Immed , ts B00109 : revoked */ /* c->opcode[1] |= 1; / * ts A70918 : Immed , ts B00109 : revoked */
c.page = NULL; c->page = NULL;
c.dir = NO_TRANSFER; c->dir = NO_TRANSFER;
d->issue_command(d, &c); d->issue_command(d, c);
/* ts A70918 : Wait long. A late eject could surprise or hurt user. /* ts A70918 : Wait long. A late eject could surprise or hurt user.
ts B00109 : Asynchronous eject revoked, as one cannot reliably ts B00109 : Asynchronous eject revoked, as one cannot reliably
distinguish out from unready. distinguish out from unready.
if (c.error) if (c->error)
return; return;
spc_wait_unit_attention(d, 1800, "STOP UNIT (+ EJECT)", 0); spc_wait_unit_attention(d, 1800, "STOP UNIT (+ EJECT)", 0);
*/ */
@ -102,18 +104,19 @@ void sbc_eject(struct burn_drive *d)
*/ */
int sbc_start_unit_flag(struct burn_drive *d, int flag) int sbc_start_unit_flag(struct burn_drive *d, int flag)
{ {
struct command c; struct command *c;
int ret; int ret;
c = &(d->casual_command);
if (mmc_function_spy(d, "start_unit") <= 0) if (mmc_function_spy(d, "start_unit") <= 0)
return 0; return 0;
scsi_init_command(&c, SBC_START_UNIT, sizeof(SBC_START_UNIT)); scsi_init_command(c, SBC_START_UNIT, sizeof(SBC_START_UNIT));
c.retry = 1; c->retry = 1;
c.opcode[1] |= (flag & 1); /* ts A70918 : Immed */ c->opcode[1] |= (flag & 1); /* ts A70918 : Immed */
c.dir = NO_TRANSFER; c->dir = NO_TRANSFER;
d->issue_command(d, &c); d->issue_command(d, c);
if (c.error) if (c->error)
return 0; return 0;
if (!(flag & 1)) if (!(flag & 1))
return 1; return 1;
@ -144,18 +147,19 @@ int sbc_start_unit(struct burn_drive *d)
/* ts A90824 : Trying to reduce drive noise */ /* ts A90824 : Trying to reduce drive noise */
int sbc_stop_unit(struct burn_drive *d) int sbc_stop_unit(struct burn_drive *d)
{ {
struct command c; struct command *c;
int ret; int ret;
c = &(d->casual_command);
if (mmc_function_spy(d, "stop_unit") <= 0) if (mmc_function_spy(d, "stop_unit") <= 0)
return 0; return 0;
scsi_init_command(&c, SBC_STOP_UNIT, sizeof(SBC_STOP_UNIT)); scsi_init_command(c, SBC_STOP_UNIT, sizeof(SBC_STOP_UNIT));
c.retry = 0; c->retry = 0;
c.opcode[1] |= 1; /* Immed */ c->opcode[1] |= 1; /* Immed */
c.dir = NO_TRANSFER; c->dir = NO_TRANSFER;
d->issue_command(d, &c); d->issue_command(d, c);
if (c.error) if (c->error)
return 0; return 0;
ret = spc_wait_unit_attention(d, 1800, "STOP UNIT", 0); ret = spc_wait_unit_attention(d, 1800, "STOP UNIT", 0);
d->is_stopped = 1; d->is_stopped = 1;

View File

@ -64,6 +64,7 @@ int scsi_init_command(struct command *c, unsigned char *opcode, int oplen)
{ {
if (oplen > 16) if (oplen > 16)
return 0; return 0;
memset(c, 0, sizeof(struct command));
memcpy(c->opcode, opcode, oplen); memcpy(c->opcode, opcode, oplen);
c->oplen = oplen; c->oplen = oplen;
c->dir = NO_TRANSFER; c->dir = NO_TRANSFER;
@ -102,25 +103,21 @@ int spc_decode_sense(unsigned char *sense, int senselen,
int spc_test_unit_ready_r(struct burn_drive *d, int *key, int *asc, int *ascq) int spc_test_unit_ready_r(struct burn_drive *d, int *key, int *asc, int *ascq)
{ {
struct command *c = NULL; struct command *c;
int ret;
c = &(d->casual_command);
if (mmc_function_spy(d, "test_unit_ready") <= 0) if (mmc_function_spy(d, "test_unit_ready") <= 0)
{ret = 0; goto ex;} return 0;
BURN_ALLOC_MEM(c, struct command, 1);
scsi_init_command(c, SPC_TEST_UNIT_READY,sizeof(SPC_TEST_UNIT_READY)); scsi_init_command(c, SPC_TEST_UNIT_READY,sizeof(SPC_TEST_UNIT_READY));
c->retry = 0; c->retry = 0;
c->dir = NO_TRANSFER; c->dir = NO_TRANSFER;
d->issue_command(d, c); d->issue_command(d, c);
if (c->error) { if (c->error) {
spc_decode_sense(c->sense, 0, key, asc, ascq); spc_decode_sense(c->sense, 0, key, asc, ascq);
{ret = (key == 0); goto ex;} return (key == 0);
} }
ret = 1; return 1;
ex:;
BURN_FREE_MEM(c);
return ret;
} }
@ -233,13 +230,12 @@ ex:;
void spc_request_sense(struct burn_drive *d, struct buffer *buf) void spc_request_sense(struct burn_drive *d, struct buffer *buf)
{ {
struct command *c = NULL; struct command *c;
int ret;
c = &(d->casual_command);
if (mmc_function_spy(d, "request_sense") <= 0) if (mmc_function_spy(d, "request_sense") <= 0)
goto ex; return;
BURN_ALLOC_MEM(c, struct command, 1);
scsi_init_command(c, SPC_REQUEST_SENSE, sizeof(SPC_REQUEST_SENSE)); scsi_init_command(c, SPC_REQUEST_SENSE, sizeof(SPC_REQUEST_SENSE));
c->retry = 0; c->retry = 0;
c->dxfer_len= c->opcode[4]; c->dxfer_len= c->opcode[4];
@ -249,8 +245,6 @@ void spc_request_sense(struct burn_drive *d, struct buffer *buf)
c->page->bytes = 0; c->page->bytes = 0;
c->dir = FROM_DRIVE; c->dir = FROM_DRIVE;
d->issue_command(d, c); d->issue_command(d, c);
ex:;
BURN_FREE_MEM(c);
} }
int spc_get_erase_progress(struct burn_drive *d) int spc_get_erase_progress(struct burn_drive *d)
@ -309,42 +303,35 @@ ex:;
void spc_prevent(struct burn_drive *d) void spc_prevent(struct burn_drive *d)
{ {
struct command *c = NULL; struct command *c;
int ret;
c = &(d->casual_command);
if (mmc_function_spy(d, "prevent") <= 0) if (mmc_function_spy(d, "prevent") <= 0)
return; return;
BURN_ALLOC_MEM(c, struct command, 1);
scsi_init_command(c, SPC_PREVENT, sizeof(SPC_PREVENT)); scsi_init_command(c, SPC_PREVENT, sizeof(SPC_PREVENT));
c->retry = 1; c->retry = 1;
c->dir = NO_TRANSFER; c->dir = NO_TRANSFER;
d->issue_command(d, c); d->issue_command(d, c);
#ifdef Libburn_pioneer_dvr_216d_get_evenT #ifdef Libburn_pioneer_dvr_216d_get_evenT
mmc_get_event(d); mmc_get_event(d);
#endif #endif
ex:;
BURN_FREE_MEM(c);
} }
void spc_allow(struct burn_drive *d) void spc_allow(struct burn_drive *d)
{ {
struct command *c = NULL; struct command *c;
int ret;
c = &(d->casual_command);
if (mmc_function_spy(d, "allow") <= 0) if (mmc_function_spy(d, "allow") <= 0)
goto ex; return;
BURN_ALLOC_MEM(c, struct command, 1);
scsi_init_command(c, SPC_ALLOW, sizeof(SPC_ALLOW)); scsi_init_command(c, SPC_ALLOW, sizeof(SPC_ALLOW));
c->retry = 1; c->retry = 1;
c->dir = NO_TRANSFER; c->dir = NO_TRANSFER;
d->issue_command(d, c); d->issue_command(d, c);
ex:;
BURN_FREE_MEM(c);
} }
/* /*

View File

@ -301,6 +301,16 @@ struct burn_drive
struct buffer *buffer; struct buffer *buffer;
struct burn_progress progress; struct burn_progress progress;
/* To be used by mmc.c, sbc.c, spc.c for SCSI commands where the struct
content surely does not have to persist while another command gets
composed and executed.
(Inherently, sending SCSI commands to the same drive cannot be
thread-safe. But there are functions which send SCSI commands
and also call other such functions. These shall use own allocated
command structs and not this struct here.)
*/
struct command casual_command;
/* ts A70711 : keeping an eye on the drive buffer */ /* ts A70711 : keeping an eye on the drive buffer */
off_t pessimistic_buffer_free; off_t pessimistic_buffer_free;
int pbf_altered; int pbf_altered;