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 7D90FECAAD8 for ; Wed, 21 Sep 2022 14:23:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3432684CB3; Wed, 21 Sep 2022 16:22:50 +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="ZkmbeleW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CFE4684CA8; Wed, 21 Sep 2022 16:22:37 +0200 (CEST) Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 A8F1984CB5 for ; Wed, 21 Sep 2022 16:22:31 +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-ed1-x535.google.com with SMTP id m3so8898561eda.12 for ; Wed, 21 Sep 2022 07:22:31 -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:subject:date; bh=i4SLwE+dsGbbRzPZAyrU23xt7QXWADwvqx8Rs87lZM4=; b=ZkmbeleWLAt3T+30w/gxZLZvzYsjkepIJ8OepK42ak3ptghOLxsryKJrEel4vwpznf DVGcpZiZ5HTpNBFbDfbe0zdu78t5HmLJuDNa0yeKhrVPOOSpIu+WqB4ER8l69TfFpjjO LjngfVfzsEHQnS3LG3ZloSHO+SrZ6BjXLdt8g= 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 :subject:date; bh=i4SLwE+dsGbbRzPZAyrU23xt7QXWADwvqx8Rs87lZM4=; b=C2E3Asagmqamcv+IlMpIak1mAAdMjNWCeZ1EADnhHKt4Tu0CoKekyeZvGobCz6KPLh yf8gyf0hwapbYW3az1gLAd/QJg7Ym6bQh8q5QhNswHuhHQJ6YIHuKsCXxeqR5l0PjUTW Il2j6pzz9tBVMyJDD92Zj3GnQbICpfZPNqD6MB/Xqz1NWPbRNnWXJbkgU75Qz6gEHebq aaB8a6tHfzeboBzjP3GwohnatfbcJnskE0o9W161DRJU79GUpXZ910stNEXA/95n0tbM enGLeEzqEbPJFKj73gfPqCf3ytWnni4Bd3jWaHfNqzzr3b7/kJadKtDn4Z5HmNsqWE32 8SEg== X-Gm-Message-State: ACrzQf1+rM5dcDhNmhmO8mcmHvWfL8f8sRCmzZ2tPH+yEIlN4cdoWHBs WEybFNHnqG2mh9C2nLXWP8a+e0jOdE41+44o X-Google-Smtp-Source: AMsMyM5ZLQgium8BiqJvyrJUzH3BLRMsEGiY6S5lZcXjb+edm7+aYXTyQxZNI7MVDrV6V5RhdKg/Qw== X-Received: by 2002:aa7:d392:0:b0:44e:67f2:c79c with SMTP id x18-20020aa7d392000000b0044e67f2c79cmr24567970edq.278.1663770151244; Wed, 21 Sep 2022 07:22:31 -0700 (PDT) Received: from sjg1.roam.corp.google.com (66.218.241.83.in-addr.dgcsystems.net. [83.241.218.66]) by smtp.gmail.com with ESMTPSA id 17-20020a170906219100b007807e4f6b30sm1387089eju.103.2022.09.21.07.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 07:22:30 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Andrew Scull , Marek Vasut , Rob Herring , Sean Anderson Subject: [PATCH v2 08/15] sandbox: scsi: Move file size into shared struct Date: Wed, 21 Sep 2022 16:21:40 +0200 Message-Id: <20220921142147.1083886-9-sjg@chromium.org> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog In-Reply-To: <20220921142147.1083886-1-sjg@chromium.org> References: <20220921142147.1083886-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 --- (no changes since v1) 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.3.968.ga6b4b080e4-goog