packet: fix error handling
[powerpc.git] / drivers / block / pktcdvd.c
index c0e8949..f1b9dd7 100644 (file)
@@ -435,7 +435,7 @@ static int pkt_debugfs_fops_open(struct inode *inode, struct file *file)
        return single_open(file, pkt_debugfs_seq_show, inode->i_private);
 }
 
-static struct file_operations debug_fops = {
+static const struct file_operations debug_fops = {
        .open           = pkt_debugfs_fops_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -765,7 +765,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
                        goto out;
        }
 
-       rq->cmd_len = COMMAND_SIZE(rq->cmd[0]);
+       rq->cmd_len = COMMAND_SIZE(cgc->cmd[0]);
        memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE);
        if (sizeof(rq->cmd) > CDROM_PACKET_SIZE)
                memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE);
@@ -777,7 +777,8 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
                rq->cmd_flags |= REQ_QUIET;
 
        blk_execute_rq(rq->q, pd->bdev->bd_disk, rq, 0);
-       ret = rq->errors;
+       if (rq->errors)
+               ret = -EIO;
 out:
        blk_put_request(rq);
        return ret;
@@ -2725,7 +2726,7 @@ static int pkt_seq_open(struct inode *inode, struct file *file)
        return single_open(file, pkt_seq_show, PDE(inode)->data);
 }
 
-static struct file_operations pkt_proc_fops = {
+static const struct file_operations pkt_proc_fops = {
        .open   = pkt_seq_open,
        .read   = seq_read,
        .llseek = seq_lseek,
@@ -3052,7 +3053,7 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
 }
 
 
-static struct file_operations pkt_ctl_fops = {
+static const struct file_operations pkt_ctl_fops = {
        .ioctl   = pkt_ctl_ioctl,
        .owner   = THIS_MODULE,
 };