xsysace: simplify media change handling
authorChristoph Hellwig <hch@lst.de>
Tue, 8 Sep 2020 14:53:37 +0000 (16:53 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 10 Sep 2020 15:32:31 +0000 (09:32 -0600)
Pass a struct ace_device to ace_revalidate_disk, move the media changed
check into the one caller that needs it, and give the routine a better
name.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/xsysace.c

index eefe542..8d581c7 100644 (file)
@@ -888,26 +888,20 @@ static unsigned int ace_check_events(struct gendisk *gd, unsigned int clearing)
        return ace->media_change ? DISK_EVENT_MEDIA_CHANGE : 0;
 }
 
-static int ace_revalidate_disk(struct gendisk *gd)
+static void ace_media_changed(struct ace_device *ace)
 {
-       struct ace_device *ace = gd->private_data;
        unsigned long flags;
 
-       dev_dbg(ace->dev, "ace_revalidate_disk()\n");
-
-       if (ace->media_change) {
-               dev_dbg(ace->dev, "requesting cf id and scheduling tasklet\n");
+       dev_dbg(ace->dev, "requesting cf id and scheduling tasklet\n");
 
-               spin_lock_irqsave(&ace->lock, flags);
-               ace->id_req_count++;
-               spin_unlock_irqrestore(&ace->lock, flags);
+       spin_lock_irqsave(&ace->lock, flags);
+       ace->id_req_count++;
+       spin_unlock_irqrestore(&ace->lock, flags);
 
-               tasklet_schedule(&ace->fsm_tasklet);
-               wait_for_completion(&ace->id_completion);
-       }
+       tasklet_schedule(&ace->fsm_tasklet);
+       wait_for_completion(&ace->id_completion);
 
        dev_dbg(ace->dev, "revalidate complete\n");
-       return ace->id_result;
 }
 
 static int ace_open(struct block_device *bdev, fmode_t mode)
@@ -922,8 +916,8 @@ static int ace_open(struct block_device *bdev, fmode_t mode)
        ace->users++;
        spin_unlock_irqrestore(&ace->lock, flags);
 
-       if (bdev_check_media_change(bdev))
-               ace_revalidate_disk(bdev->bd_disk);
+       if (bdev_check_media_change(bdev) && ace->media_change)
+               ace_media_changed(ace);
        mutex_unlock(&xsysace_mutex);
 
        return 0;
@@ -1080,7 +1074,7 @@ static int ace_setup(struct ace_device *ace)
                (unsigned long long) ace->physaddr, ace->baseaddr, ace->irq);
 
        ace->media_change = 1;
-       ace_revalidate_disk(ace->gd);
+       ace_media_changed(ace);
 
        /* Make the sysace device 'live' */
        add_disk(ace->gd);