qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, kwolf@redhat.com
Subject: [Qemu-devel] [PATCH 4/5] ide/atapi: Replace bdrv_get_geometry calls by s->nb_sectors
Date: Tue, 19 Apr 2011 14:36:42 +0200	[thread overview]
Message-ID: <1303216603-11658-5-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1303216603-11658-1-git-send-email-kwolf@redhat.com>

The disk size can only change when the medium is changed, and the change
callback takes care of updating s->nb_sectors in this case.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hw/ide/atapi.c |   21 ++++++---------------
 1 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index e8ac764..032d1b0 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -416,10 +416,10 @@ static int ide_dvd_read_structure(IDEState *s, int format,
                 if (layer != 0)
                     return -ASC_INV_FIELD_IN_CMD_PACKET;
 
-                bdrv_get_geometry(s->bs, &total_sectors);
-                total_sectors >>= 2;
-                if (total_sectors == 0)
+                total_sectors = s->nb_sectors >> 2;
+                if (total_sectors == 0) {
                     return -ASC_MEDIUM_NOT_PRESENT;
+                }
 
                 buf[4] = 1;   /* DVD-ROM, part version 1 */
                 buf[5] = 0xf; /* 120mm disc, minimum rate unspecified */
@@ -881,11 +881,8 @@ static void cmd_read_cd(IDEState *s, uint8_t* buf)
 static void cmd_seek(IDEState *s, uint8_t* buf)
 {
     unsigned int lba;
-    uint64_t total_sectors;
-
-    bdrv_get_geometry(s->bs, &total_sectors);
+    uint64_t total_sectors = s->nb_sectors >> 2;
 
-    total_sectors >>= 2;
     if (total_sectors == 0) {
         ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
         return;
@@ -944,12 +941,9 @@ static void cmd_mechanism_status(IDEState *s, uint8_t* buf)
 static void cmd_read_toc_pma_atip(IDEState *s, uint8_t* buf)
 {
     int format, msf, start_track, len;
-    uint64_t total_sectors;
+    uint64_t total_sectors = s->nb_sectors >> 2;
     int max_len;
 
-    bdrv_get_geometry(s->bs, &total_sectors);
-
-    total_sectors >>= 2;
     if (total_sectors == 0) {
         ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
         return;
@@ -990,11 +984,8 @@ static void cmd_read_toc_pma_atip(IDEState *s, uint8_t* buf)
 
 static void cmd_read_cdvd_capacity(IDEState *s, uint8_t* buf)
 {
-    uint64_t total_sectors;
-
-    bdrv_get_geometry(s->bs, &total_sectors);
+    uint64_t total_sectors = s->nb_sectors >> 2;
 
-    total_sectors >>= 2;
     if (total_sectors == 0) {
         ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
         return;
-- 
1.7.2.3

  parent reply	other threads:[~2011-04-19 12:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-19 12:36 [Qemu-devel] [PATCH 0/5] atapi: Some code restructuring Kevin Wolf
2011-04-19 12:36 ` [Qemu-devel] [PATCH 1/5] ide: Split atapi.c out Kevin Wolf
2011-04-19 12:36 ` [Qemu-devel] [PATCH 2/5] ide/atapi: Factor some commands out Kevin Wolf
2011-04-19 12:36 ` [Qemu-devel] [PATCH 3/5] ide/atapi: Use table instead of switch for commands Kevin Wolf
2011-04-19 13:20   ` Amit Shah
2011-04-19 13:34     ` Kevin Wolf
2011-04-19 12:36 ` Kevin Wolf [this message]
2011-04-19 12:36 ` [Qemu-devel] [PATCH 5/5] ide/atapi: Introduce NEED_DISK flag " Kevin Wolf
2011-04-19 13:18   ` Amit Shah
2011-04-19 13:45     ` Kevin Wolf
2011-04-19 13:21 ` [Qemu-devel] [PATCH 0/5] atapi: Some code restructuring Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1303216603-11658-5-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).