V4L/DVB (11026): sh-mobile-ceu-camera: set field to the value, configured at open()
[safe/jmp/linux-2.6] / drivers / message / i2o / i2o_block.c
index b09fb63..a443e13 100644 (file)
@@ -149,29 +149,6 @@ static int i2o_block_device_flush(struct i2o_device *dev)
 };
 
 /**
- *     i2o_block_issue_flush - device-flush interface for block-layer
- *     @queue: the request queue of the device which should be flushed
- *     @disk: gendisk
- *     @error_sector: error offset
- *
- *     Helper function to provide flush functionality to block-layer.
- *
- *     Returns 0 on success or negative error code on failure.
- */
-
-static int i2o_block_issue_flush(request_queue_t * queue, struct gendisk *disk,
-                                sector_t * error_sector)
-{
-       struct i2o_block_device *i2o_blk_dev = queue->queuedata;
-       int rc = -ENODEV;
-
-       if (likely(i2o_blk_dev))
-               rc = i2o_block_device_flush(i2o_blk_dev->i2o_dev);
-
-       return rc;
-}
-
-/**
  *     i2o_block_device_mount - Mount (load) the media of device dev
  *     @dev: I2O device which should receive the mount request
  *     @media_id: Media Identifier
@@ -215,7 +192,7 @@ static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id)
        struct i2o_message *msg;
 
        msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
-       if (IS_ERR(msg) == I2O_QUEUE_EMPTY)
+       if (IS_ERR(msg))
                return PTR_ERR(msg);
 
        msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
@@ -259,7 +236,7 @@ static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id)
 /**
  *     i2o_block_device_power - Power management for device dev
  *     @dev: I2O device which should receive the power management request
- *     @operation: Operation which should be send
+ *     @op: Operation to send
  *
  *     Send a power management request to the device dev.
  *
@@ -307,6 +284,7 @@ static inline struct i2o_block_request *i2o_block_request_alloc(void)
                return ERR_PTR(-ENOMEM);
 
        INIT_LIST_HEAD(&ireq->queue);
+       sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS);
 
        return ireq;
 };
@@ -315,7 +293,7 @@ static inline struct i2o_block_request *i2o_block_request_alloc(void)
  *     i2o_block_request_free - Frees a I2O block request
  *     @ireq: I2O block request which should be freed
  *
- *     Fres the allocated memory (give it back to the request mempool).
+ *     Frees the allocated memory (give it back to the request mempool).
  */
 static inline void i2o_block_request_free(struct i2o_block_request *ireq)
 {
@@ -326,6 +304,7 @@ static inline void i2o_block_request_free(struct i2o_block_request *ireq)
  *     i2o_block_sglist_alloc - Allocate the SG list and map it
  *     @c: I2O controller to which the request belongs
  *     @ireq: I2O block request
+ *     @mptr: message body pointer
  *
  *     Builds the SG list and map it to be accessable by the controller.
  *
@@ -375,7 +354,7 @@ static inline void i2o_block_sglist_free(struct i2o_block_request *ireq)
  *     @req: the request to prepare
  *
  *     Allocate the necessary i2o_block_request struct and connect it to
- *     the request. This is needed that we not loose the SG list later on.
+ *     the request. This is needed that we not lose the SG list later on.
  *
  *     Returns BLKPREP_OK on success or BLKPREP_DEFER on failure.
  */
@@ -389,17 +368,10 @@ static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req)
                return BLKPREP_KILL;
        }
 
-       /* request is already processed by us, so return */
-       if (req->flags & REQ_SPECIAL) {
-               osm_debug("REQ_SPECIAL already set!\n");
-               req->flags |= REQ_DONTPREP;
-               return BLKPREP_OK;
-       }
-
        /* connect the i2o_block_request to the request */
        if (!req->special) {
                ireq = i2o_block_request_alloc();
-               if (unlikely(IS_ERR(ireq))) {
+               if (IS_ERR(ireq)) {
                        osm_debug("unable to allocate i2o_block_request!\n");
                        return BLKPREP_DEFER;
                }
@@ -407,27 +379,27 @@ static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req)
                ireq->i2o_blk_dev = i2o_blk_dev;
                req->special = ireq;
                ireq->req = req;
-       } else
-               ireq = req->special;
-
+       }
        /* do not come back here */
-       req->flags |= REQ_DONTPREP | REQ_SPECIAL;
+       req->cmd_flags |= REQ_DONTPREP;
 
        return BLKPREP_OK;
 };
 
 /**
  *     i2o_block_delayed_request_fn - delayed request queue function
- *     delayed_request: the delayed request with the queue to start
+ *     @work: the delayed request with the queue to start
  *
  *     If the request queue is stopped for a disk, and there is no open
  *     request, a new event is created, which calls this function to start
  *     the queue after I2O_BLOCK_REQUEST_TIME. Otherwise the queue will never
  *     be started again.
  */
