Commit aaa7c015 authored by Tejun Heo's avatar Tejun Heo

ub: Convert to bdops->check_events()

Convert from ->media_changed() to ->check_events().

ub buffers media changed state and clears it on revalidation.  It will
behave correctly with kernel event polling.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Pete Zaitcev <zaitcev@redhat.com>
parent 4bbde777
...@@ -1788,7 +1788,8 @@ static int ub_bd_revalidate(struct gendisk *disk) ...@@ -1788,7 +1788,8 @@ static int ub_bd_revalidate(struct gendisk *disk)
* *
* The return code is bool! * The return code is bool!
*/ */
static int ub_bd_media_changed(struct gendisk *disk) static unsigned int ub_bd_check_events(struct gendisk *disk,
unsigned int clearing)
{ {
struct ub_lun *lun = disk->private_data; struct ub_lun *lun = disk->private_data;
...@@ -1806,10 +1807,10 @@ static int ub_bd_media_changed(struct gendisk *disk) ...@@ -1806,10 +1807,10 @@ static int ub_bd_media_changed(struct gendisk *disk)
*/ */
if (ub_sync_tur(lun->udev, lun) != 0) { if (ub_sync_tur(lun->udev, lun) != 0) {
lun->changed = 1; lun->changed = 1;
return 1; return DISK_EVENT_MEDIA_CHANGE;
} }
return lun->changed; return lun->changed ? DISK_EVENT_MEDIA_CHANGE : 0;
} }
static const struct block_device_operations ub_bd_fops = { static const struct block_device_operations ub_bd_fops = {
...@@ -1817,7 +1818,7 @@ static const struct block_device_operations ub_bd_fops = { ...@@ -1817,7 +1818,7 @@ static const struct block_device_operations ub_bd_fops = {
.open = ub_bd_unlocked_open, .open = ub_bd_unlocked_open,
.release = ub_bd_release, .release = ub_bd_release,
.ioctl = ub_bd_ioctl, .ioctl = ub_bd_ioctl,
.media_changed = ub_bd_media_changed, .check_events = ub_bd_check_events,
.revalidate_disk = ub_bd_revalidate, .revalidate_disk = ub_bd_revalidate,
}; };
...@@ -2333,6 +2334,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum) ...@@ -2333,6 +2334,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum)
disk->major = UB_MAJOR; disk->major = UB_MAJOR;
disk->first_minor = lun->id * UB_PARTS_PER_LUN; disk->first_minor = lun->id * UB_PARTS_PER_LUN;
disk->fops = &ub_bd_fops; disk->fops = &ub_bd_fops;
disk->events = DISK_EVENT_MEDIA_CHANGE;
disk->private_data = lun; disk->private_data = lun;
disk->driverfs_dev = &sc->intf->dev; disk->driverfs_dev = &sc->intf->dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment