]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/block/paride/pf.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/viro/bdev
[linux-2.6-omap-h63xx.git] / drivers / block / paride / pf.c
index ceffa6034e2044f81340a3fadb2241f9053d0abf..bef3b997ba3e39d11b85917b31b20f6e96a27f1c 100644 (file)
@@ -201,13 +201,13 @@ module_param_array(drive3, int, NULL, 0);
 #define ATAPI_READ_10          0x28
 #define ATAPI_WRITE_10         0x2a
 
-static int pf_open(struct inode *inode, struct file *file);
+static int pf_open(struct block_device *bdev, fmode_t mode);
 static void do_pf_request(struct request_queue * q);
-static int pf_ioctl(struct inode *inode, struct file *file,
+static int pf_ioctl(struct block_device *bdev, fmode_t mode,
                    unsigned int cmd, unsigned long arg);
 static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo);
 
-static int pf_release(struct inode *inode, struct file *file);
+static int pf_release(struct gendisk *disk, fmode_t mode);
 
 static int pf_detect(void);
 static void do_pf_read(void);
@@ -266,7 +266,7 @@ static struct block_device_operations pf_fops = {
        .owner          = THIS_MODULE,
        .open           = pf_open,
        .release        = pf_release,
-       .ioctl          = pf_ioctl,
+       .locked_ioctl   = pf_ioctl,
        .getgeo         = pf_getgeo,
        .media_changed  = pf_check_media,
 };
@@ -296,16 +296,16 @@ static void __init pf_init_units(void)
        }
 }
 
-static int pf_open(struct inode *inode, struct file *file)
+static int pf_open(struct block_device *bdev, fmode_t mode)
 {
-       struct pf_unit *pf = inode->i_bdev->bd_disk->private_data;
+       struct pf_unit *pf = bdev->bd_disk->private_data;
 
        pf_identify(pf);
 
        if (pf->media_status == PF_NM)
                return -ENODEV;
 
-       if ((pf->media_status == PF_RO) && (file->f_mode & 2))
+       if ((pf->media_status == PF_RO) && (mode & FMODE_WRITE))
                return -EROFS;
 
        pf->access++;
@@ -333,9 +333,9 @@ static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo)
        return 0;
 }
 
-static int pf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static int pf_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
 {
-       struct pf_unit *pf = inode->i_bdev->bd_disk->private_data;
+       struct pf_unit *pf = bdev->bd_disk->private_data;
 
        if (cmd != CDROMEJECT)
                return -EINVAL;
@@ -346,9 +346,9 @@ static int pf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
        return 0;
 }
 
-static int pf_release(struct inode *inode, struct file *file)
+static int pf_release(struct gendisk *disk, fmode_t mode)
 {
-       struct pf_unit *pf = inode->i_bdev->bd_disk->private_data;
+       struct pf_unit *pf = disk->private_data;
 
        if (pf->access <= 0)
                return -EINVAL;
@@ -488,13 +488,11 @@ static int pf_atapi(struct pf_unit *pf, char *cmd, int dlen, char *buf, char *fu
        return r;
 }
 
-#define DBMSG(msg)      ((verbose>1)?(msg):NULL)
-
 static void pf_lock(struct pf_unit *pf, int func)
 {
        char lo_cmd[12] = { ATAPI_LOCK, pf->lun << 5, 0, 0, func, 0, 0, 0, 0, 0, 0, 0 };
 
-       pf_atapi(pf, lo_cmd, 0, pf_scratch, func ? "unlock" : "lock");
+       pf_atapi(pf, lo_cmd, 0, pf_scratch, func ? "lock" : "unlock");
 }
 
 static void pf_eject(struct pf_unit *pf)
@@ -555,7 +553,7 @@ static void pf_mode_sense(struct pf_unit *pf)
            { ATAPI_MODE_SENSE, pf->lun << 5, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0 };
        char buf[8];
 
-       pf_atapi(pf, ms_cmd, 8, buf, DBMSG("mode sense"));
+       pf_atapi(pf, ms_cmd, 8, buf, "mode sense");
        pf->media_status = PF_RW;
        if (buf[3] & 0x80)
                pf->media_status = PF_RO;
@@ -591,7 +589,7 @@ static void pf_get_capacity(struct pf_unit *pf)
        char buf[8];
        int bs;
 
-       if (pf_atapi(pf, rc_cmd, 8, buf, DBMSG("get capacity"))) {
+       if (pf_atapi(pf, rc_cmd, 8, buf, "get capacity")) {
                pf->media_status = PF_NM;
                return;
        }
@@ -804,13 +802,18 @@ static int pf_next_buf(void)
        pf_buf += 512;
        pf_block++;
        if (!pf_run)
-               return 0;
-       if (!pf_count)
                return 1;
-       spin_lock_irqsave(&pf_spin_lock, saved_flags);
-       pf_end_request(1);
-       spin_unlock_irqrestore(&pf_spin_lock, saved_flags);
-       return 1;
+       if (!pf_count) {
+               spin_lock_irqsave(&pf_spin_lock, saved_flags);
+               pf_end_request(1);
+               pf_req = elv_next_request(pf_queue);
+               spin_unlock_irqrestore(&pf_spin_lock, saved_flags);
+               if (!pf_req)
+                       return 1;
+               pf_count = pf_req->current_nr_sectors;
+               pf_buf = pf_req->buffer;
+       }
+       return 0;
 }
 
 static inline void next_request(int success)