Message ID | 1452613674-12248-2-git-send-email-mreitz@redhat.com |
---|---|
State | New |
Headers | show |
On 01/12/2016 08:47 AM, Max Reitz wrote: > Pull out the check whether a block device has a tray from > blk_dev_is_tray_open() into an own function so both attributes (whether s.an own/its own/ > there is a tray vs. whether that tray is open) can be queried > independently. > > Cc: qemu-stable <qemu-stable@nongnu.org> > Signed-off-by: Max Reitz <mreitz@redhat.com> > --- > block/block-backend.c | 10 +++++++++- > include/block/block_int.h | 1 + > 2 files changed, 10 insertions(+), 1 deletion(-) Reviewed-by: Eric Blake <eblake@redhat.com>
On Tue 12 Jan 2016 04:47:51 PM CET, Max Reitz <mreitz@redhat.com> wrote: > Pull out the check whether a block device has a tray from > blk_dev_is_tray_open() into an own function so both attributes (whether > there is a tray vs. whether that tray is open) can be queried > independently. > > Cc: qemu-stable <qemu-stable@nongnu.org> > Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Berto
diff --git a/block/block-backend.c b/block/block-backend.c index f41d326..60f9588 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -458,6 +458,14 @@ bool blk_dev_has_removable_media(BlockBackend *blk) } /* + * Does @blk's attached device model have a tray? + */ +bool blk_dev_has_tray(BlockBackend *blk) +{ + return blk->dev_ops && blk->dev_ops->is_tray_open; +} + +/* * Notify @blk's attached device model of a media eject request. * If @force is true, the medium is about to be yanked out forcefully. */ @@ -473,7 +481,7 @@ void blk_dev_eject_request(BlockBackend *blk, bool force) */ bool blk_dev_is_tray_open(BlockBackend *blk) { - if (blk->dev_ops && blk->dev_ops->is_tray_open) { + if (blk_dev_has_tray(blk)) { return blk->dev_ops->is_tray_open(blk->dev_opaque); } return false; diff --git a/include/block/block_int.h b/include/block/block_int.h index 256609d..14bf022 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -694,6 +694,7 @@ void blk_set_bs(BlockBackend *blk, BlockDriverState *bs); void blk_dev_change_media_cb(BlockBackend *blk, bool load); bool blk_dev_has_removable_media(BlockBackend *blk); +bool blk_dev_has_tray(BlockBackend *blk); void blk_dev_eject_request(BlockBackend *blk, bool force); bool blk_dev_is_tray_open(BlockBackend *blk); bool blk_dev_is_medium_locked(BlockBackend *blk);
Pull out the check whether a block device has a tray from blk_dev_is_tray_open() into an own function so both attributes (whether there is a tray vs. whether that tray is open) can be queried independently. Cc: qemu-stable <qemu-stable@nongnu.org> Signed-off-by: Max Reitz <mreitz@redhat.com> --- block/block-backend.c | 10 +++++++++- include/block/block_int.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-)