]> err.no Git - linux-2.6/blobdiff - drivers/block/pktcdvd.c
Pull cpuidle into release branch
[linux-2.6] / drivers / block / pktcdvd.c
index 31be33e4f119d5238bdc283b99e2e534133ddd9f..a5ee21319d37fa2633bd5625099fb429a5c353ca 100644 (file)
@@ -358,10 +358,19 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
                                        size_t count)
 {
        unsigned int major, minor;
+
        if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
+               /* pkt_setup_dev() expects caller to hold reference to self */
+               if (!try_module_get(THIS_MODULE))
+                       return -ENODEV;
+
                pkt_setup_dev(MKDEV(major, minor), NULL);
+
+               module_put(THIS_MODULE);
+
                return count;
        }
+
        return -EINVAL;
 }
 
@@ -752,7 +761,7 @@ static inline struct bio *pkt_get_list_first(struct bio **list_head, struct bio
  */
 static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *cgc)
 {
-       request_queue_t *q = bdev_get_queue(pd->bdev);
+       struct request_queue *q = bdev_get_queue(pd->bdev);
        struct request *rq;
        int ret = 0;
 
@@ -979,7 +988,7 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
  * Special care is needed if the underlying block device has a small
  * max_phys_segments value.
  */
-static int pkt_set_segment_merging(struct pktcdvd_device *pd, request_queue_t *q)
+static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_queue *q)
 {
        if ((pd->settings.size << 9) / CD_FRAMESIZE <= q->max_phys_segments) {
                /*
@@ -1058,15 +1067,12 @@ static void pkt_make_local_copy(struct packet_data *pkt, struct bio_vec *bvec)
        }
 }
 
-static int pkt_end_io_read(struct bio *bio, unsigned int bytes_done, int err)
+static void pkt_end_io_read(struct bio *bio, int err)
 {
        struct packet_data *pkt = bio->bi_private;
        struct pktcdvd_device *pd = pkt->pd;
        BUG_ON(!pd);
 
-       if (bio->bi_size)
-               return 1;
-
        VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio,
                (unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err);
 
@@ -1077,19 +1083,14 @@ static int pkt_end_io_read(struct bio *bio, unsigned int bytes_done, int err)
                wake_up(&pd->wqueue);
        }
        pkt_bio_finished(pd);
-
-       return 0;
 }
 
-static int pkt_end_io_packet_write(struct bio *bio, unsigned int bytes_done, int err)
+static void pkt_end_io_packet_write(struct bio *bio, int err)
 {
        struct packet_data *pkt = bio->bi_private;
        struct pktcdvd_device *pd = pkt->pd;
        BUG_ON(!pd);
 
-       if (bio->bi_size)
-               return 1;
-
        VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err);
 
        pd->stats.pkt_ended++;
@@ -1098,7 +1099,6 @@ static int pkt_end_io_packet_write(struct bio *bio, unsigned int bytes_done, int
        atomic_dec(&pkt->io_wait);
        atomic_inc(&pkt->run_sm);
        wake_up(&pd->wqueue);
-       return 0;
 }
 
 /*
@@ -1142,16 +1142,21 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
         * Schedule reads for missing parts of the packet.
         */
        for (f = 0; f < pkt->frames; f++) {
+               struct bio_vec *vec;
+
                int p, offset;
                if (written[f])
                        continue;
                bio = pkt->r_bios[f];
+               vec = bio->bi_io_vec;
                bio_init(bio);
                bio->bi_max_vecs = 1;
                bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9);
                bio->bi_bdev = pd->bdev;
                bio->bi_end_io = pkt_end_io_read;
                bio->bi_private = pkt;
+               bio->bi_io_vec = vec;
+               bio->bi_destructor = pkt_bio_destructor;
 
                p = (f * CD_FRAMESIZE) / PAGE_SIZE;
                offset = (f * CD_FRAMESIZE) % PAGE_SIZE;
@@ -1448,6 +1453,8 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
        pkt->w_bio->bi_bdev = pd->bdev;
        pkt->w_bio->bi_end_io = pkt_end_io_packet_write;
        pkt->w_bio->bi_private = pkt;
+       pkt->w_bio->bi_io_vec = bvec;
+       pkt->w_bio->bi_destructor = pkt_bio_destructor;
        for (f = 0; f < pkt->frames; f++)
                if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset))
                        BUG();
@@ -1470,7 +1477,7 @@ static void pkt_finish_packet(struct packet_data *pkt, int uptodate)
        while (bio) {
                next = bio->bi_next;
                bio->bi_next = NULL;
-               bio_endio(bio, bio->bi_size, uptodate ? 0 : -EIO);
+               bio_endio(bio, uptodate ? 0 : -EIO);
                bio = next;
        }
        pkt->orig_bios = pkt->orig_bios_tail = NULL;
@@ -2314,7 +2321,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write)
 {
        int ret;
        long lba;
-       request_queue_t *q;
+       struct request_queue *q;
 
        /*
         * We need to re-open the cdrom device without O_NONBLOCK to be able
@@ -2462,22 +2469,18 @@ static int pkt_close(struct inode *inode, struct file *file)
 }
 
 
-static int pkt_end_io_read_cloned(struct bio *bio, unsigned int bytes_done, int err)
+static void pkt_end_io_read_cloned(struct bio *bio, int err)
 {
        struct packet_stacked_data *psd = bio->bi_private;
        struct pktcdvd_device *pd = psd->pd;
 
-       if (bio->bi_size)
-               return 1;
-
        bio_put(bio);
-       bio_endio(psd->bio, psd->bio->bi_size, err);
+       bio_endio(psd->bio, err);
        mempool_free(psd, psd_pool);
        pkt_bio_finished(pd);
-       return 0;
 }
 
-static int pkt_make_request(request_queue_t *q, struct bio *bio)
+static int pkt_make_request(struct request_queue *q, struct bio *bio)
 {
        struct pktcdvd_device *pd;
        char b[BDEVNAME_SIZE];
@@ -2620,13 +2623,13 @@ static int pkt_make_request(request_queue_t *q, struct bio *bio)
        }
        return 0;
 end_io:
-       bio_io_error(bio, bio->bi_size);
+       bio_io_error(bio);
        return 0;
 }
 
 
 
-static int pkt_merge_bvec(request_queue_t *q, struct bio *bio, struct bio_vec *bvec)
+static int pkt_merge_bvec(struct request_queue *q, struct bio *bio, struct bio_vec *bvec)
 {
        struct pktcdvd_device *pd = q->queuedata;
        sector_t zone = ZONE(bio->bi_sector, pd);
@@ -2647,7 +2650,7 @@ static int pkt_merge_bvec(request_queue_t *q, struct bio *bio, struct bio_vec *b
 
 static void pkt_init_queue(struct pktcdvd_device *pd)
 {
-       request_queue_t *q = pd->disk->queue;
+       struct request_queue *q = pd->disk->queue;
 
        blk_queue_make_request(q, pkt_make_request);
        blk_queue_hardsect_size(q, CD_FRAMESIZE);