ACPI: sbs: remove I2C Makefile hooks
[safe/jmp/linux-2.6] / drivers / cdrom / viocd.c
index 36f31d2..44cd7b2 100644 (file)
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 
-#include <asm/bug.h>
-
 #include <asm/vio.h>
 #include <asm/scatterlist.h>
-#include <asm/iSeries/HvTypes.h>
-#include <asm/iSeries/HvLpEvent.h>
-#include <asm/iSeries/vio.h>
+#include <asm/iseries/hv_types.h>
+#include <asm/iseries/hv_lp_event.h>
+#include <asm/iseries/vio.h>
+#include <asm/firmware.h>
 
 #define VIOCD_DEVICE                   "iseries/vcd"
-#define VIOCD_DEVICE_DEVFS             "iseries/vcd"
 
 #define VIOCD_VERS "1.06"
 
@@ -178,7 +176,7 @@ static int proc_viocd_open(struct inode *inode, struct file *file)
        return single_open(file, proc_viocd_show, NULL);
 }
 
-static struct file_operations proc_viocd_operations = {
+static const struct file_operations proc_viocd_operations = {
        .open           = proc_viocd_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -378,6 +376,25 @@ static int send_request(struct request *req)
        return 0;
 }
 
+static void viocd_end_request(struct request *req, int uptodate)
+{
+       int nsectors = req->hard_nr_sectors;
+
+       /*
+        * Make sure it's fully ended, and ensure that we process
+        * at least one sector.
+        */
+       if (blk_pc_request(req))
+               nsectors = (req->data_len + 511) >> 9;
+       if (!nsectors)
+               nsectors = 1;
+
+       if (end_that_request_first(req, uptodate, nsectors))
+               BUG();
+       add_disk_randomness(req->rq_disk);
+       blkdev_dequeue_request(req);
+       end_that_request_last(req, uptodate);
+}
 
 static int rwreq;
 
@@ -387,11 +404,11 @@ static void do_viocd_request(request_queue_t *q)
 
        while ((rwreq == 0) && ((req = elv_next_request(q)) != NULL)) {
                if (!blk_fs_request(req))
-                       end_request(req, 0);
+                       viocd_end_request(req, 0);
                else if (send_request(req) < 0) {
                        printk(VIOCD_KERN_WARNING
                                        "unable to send message to OS/400!");
-                       end_request(req, 0);
+                       viocd_end_request(req, 0);
                } else
                        rwreq++;
        }
@@ -542,10 +559,10 @@ static void vio_handle_cd_event(struct HvLpEvent *event)
                /* Notification that a partition went away! */
                return;
        /* First, we should NEVER get an int here...only acks */
-       if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
+       if (hvlpevent_is_int(event)) {
                printk(VIOCD_KERN_WARNING
                                "Yikes! got an int in viocd event handler!\n");
-               if (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck) {
+               if (hvlpevent_need_ack(event)) {
                        event->xRc = HvLpEvent_Rc_InvalidSubtype;
                        HvCallEvent_ackLpEvent(event);
                }
@@ -603,9 +620,9 @@ return_complete:
                                        "with rc %d:0x%04X: %s\n",
                                        req, event->xRc,
                                        bevent->sub_result, err->msg);
-                       end_request(req, 0);
+                       viocd_end_request(req, 0);
                } else
-                       end_request(req, 1);
+                       viocd_end_request(req, 1);
 
                /* restart handling of incoming requests */
                spin_unlock_irqrestore(&viocd_reqlock, flags);
@@ -616,7 +633,7 @@ return_complete:
                printk(VIOCD_KERN_WARNING
                                "message with invalid subtype %0x04X!\n",
                                event->xSubtype & VIOMINOR_SUBTYPE_MASK);
-               if (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck) {
+               if (hvlpevent_need_ack(event)) {
                        event->xRc = HvLpEvent_Rc_InvalidSubtype;
                        HvCallEvent_ackLpEvent(event);
                }
@@ -629,7 +646,7 @@ static struct cdrom_device_ops viocd_dops = {
        .media_changed = viocd_media_changed,
        .lock_door = viocd_lock_door,
        .generic_packet = viocd_packet,
-       .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM
+       .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM
 };
 
 static int __init find_capability(const char *type)
@@ -690,8 +707,6 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id)
        gendisk->first_minor = deviceno;
        strncpy(gendisk->disk_name, c->name,
                        sizeof(gendisk->disk_name));
-       snprintf(gendisk->devfs_name, sizeof(gendisk->devfs_name),
-                       VIOCD_DEVICE_DEVFS "%d", deviceno);
        blk_queue_max_hw_segments(q, 1);
        blk_queue_max_phys_segments(q, 1);
        blk_queue_max_sectors(q, 4096 / 512);
@@ -733,7 +748,7 @@ static int viocd_remove(struct vio_dev *vdev)
  * support.
  */
 static struct vio_device_id viocd_device_table[] __devinitdata = {
-       { "viocd", "" },
+       { "block", "IBM,iSeries-viocd" },
        { "", "" }
 };
 MODULE_DEVICE_TABLE(vio, viocd_device_table);
@@ -753,6 +768,9 @@ static int __init viocd_init(void)
        struct proc_dir_entry *e;
        int ret = 0;
 
+       if (!firmware_has_feature(FW_FEATURE_ISERIES))
+               return -ENODEV;
+
        if (viopath_hostLp == HvLpIndexInvalid) {
                vio_set_hostlp();
                /* If we don't have a host, bail out */