]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
gdrom,viocd: Convert to bdops->check_events()
authorTejun Heo <tj@kernel.org>
Wed, 9 Mar 2011 18:54:28 +0000 (19:54 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 3 Jun 2011 01:33:42 +0000 (10:33 +0900)
commit 1c27030bd21e7e2c68ef5be9f28c63778cf4b27f upstream.

Convert gdrom and viocd from ->media_changed() to ->check_events().

It's unclear how the conditions are cleared and it's possible that it
may generate spurious events when polled.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/cdrom/gdrom.c
drivers/cdrom/viocd.c

index 64a21461c408f9853d6c6199bc1ed9e38fb842ca..b2b034fea34e6b8eabf7054928e34bc4d6fc0e17 100644 (file)
@@ -395,10 +395,12 @@ static int gdrom_drivestatus(struct cdrom_device_info *cd_info, int ignore)
        return CDS_NO_INFO;
 }
 
-static int gdrom_mediachanged(struct cdrom_device_info *cd_info, int ignore)
+static unsigned int gdrom_check_events(struct cdrom_device_info *cd_info,
+                                      unsigned int clearing, int ignore)
 {
        /* check the sense key */
-       return (__raw_readb(GDROM_ERROR_REG) & 0xF0) == 0x60;
+       return (__raw_readb(GDROM_ERROR_REG) & 0xF0) == 0x60 ?
+               DISK_EVENT_MEDIA_CHANGE : 0;
 }
 
 /* reset the G1 bus */
@@ -483,7 +485,7 @@ static struct cdrom_device_ops gdrom_ops = {
        .open                   = gdrom_open,
        .release                = gdrom_release,
        .drive_status           = gdrom_drivestatus,
-       .media_changed          = gdrom_mediachanged,
+       .check_events           = gdrom_check_events,
        .get_last_session       = gdrom_get_last_session,
        .reset                  = gdrom_hardreset,
        .audio_ioctl            = gdrom_audio_ioctl,
@@ -509,9 +511,10 @@ static int gdrom_bdops_release(struct gendisk *disk, fmode_t mode)
        return 0;
 }
 
-static int gdrom_bdops_mediachanged(struct gendisk *disk)
+static unsigned int gdrom_bdops_check_events(struct gendisk *disk,
+                                            unsigned int clearing)
 {
-       return cdrom_media_changed(gd.cd_info);
+       return cdrom_check_events(gd.cd_info, clearing);
 }
 
 static int gdrom_bdops_ioctl(struct block_device *bdev, fmode_t mode,
@@ -530,7 +533,7 @@ static const struct block_device_operations gdrom_bdops = {
        .owner                  = THIS_MODULE,
        .open                   = gdrom_bdops_open,
        .release                = gdrom_bdops_release,
-       .media_changed          = gdrom_bdops_mediachanged,
+       .check_events           = gdrom_bdops_check_events,
        .ioctl                  = gdrom_bdops_ioctl,
 };
 
@@ -800,6 +803,7 @@ static int __devinit probe_gdrom(struct platform_device *devptr)
                goto probe_fail_cdrom_register;
        }
        gd.disk->fops = &gdrom_bdops;
+       gd.disk->events = DISK_EVENT_MEDIA_CHANGE;
        /* latch on to the interrupt */
        err = gdrom_set_interrupt_handlers();
        if (err)
index be73a9b493a69970135663ffd4ed7a83cb568cb9..4e874c5fa60595036a7e10b26257384715b06b56 100644 (file)
@@ -186,10 +186,11 @@ static int viocd_blk_ioctl(struct block_device *bdev, fmode_t mode,
        return ret;
 }
 
-static int viocd_blk_media_changed(struct gendisk *disk)
+static unsigned int viocd_blk_check_events(struct gendisk *disk,
+                                          unsigned int clearing)
 {
        struct disk_info *di = disk->private_data;
-       return cdrom_media_changed(&di->viocd_info);
+       return cdrom_check_events(&di->viocd_info, clearing);
 }
 
 static const struct block_device_operations viocd_fops = {
@@ -197,7 +198,7 @@ static const struct block_device_operations viocd_fops = {
        .open =                 viocd_blk_open,
        .release =              viocd_blk_release,
        .ioctl =                viocd_blk_ioctl,
-       .media_changed =        viocd_blk_media_changed,
+       .check_events =         viocd_blk_check_events,
 };
 
 static int viocd_open(struct cdrom_device_info *cdi, int purpose)
@@ -320,7 +321,8 @@ static void do_viocd_request(struct request_queue *q)
        }
 }
 
-static int viocd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
+static unsigned int viocd_check_events(struct cdrom_device_info *cdi,
+                                      unsigned int clearing, int disc_nr)
 {
        struct viocd_waitevent we;
        HvLpEvent_Rc hvrc;
@@ -340,7 +342,7 @@ static int viocd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
        if (hvrc != 0) {
                pr_warning("bad rc on HvCallEvent_signalLpEventFast %d\n",
                           (int)hvrc);
-               return -EIO;
+               return 0;
        }
 
        wait_for_completion(&we.com);
@@ -354,7 +356,7 @@ static int viocd_media_changed(struct cdrom_device_info *cdi, int disc_nr)
                return 0;
        }
 
-       return we.changed;
+       return we.changed ? DISK_EVENT_MEDIA_CHANGE : 0;
 }
 
 static int viocd_lock_door(struct cdrom_device_info *cdi, int locking)
@@ -550,7 +552,7 @@ static int viocd_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
 static struct cdrom_device_ops viocd_dops = {
        .open = viocd_open,
        .release = viocd_release,
-       .media_changed = viocd_media_changed,
+       .check_events = viocd_check_events,
        .lock_door = viocd_lock_door,
        .generic_packet = viocd_packet,
        .audio_ioctl = viocd_audio_ioctl,
@@ -624,6 +626,7 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id)
        gendisk->queue = q;
        gendisk->fops = &viocd_fops;
        gendisk->flags = GENHD_FL_CD|GENHD_FL_REMOVABLE;
+       gendisk->events = DISK_EVENT_MEDIA_CHANGE;
        set_capacity(gendisk, 0);
        gendisk->private_data = d;
        d->viocd_disk = gendisk;