From patchwork Wed Sep 21 14:21:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1680723 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=PpaX3VGy; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MXgdP6Fhxz1ypX for ; Thu, 22 Sep 2022 00:23:53 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BF64584CC2; Wed, 21 Sep 2022 16:22:51 +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="PpaX3VGy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 700CA84CA9; Wed, 21 Sep 2022 16:22:39 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (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 1CFCD84CB3 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-ej1-x631.google.com with SMTP id dv25so13920144ejb.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=YAKrtjm+88ALo5IpeOHWPx10lmqBwjHiig8NT9DEgPE=; b=PpaX3VGyuOi/dRVezxKLaL8iYGqBF99cTKMvWTFBBve1tacxaLkHy9gEj7+oCmLAax nBc1TcTZM8XD0IFJ827LRxQWgznGou0A//D/mBhh4DyPFCPF2osUpb2Qg1BDrojU5R+2 3o4uf8MqcbkIDu9YbgP0fID40GUWaK759eWCw= 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=YAKrtjm+88ALo5IpeOHWPx10lmqBwjHiig8NT9DEgPE=; b=44OfZBiXhDhpPte7VplYEZxH052DZgHvQXZ9Fy6yqJF30HmV0JpX7o8Yek5SAIntja 3cleyR6vXGAuDFglYmZQPt4hCYDnbmB0tMDdSgP2AbexnU24cHhQihjkOx9U5VDnflmh 4W3CTzMoc95DCEZclVKG/2FjseyrDQzvisV1V1vtVuz3Wu03cx0lKDTMhzKvgYM494OB H4SsMvEuvx9GSuyPpN7BcmKUDRZRtCf1sFd4O19tJLVCh78ezfh2DKmA4mrqotdRaCmw TPir+b1sKFAdwiljbzUoxuzwHaq3hZLyJtz7k3wPKfB3oGziEKELw2naU4/wUOvRKGKG L/ww== X-Gm-Message-State: ACrzQf2/ZDOlskbZYgWRzRBjRee70Hi/vetIzW47AqxE5dsXp+dvqnRv GLvDe1z/y5QRri3ZRNGldGSk9Ly0QGqDR0jK X-Google-Smtp-Source: AMsMyM4p0R+xXw47SmG4UCy42u3a7wRajLnst/mWxoHSMtT4TkNTr3MhXA3jPuLaWMCQmxUjNO9TCg== X-Received: by 2002:a17:907:86ac:b0:780:df48:6a74 with SMTP id qa44-20020a17090786ac00b00780df486a74mr16192688ejc.656.1663770150298; Wed, 21 Sep 2022 07:22:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 07:22:29 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Andrew Scull , Marek Vasut , Rob Herring , Sean Anderson Subject: [PATCH v2 07/15] sandbox: scsi: Move block size into shared struct Date: Wed, 21 Sep 2022 16:21:39 +0200 Message-Id: <20220921142147.1083886-8-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 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 | 11 ++++++----- include/scsi_emul.h | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/usb/emul/sandbox_flash.c b/drivers/usb/emul/sandbox_flash.c index eaa7f1e7ff6..e4a8eb2e988 100644 --- a/drivers/usb/emul/sandbox_flash.c +++ b/drivers/usb/emul/sandbox_flash.c @@ -222,9 +222,9 @@ static void handle_read(struct sandbox_flash_priv *priv, ulong lba, debug("%s: lba=%lx, transfer_len=%lx\n", __func__, lba, transfer_len); info->read_len = transfer_len; if (priv->fd != -1) { - os_lseek(priv->fd, lba * SANDBOX_FLASH_BLOCK_LEN, OS_SEEK_SET); + os_lseek(priv->fd, lba * info->block_size, OS_SEEK_SET); setup_response(priv, info->buff, - transfer_len * SANDBOX_FLASH_BLOCK_LEN); + transfer_len * info->block_size); } else { setup_fail_response(priv); } @@ -259,11 +259,11 @@ static int handle_ufi_command(struct sandbox_flash_plat *plat, uint blocks; if (priv->file_size) - blocks = priv->file_size / SANDBOX_FLASH_BLOCK_LEN - 1; + blocks = priv->file_size / info->block_size - 1; else blocks = 0; resp->last_block_addr = cpu_to_be32(blocks); - resp->block_len = cpu_to_be32(SANDBOX_FLASH_BLOCK_LEN); + resp->block_len = cpu_to_be32(info->block_size); setup_response(priv, resp, sizeof(*resp)); break; } @@ -332,7 +332,7 @@ static int sandbox_flash_bulk(struct udevice *dev, struct usb_device *udev, bytes_read = os_read(priv->fd, buff, len); if (bytes_read != len) return -EIO; - info->read_len -= len / SANDBOX_FLASH_BLOCK_LEN; + info->read_len -= len / info->block_size; if (!info->read_len) info->phase = SCSIPH_STATUS; } else { @@ -404,6 +404,7 @@ static int sandbox_flash_probe(struct udevice *dev) return log_ret(-ENOMEM); info->vendor = plat->flash_strings[STRINGID_MANUFACTURER - 1].s; info->product = plat->flash_strings[STRINGID_PRODUCT - 1].s; + info->block_size = SANDBOX_FLASH_BLOCK_LEN; return 0; } diff --git a/include/scsi_emul.h b/include/scsi_emul.h index b281c166f6f..86c9379ca9e 100644 --- a/include/scsi_emul.h +++ b/include/scsi_emul.h @@ -17,6 +17,7 @@ * * @vendor: Vendor name * @product: Product name + * @block_size: Block size of device in bytes (normally 512) * * @phase: Current SCSI phase * @buff_used: Number of bytes ready to transfer back to host @@ -30,6 +31,7 @@ struct scsi_emul_info { void *buff; const char *vendor; const char *product; + int block_size; /* state maintained by the emulator: */ enum scsi_cmd_phase phase;