提交 8c662852 编写于 作者: B Borislav Petkov 提交者: Bartlomiej Zolnierkiewicz

ide-atapi: compute cmd_len based on device type in ide_transfer_pc

There should be no functionality change resulting from this patch.
Signed-off-by: NBorislav Petkov <petkovbb@gmail.com>
[bart: move cmd_len check closer to ->output_data() call]
Signed-off-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
上级 5317464d
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#define debug_log(fmt, args...) do {} while (0) #define debug_log(fmt, args...) do {} while (0)
#endif #endif
#define ATAPI_MIN_CDB_BYTES 12
static inline int dev_is_idecd(ide_drive_t *drive) static inline int dev_is_idecd(ide_drive_t *drive)
{ {
return drive->media == ide_cdrom || drive->media == ide_optical; return drive->media == ide_cdrom || drive->media == ide_optical;
...@@ -492,6 +494,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) ...@@ -492,6 +494,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
struct request *rq = hwif->hwgroup->rq; struct request *rq = hwif->hwgroup->rq;
ide_expiry_t *expiry; ide_expiry_t *expiry;
unsigned int timeout; unsigned int timeout;
int cmd_len;
ide_startstop_t startstop; ide_startstop_t startstop;
u8 ireason; u8 ireason;
...@@ -513,9 +516,18 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) ...@@ -513,9 +516,18 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) { if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) {
printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing "
"a packet command\n", drive->name); "a packet command\n", drive->name);
return ide_do_reset(drive); return ide_do_reset(drive);
} }
if (dev_is_idecd(drive)) {
/* ATAPI commands get padded out to 12 bytes minimum */
cmd_len = COMMAND_SIZE(rq->cmd[0]);
if (cmd_len < ATAPI_MIN_CDB_BYTES)
cmd_len = ATAPI_MIN_CDB_BYTES;
} else
cmd_len = ATAPI_MIN_CDB_BYTES;
/* /*
* If necessary schedule the packet transfer to occur 'timeout' * If necessary schedule the packet transfer to occur 'timeout'
* miliseconds later in ide_delayed_transfer_pc() after the device * miliseconds later in ide_delayed_transfer_pc() after the device
...@@ -541,7 +553,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) ...@@ -541,7 +553,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
/* Send the actual packet */ /* Send the actual packet */
if ((drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) == 0) if ((drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) == 0)
hwif->tp_ops->output_data(drive, NULL, rq->cmd, 12); hwif->tp_ops->output_data(drive, NULL, rq->cmd, cmd_len);
return ide_started; return ide_started;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册