Commit 3c0d73d2 authored by Jens Axboe's avatar Jens Axboe Committed by Linus Torvalds

[PATCH] cdrom generic_packet oops fix

Add dummy ->generic_packet() for devices that don't provide one.  It will
error all commands with "unknown opcode" 0x05/0x20/0x00 sense and return
-EIO.
Signed-off-by: default avatarJens Axboe <axboe@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d3e54058
...@@ -354,6 +354,19 @@ static void cdrom_sysctl_register(void); ...@@ -354,6 +354,19 @@ static void cdrom_sysctl_register(void);
#endif /* CONFIG_SYSCTL */ #endif /* CONFIG_SYSCTL */
static struct cdrom_device_info *topCdromPtr; static struct cdrom_device_info *topCdromPtr;
static int cdrom_dummy_generic_packet(struct cdrom_device_info *cdi,
struct packet_command *cgc)
{
if (cgc->sense) {
cgc->sense->sense_key = 0x05;
cgc->sense->asc = 0x20;
cgc->sense->ascq = 0x00;
}
cgc->stat = -EIO;
return -EIO;
}
/* This macro makes sure we don't have to check on cdrom_device_ops /* This macro makes sure we don't have to check on cdrom_device_ops
* existence in the run-time routines below. Change_capability is a * existence in the run-time routines below. Change_capability is a
* hack to have the capability flags defined const, while we can still * hack to have the capability flags defined const, while we can still
...@@ -411,6 +424,9 @@ int register_cdrom(struct cdrom_device_info *cdi) ...@@ -411,6 +424,9 @@ int register_cdrom(struct cdrom_device_info *cdi)
else else
cdi->cdda_method = CDDA_OLD; cdi->cdda_method = CDDA_OLD;
if (!cdo->generic_packet)
cdo->generic_packet = cdrom_dummy_generic_packet;
cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name); cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
spin_lock(&cdrom_lock); spin_lock(&cdrom_lock);
cdi->next = topCdromPtr; cdi->next = topCdromPtr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment