From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 939B0ECAAD2 for ; Sat, 27 Aug 2022 15:17:04 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 75A848493F; Sat, 27 Aug 2022 17:16:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="FFNPljSF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D64B48492F; Sat, 27 Aug 2022 17:15:58 +0200 (CEST) Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 57B4F84909 for ; Sat, 27 Aug 2022 17:15:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11eb44f520dso1402200fac.10 for ; Sat, 27 Aug 2022 08:15:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=/HkV2FjcWI+Wz04n7bM5CUf08mpTtgMiSXYgRFnKhXg=; b=FFNPljSFuut1Zd4Bf2bmCt9OtrCKa/h2YY2Oj3XaQOwGtr+pky8C6rWrnz9OuMfeHf KcCX479Zeg7ztbRNZRWtI8eGY02y1gI0QVLNPQhvSBCzu5L8oLSs86kMcbdRs8Ld4L+M URSBBUL+onYTZpF8XG+8T2mGltTy9IF66UZFY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=/HkV2FjcWI+Wz04n7bM5CUf08mpTtgMiSXYgRFnKhXg=; b=RlskIRqIDb39zbnthf0vlqvgsY9J4j/Ey5RBcF24+w6lOZ2V/XLCciXmPNuOAD0cqT XfcTfVnZqWigl7ot5dKZ+7nqiFeQvhR0tEXIPbyF6RRz925Ciwev2Fx7Cdb3NnZ+w6n+ 6wXo3DTG6qapNqRgXp353EEOAgAwn0NovrfkljQgxMBYPkZmybPivurUWzwMXz2zldZ8 B4xVUCMtJxUclRxZ9HPyxTsS7b8PSVlucKQOoQ8j6lqgNDopH5LISgmlM7Mhxm78eflw JzmIPUa1y/CwSG1csZ2bd2F8q+q21BkxjxwQ6EZNAluyiX9gQpV00NtnuskMspenZ9YI GM+w== X-Gm-Message-State: ACgBeo2jkSUbBUsXxTgqmCHJN7aZZxmk2APoQs2Q6uIbr+xcmWibr8Ph Q33x0KOO24jQVC4iA8SGr+7Jv2CzftFLUQ== X-Google-Smtp-Source: AA6agR5jrTfctP5uumpSoUjq5tVjhbmSK3rMMhPSyjH9D4jSKAjoaPDXGJqeGfF6cJUPaUMXw1jERw== X-Received: by 2002:a05:6871:88c:b0:11c:45a7:3f66 with SMTP id r12-20020a056871088c00b0011c45a73f66mr4127176oaq.126.1661613349177; Sat, 27 Aug 2022 08:15:49 -0700 (PDT) Received: from sjg1.lan (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id e9-20020acab509000000b00344a22e71a9sm2466876oif.9.2022.08.27.08.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 08:15:48 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Andrew Scull , Marek Vasut , Rob Herring , Sean Anderson Subject: [PATCH 08/15] sandbox: scsi: Move file size into shared struct Date: Sat, 27 Aug 2022 09:15:06 -0600 Message-Id: <20220827151513.736395-9-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220827151513.736395-1-sjg@chromium.org> References: <20220827151513.736395-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Move this information into struct scsi_emul_info so we can use it in common code. Signed-off-by: Simon Glass --- 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