-static void i2o_block_delayed_request_fn(void *delayed_request)
+static void i2o_block_delayed_request_fn(struct work_struct *work)
 {
-       struct i2o_block_delayed_request *dreq = delayed_request;
+       struct i2o_block_delayed_request *dreq =
+               container_of(work, struct i2o_block_delayed_request,
+                            work.work);
        struct request_queue *q = dreq->queue;
        unsigned long flags;
 
@@ -440,36 +412,32 @@ static void i2o_block_delayed_request_fn(void *delayed_request)
 /**
  *     i2o_block_end_request - Post-processing of completed commands
  *     @req: request which should be completed
- *     @uptodate: 1 for success, 0 for I/O error, < 0 for specific error
+ *     @error: 0 for success, < 0 for error
  *     @nr_bytes: number of bytes to complete
  *
  *     Mark the request as complete. The lock must not be held when entering.
  *
  */
-static void i2o_block_end_request(struct request *req, int uptodate,
+static void i2o_block_end_request(struct request *req, int error,
                                  int nr_bytes)
 {
        struct i2o_block_request *ireq = req->special;
        struct i2o_block_device *dev = ireq->i2o_blk_dev;
-       request_queue_t *q = req->q;
+       struct request_queue *q = req->q;
        unsigned long flags;
 
-       if (end_that_request_chunk(req, uptodate, nr_bytes)) {
+       if (blk_end_request(req, error, nr_bytes)) {
                int leftover = (req->hard_nr_sectors << KERNEL_SECTOR_SHIFT);
 
                if (blk_pc_request(req))
                        leftover = req->data_len;
 
-               if (end_io_error(uptodate))
-                       end_that_request_chunk(req, 0, leftover);
+               if (error)
+                       blk_end_request(req, -EIO, leftover);
        }
 
-       add_disk_randomness(req->rq_disk);
-
        spin_lock_irqsave(q->queue_lock, flags);
 
-       end_that_request_last(req, uptodate);
-
        if (likely(dev)) {
                dev->open_queue_depth--;
                list_del(&ireq->queue);
@@ -487,7 +455,7 @@ static void i2o_block_end_request(struct request *req, int uptodate,
  *     i2o_block_reply - Block OSM reply handler.
  *     @c: I2O controller from which the message arrives
  *     @m: message id of reply
- *     qmsg: the actuall I2O message reply
+ *     @msg: the actual I2O message reply
  *
  *     This function gets all the message replies.
  *
@@ -496,7 +464,7 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m,
                           struct i2o_message *msg)
 {
        struct request *req;
-       int uptodate = 1;
+       int error = 0;
 
        req = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt));
        if (unlikely(!req)) {
@@ -529,16 +497,17 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m,
 
                req->errors++;
 
-               uptodate = 0;
+               error = -EIO;
        }
 
-       i2o_block_end_request(req, uptodate, le32_to_cpu(msg->body[1]));
+       i2o_block_end_request(req, error, le32_to_cpu(msg->body[1]));
 
        return 1;
 };
 
-static void i2o_block_event(struct i2o_event *evt)
+static void i2o_block_event(struct work_struct *work)
 {
+       struct i2o_event *evt = container_of(work, struct i2o_event, work);
        osm_debug("event received\n");
        kfree(evt);
 };
@@ -598,15 +567,17 @@ static void i2o_block_biosparam(unsigned long capacity, unsigned short *cyls,
 
 /**
  *     i2o_block_open - Open the block device
+ *     @bdev: block device being opened
+ *     @mode: file open mode
  *
  *     Power up the device, mount and lock the media. This function is called,
  *     if the block device is opened for access.
  *
  *     Returns 0 on success or negative error code on failure.
  */
-static int i2o_block_open(struct inode *inode, struct file *file)
+static int i2o_block_open(struct block_device *bdev, fmode_t mode)
 {
-       struct i2o_block_device *dev = inode->i_bdev->bd_disk->private_data;
+       struct i2o_block_device *dev = bdev->bd_disk->private_data;
 
        if (!dev->i2o_dev)
                return -ENODEV;
@@ -625,15 +596,16 @@ static int i2o_block_open(struct inode *inode, struct file *file)
 
 /**
  *     i2o_block_release - Release the I2O block device
+ *     @disk: gendisk device being released
+ *     @mode: file open mode
  *
  *     Unlock and unmount the media, and power down the device. Gets called if
  *     the block device is closed.
  *
  *     Returns 0 on success or negative error code on failure.
  */
-static int i2o_block_release(struct inode *inode, struct file *file)
+static int i2o_block_release(struct gendisk *disk, fmode_t mode)
 {
-       struct gendisk *disk = inode->i_bdev->bd_disk;
        struct i2o_block_device *dev = disk->private_data;
        u8 operation;
 
@@ -671,6 +643,8 @@ static int i2o_block_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 
 /**
  *     i2o_block_ioctl - Issue device specific ioctl calls.
+ *     @bdev: block device being opened
+ *     @mode: file open mode
  *     @cmd: ioctl command
  *     @arg: arg
  *
@@ -678,10 +652,10 @@ static int i2o_block_getgeo(struct block_device *bdev, struct hd_geometry *geo)
  *
  *     Return 0 on success or negative error on failure.
  */
-static int i2o_block_ioctl(struct inode *inode, struct file *file,
+static int i2o_block_ioctl(struct block_device *bdev, fmode_t mode,
                           unsigned int cmd, unsigned long arg)
 {
-       struct gendisk *disk = inode->i_bdev->bd_disk;
+       struct gendisk *disk = bdev->bd_disk;
        struct i2o_block_device *dev = disk->private_data;
 
        /* Anyone capable of this syscall can do *real bad* things */
@@ -743,7 +717,7 @@ static int i2o_block_transfer(struct request *req)
 {
        struct i2o_block_device *dev = req->rq_disk->private_data;
        struct i2o_controller *c;
-       int tid = dev->i2o_dev->lct_data.tid;
+       u32 tid = dev->i2o_dev->lct_data.tid;
        struct i2o_message *msg;
        u32 *mptr;
        struct i2o_block_request *ireq = req->special;
@@ -898,7 +872,7 @@ static int i2o_block_transfer(struct request *req)
 
 /**
  *     i2o_block_request_fn - request queue handling function
- *     q: request queue from which the request could be fetched
+ *     @q: request queue from which the request could be fetched
  *
  *     Takes the next request from the queue, transfers it and if no error
  *     occurs dequeue it from the queue. On arrival of the reply the message
@@ -937,8 +911,8 @@ static void i2o_block_request_fn(struct request_queue *q)
                                continue;
 
                        dreq->queue = q;
-                       INIT_WORK(&dreq->work, i2o_block_delayed_request_fn,
-                                 dreq);
+                       INIT_DELAYED_WORK(&dreq->work,
+                                         i2o_block_delayed_request_fn);
 
                        if (!queue_delayed_work(i2o_block_driver.event_queue,
                                                &dreq->work,
@@ -958,7 +932,7 @@ static struct block_device_operations i2o_block_fops = {
        .owner = THIS_MODULE,
        .open = i2o_block_open,
        .release = i2o_block_release,
-       .ioctl = i2o_block_ioctl,
+       .locked_ioctl = i2o_block_ioctl,
        .getgeo = i2o_block_getgeo,
        .media_changed = i2o_block_media_changed
 };
@@ -1008,7 +982,6 @@ static struct i2o_block_device *i2o_block_device_alloc(void)
        }
 
        blk_queue_prep_rq(queue, i2o_block_prep_req_fn);
-       blk_queue_issue_flush_fn(queue, i2o_block_issue_flush);
 
        gd->major = I2O_MAJOR;
        gd->queue = queue;
@@ -1089,7 +1062,6 @@ static int i2o_block_probe(struct device *dev)
        gd = i2o_blk_dev->gd;
        gd->first_minor = unit << 4;
        sprintf(gd->disk_name, "i2o/hd%c", 'a' + unit);
-       sprintf(gd->devfs_name, "i2o/hd%c", 'a' + unit);
        gd->driverfs_dev = &i2o_dev->device;
 
        /* setup request queue */
@@ -1100,8 +1072,8 @@ static int i2o_block_probe(struct device *dev)
        blk_queue_max_sectors(queue, max_sectors);
        blk_queue_max_hw_segments(queue, i2o_sg_tablesize(c, body_size));
 
-       osm_debug("max sectors = %d\n", queue->max_phys_segments);
-       osm_debug("phys segments = %d\n", queue->max_sectors);
+       osm_debug("max sectors = %d\n", queue->max_sectors);
+       osm_debug("phys segments = %d\n", queue->max_phys_segments);
        osm_debug("max hw segments = %d\n", queue->max_hw_segments);
 
        /*
@@ -1171,18 +1143,16 @@ static int __init i2o_block_init(void)
        /* Allocate request mempool and slab */
        size = sizeof(struct i2o_block_request);
        i2o_blk_req_pool.slab = kmem_cache_create("i2o_block_req", size, 0,
-                                                 SLAB_HWCACHE_ALIGN, NULL,
-                                                 NULL);
+                                                 SLAB_HWCACHE_ALIGN, NULL);
        if (!i2o_blk_req_pool.slab) {
                osm_err("can't init request slab\n");
                rc = -ENOMEM;
                goto exit;
        }
 
-       i2o_blk_req_pool.pool = mempool_create(I2O_BLOCK_REQ_MEMPOOL_SIZE,
-                                              mempool_alloc_slab,
-                                              mempool_free_slab,
-                                              i2o_blk_req_pool.slab);
+       i2o_blk_req_pool.pool =
+               mempool_create_slab_pool(I2O_BLOCK_REQ_MEMPOOL_SIZE,
+                                        i2o_blk_req_pool.slab);
        if (!i2o_blk_req_pool.pool) {
                osm_err("can't init request mempool\n");
                rc = -ENOMEM;