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 D8531C0502A for ; Sat, 27 Aug 2022 15:16:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 866808494C; Sat, 27 Aug 2022 17:16:19 +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="a48bvG30"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 59BA88444D; Sat, 27 Aug 2022 17:15:58 +0200 (CEST) Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) (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 C79288492F for ; Sat, 27 Aug 2022 17:15:49 +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-x29.google.com with SMTP id 586e51a60fabf-11c5ee9bf43so5645282fac.5 for ; Sat, 27 Aug 2022 08:15:49 -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=WBlys5kCj4SPiIYyvfyd6fVKny/xTA59ZVEux/lYcRI=; b=a48bvG30AmLfk/I5iS7+GuiRcfCJl0YBV5/qDLN2W5TekO6CB95PxDUWbrfGSMH6MK qakCbU2i2ivvIVzlQIR/JKuDFMKQUOt5VsTmBFHMJ7aaw7ejPkS4bEZR4olI6iVc5sGb zT5tYvNVtaptXl6XGUz//0xIRGvxkWrbnSMp0= 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=WBlys5kCj4SPiIYyvfyd6fVKny/xTA59ZVEux/lYcRI=; b=mtvpfzmFUS0/9opOay4st0qq2RGJZM9GoR45kSMsHMhS2V2ey4Za71DUp+WMsd8eVz lYo7AM1hcC8AZD7rzrrH64ihd46FmFGIXwLSodG5pZDMoQnWMD1pM/pzoeZ2WU6WIMbk aYM9tcTVTRXpwn+iqfWefxEwwu/OUKJFeUUMPJhJCQ9P7Vph/H1tUjqxLBP/Ce0Gp8JB kNqmbPdJ1YqHhJHZp0Fh6ztmC4NmrgcOQdXoyGUl00eVxiTIhEzHb8TamIunVC6AB2lm ed7rwf9hu1YTD3d4YHPhKDXsTHqGji6P6TFXylzQWMAfiHR3iw2S4OSsfmSU8tOpOiIL hjsw== X-Gm-Message-State: ACgBeo1C0xB5puSWkmuM8QgFyyz73eNUtxNN1ukUaUoyGMGH86MDZ5Iq 4mj5xQlk19vFcEGbUihNHrSQAO/BcCpdkw== X-Google-Smtp-Source: AA6agR4PlCBg46qp/Gf8hPs5CCQl9Qmg6XLUqIC/yn6OMSUKG57Veyv3eJTqErvGqTbPYkCycqSVCA== X-Received: by 2002:a05:6870:600e:b0:101:652e:fadc with SMTP id t14-20020a056870600e00b00101652efadcmr4237160oaa.206.1661613348176; Sat, 27 Aug 2022 08:15:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 08:15:47 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Andrew Scull , Marek Vasut , Rob Herring , Sean Anderson Subject: [PATCH 07/15] sandbox: scsi: Move block size into shared struct Date: Sat, 27 Aug 2022 09:15:05 -0600 Message-Id: <20220827151513.736395-8-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 | 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; -- 2.37.2.672.g94769d06f0-goog