u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Simon Glass <sjg@chromium.org>, Andrew Scull <ascull@google.com>,
	Marek Vasut <marex@denx.de>,
	Rob Herring <rob.herring@calxeda.com>,
	Sean Anderson <seanga2@gmail.com>
Subject: [PATCH 08/15] sandbox: scsi: Move file size into shared struct
Date: Sat, 27 Aug 2022 09:15:06 -0600	[thread overview]
Message-ID: <20220827151513.736395-9-sjg@chromium.org> (raw)
In-Reply-To: <20220827151513.736395-1-sjg@chromium.org>

Move this information into struct scsi_emul_info so we can use it in
common code.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/usb/emul/sandbox_flash.c | 7 +++----
 include/scsi_emul.h              | 2 ++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/emul/sandbox_flash.c b/drivers/usb/emul/sandbox_flash.c
index e4a8eb2e988..3c5bc675e3c 100644
--- a/drivers/usb/emul/sandbox_flash.c
+++ b/drivers/usb/emul/sandbox_flash.c
@@ -49,7 +49,6 @@ struct sandbox_flash_priv {
 	bool error;
 	u32 tag;
 	int fd;
-	loff_t file_size;
 	struct umass_bbb_csw status;
 };
 
@@ -258,8 +257,8 @@ static int handle_ufi_command(struct sandbox_flash_plat *plat,
 		struct scsi_read_capacity_resp *resp = (void *)info->buff;
 		uint blocks;
 
-		if (priv->file_size)
-			blocks = priv->file_size / info->block_size - 1;
+		if (info->file_size)
+			blocks = info->file_size / info->block_size - 1;
 		else
 			blocks = 0;
 		resp->last_block_addr = cpu_to_be32(blocks);
@@ -395,7 +394,7 @@ static int sandbox_flash_probe(struct udevice *dev)
 
 	priv->fd = os_open(plat->pathname, OS_O_RDONLY);
 	if (priv->fd != -1) {
-		ret = os_get_filesize(plat->pathname, &priv->file_size);
+		ret = os_get_filesize(plat->pathname, &info->file_size);
 		if (ret)
 			return log_msg_ret("sz", ret);
 	}
diff --git a/include/scsi_emul.h b/include/scsi_emul.h
index 86c9379ca9e..3c52398e3ff 100644
--- a/include/scsi_emul.h
+++ b/include/scsi_emul.h
@@ -18,6 +18,7 @@
  * @vendor: Vendor name
  * @product: Product name
  * @block_size: Block size of device in bytes (normally 512)
+ * @file_size: Size of the backing file for this emulator, in bytes
  *
  * @phase: Current SCSI phase
  * @buff_used: Number of bytes ready to transfer back to host
@@ -32,6 +33,7 @@ struct scsi_emul_info {
 	const char *vendor;
 	const char *product;
 	int block_size;
+	loff_t file_size;
 
 	/* state maintained by the emulator: */
 	enum scsi_cmd_phase phase;
-- 
2.37.2.672.g94769d06f0-goog


  parent reply	other threads:[~2022-08-27 15:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-27 15:14 [PATCH 00/15] scsi: Convert sandbox SCSI to driver model Simon Glass
2022-08-27 15:14 ` [PATCH 01/15] scsi: Tidy up comments for struct scsi_cmd Simon Glass
2022-08-29 14:49   ` Heinrich Schuchardt
2022-08-27 15:15 ` [PATCH 02/15] sandbox: usb: Rename transfer_len in protocol struct Simon Glass
2022-08-27 15:15 ` [PATCH 03/15] scsi: Move cmd_phase enum to the header Simon Glass
2022-08-29 14:50   ` Heinrich Schuchardt
2022-08-27 15:15 ` [PATCH 04/15] scsi: Move core emulation state into a new struct Simon Glass
2022-08-27 15:15 ` [PATCH 05/15] sandbox: Move buffer to scsi_emul_info Simon Glass
2022-08-27 15:15 ` [PATCH 06/15] scsi: Move vendor/product info into the shared struct Simon Glass
2022-08-27 15:15 ` [PATCH 07/15] sandbox: scsi: Move block size into " Simon Glass
2022-08-27 15:15 ` Simon Glass [this message]
2022-08-27 15:15 ` [PATCH 09/15] sandbox: scsi: Move reply setup out of helper Simon Glass
2022-08-27 15:15 ` [PATCH 10/15] sandbox: scsi: Remove setup calls from handle_read() Simon Glass
2022-08-27 15:15 ` [PATCH 11/15] sandbox: scsi: Move structs to header file Simon Glass
2022-08-29 14:51   ` Heinrich Schuchardt
2022-08-27 15:15 ` [PATCH 12/15] sandbox: Enable SCSI for all builds Simon Glass
2022-08-27 15:15 ` [PATCH 13/15] sandbox: scsi: Move request-handling code to scsi_emul Simon Glass
2022-08-27 15:15 ` [PATCH 14/15] sandbox: Convert to use driver model for SCSI Simon Glass
2022-08-27 15:15 ` [PATCH 15/15] sandbox: Add a test " Simon Glass

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=20220827151513.736395-9-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=ascull@google.com \
    --cc=marex@denx.de \
    --cc=rob.herring@calxeda.com \
    --cc=seanga2@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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).