mirror of https://gitee.com/openkylin/linux.git
xsysace: simplify media change handling
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>
This commit is contained in:
parent
f094225bfc
commit
77f93bfd0c
|
@ -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;
|
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;
|
unsigned long flags;
|
||||||
|
|
||||||
dev_dbg(ace->dev, "ace_revalidate_disk()\n");
|
dev_dbg(ace->dev, "requesting cf id and scheduling tasklet\n");
|
||||||
|
|
||||||
if (ace->media_change) {
|
spin_lock_irqsave(&ace->lock, flags);
|
||||||
dev_dbg(ace->dev, "requesting cf id and scheduling tasklet\n");
|
ace->id_req_count++;
|
||||||
|
spin_unlock_irqrestore(&ace->lock, flags);
|
||||||
|
|
||||||
spin_lock_irqsave(&ace->lock, flags);
|
tasklet_schedule(&ace->fsm_tasklet);
|
||||||
ace->id_req_count++;
|
wait_for_completion(&ace->id_completion);
|
||||||
spin_unlock_irqrestore(&ace->lock, flags);
|
|
||||||
|
|
||||||
tasklet_schedule(&ace->fsm_tasklet);
|
|
||||||
wait_for_completion(&ace->id_completion);
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_dbg(ace->dev, "revalidate complete\n");
|
dev_dbg(ace->dev, "revalidate complete\n");
|
||||||
return ace->id_result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ace_open(struct block_device *bdev, fmode_t mode)
|
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++;
|
ace->users++;
|
||||||
spin_unlock_irqrestore(&ace->lock, flags);
|
spin_unlock_irqrestore(&ace->lock, flags);
|
||||||
|
|
||||||
if (bdev_check_media_change(bdev))
|
if (bdev_check_media_change(bdev) && ace->media_change)
|
||||||
ace_revalidate_disk(bdev->bd_disk);
|
ace_media_changed(ace);
|
||||||
mutex_unlock(&xsysace_mutex);
|
mutex_unlock(&xsysace_mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1080,7 +1074,7 @@ static int ace_setup(struct ace_device *ace)
|
||||||
(unsigned long long) ace->physaddr, ace->baseaddr, ace->irq);
|
(unsigned long long) ace->physaddr, ace->baseaddr, ace->irq);
|
||||||
|
|
||||||
ace->media_change = 1;
|
ace->media_change = 1;
|
||||||
ace_revalidate_disk(ace->gd);
|
ace_media_changed(ace);
|
||||||
|
|
||||||
/* Make the sysace device 'live' */
|
/* Make the sysace device 'live' */
|
||||||
add_disk(ace->gd);
|
add_disk(ace->gd);
|
||||||
|
|
Loading…
Reference in New Issue