Skip to content

Commit

Permalink
xsysace: simplify media change handling
Browse files Browse the repository at this point in the history
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>
Christoph Hellwig authored and Jens Axboe committed Sep 10, 2020
1 parent f094225 commit 77f93bf
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions drivers/block/xsysace.c
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 77f93bf

Please sign in to comment.