From nobody Wed Nov 27 13:54:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1731210075; cv=none; d=zohomail.com; s=zohoarc; b=Z9QChvqupEgNQrf237ZqShJr39/gtGOlTHqpd0xZ5/0TQ8B1PxTBVhUsyzBBcGTNarYNLy4dm8i+Sh3ElmDe31C/00BoqBHceB+5lcHqj/Yfhu9qKflM5H6E2W+h24KYrzkCIdU+1RGJBhVH+tDeBmQPHBFDJESK7Gt2PlxBse0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731210075; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ds0KMRTr+esWMK197iNx2SANaPoYOexQH1YChjEEvhI=; b=WZ3poXmkjalJxnKS8ti79RPiCSZsMjOmVLxpcRvjuaKgCHQb1phOF868sHItJzb5knVaRzsBRDFxaRTR/A3t1OABmesLulwKQns9GFVpp/QZuxk4XineqtJBxfcMNOL6g6+gNFYMh5yEozvsjAAttHqXhMrnF4bhCQ8qlv7p1FU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731210075266508.1733258946384; Sat, 9 Nov 2024 19:41:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9yoB-0007dP-F2; Sat, 09 Nov 2024 22:40:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9yo9-0007cm-AZ for qemu-devel@nongnu.org; Sat, 09 Nov 2024 22:40:13 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9yo7-0000PF-S0 for qemu-devel@nongnu.org; Sat, 09 Nov 2024 22:40:13 -0500 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-71e5a62031aso2771852b3a.1 for ; Sat, 09 Nov 2024 19:40:11 -0800 (PST) Received: from wheely.local0.net (124-171-217-17.tpgi.com.au. [124.171.217.17]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7240799bb78sm6345273b3a.95.2024.11.09.19.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 19:40:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731210010; x=1731814810; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ds0KMRTr+esWMK197iNx2SANaPoYOexQH1YChjEEvhI=; b=DBjHl1ThWEY7zkR7oqqJvxXu47uQnnPcuWi+mAuVtPV0jHe0EfvAZrd6+eWZZvkg03 fOcBWaRmVNtXagKeb30z7KKTxd/eJOoJ5MTAIWth8B68FGl67AWIxIamcGURVMGs4Zhd Y3bSMFFeEeL0yLaVImttXIxcfTQSO0DwODIzhbYbfRp/wFmvMPCJq1PSOCzOA6byCJBO A6jzhtPlO5rgYKCbot7ZWbwa1G650shc1R2IoGdW1OlaW8kWvVCm5xyr+Sjr2hJZwzZs pNTQoykZqr0Xvq0ymdPzXDGL112SkTnXc2sveHiDECv3RjakgmUwXsTMTqMNrTmDd+tw DnGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731210010; x=1731814810; 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:message-id:reply-to; bh=Ds0KMRTr+esWMK197iNx2SANaPoYOexQH1YChjEEvhI=; b=ppkC2kcNVEgzKtyPWaa8fPUbneXs4yHRmN80p08Zw3jOczThTe6/aDPmO4/w7ANnZ1 A4d1y2yBFTtTPyoGyBvkoUYejGRGAPDxsSJSTHvIfyrhLmdhYnZK/HXr8v/5cYjCBYBA G2EDZkjexLdRONMwYv2HqcCgCFuHDHJckK77KwYQc6s39mxOb0imhY4KN3j3uqZBlbmK K0G70dNW4ZFfAcxaq56P3WfRvQypOW6wK98jUqijzIe0zEcLZcpoUyqx6xTyjwVVVlwC BlvvbL3QCPSYr1sqtjcNKME0ss77OABhxWKp3h0VV21PDeltQiCUkTaXAGFvQ3LYsvmC GxEg== X-Gm-Message-State: AOJu0Yw0bupBGI959Ai0G4bGHONcamFEhQj55fuN7B/FT7kfN7MOsZ7X VdhjDqSyNVurDcGqBJumsP4ckVT2yOSejttI0R71pAbKOYviZSI9YTZ5ng== X-Google-Smtp-Source: AGHT+IFHhzZBhUeX/irPuEpMRhaRrMo57Rt/Ubu4juLUC/68w6dRL9Lp9OBRstJaTavf7tSI4bUbRA== X-Received: by 2002:a05:6a00:14d2:b0:71e:cb:e7bf with SMTP id d2e1a72fcca58-724133625a2mr10390155b3a.18.1731210009987; Sat, 09 Nov 2024 19:40:09 -0800 (PST) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , Gerd Hoffmann Subject: [RFC PATCH 1/2] usb/msd: Add status to usb_msd_packet_complete() function Date: Sun, 10 Nov 2024 13:39:59 +1000 Message-ID: <20241110034000.379463-2-npiggin@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110034000.379463-1-npiggin@gmail.com> References: <20241110034000.379463-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=npiggin@gmail.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1731210077235116600 Content-Type: text/plain; charset="utf-8" This is a convenience change that accepts a status when completing a packet. Signed-off-by: Nicholas Piggin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/usb/dev-storage.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 341e505bd0..4f1e8b7f6c 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -177,7 +177,7 @@ static const USBDesc desc =3D { .str =3D desc_strings, }; =20 -static void usb_msd_packet_complete(MSDState *s) +static void usb_msd_packet_complete(MSDState *s, int status) { USBPacket *p =3D s->packet; =20 @@ -187,6 +187,7 @@ static void usb_msd_packet_complete(MSDState *s) * usb_packet_complete returns. */ trace_usb_msd_packet_complete(); + p->status =3D status; s->packet =3D NULL; usb_packet_complete(&s->dev, p); } @@ -196,8 +197,7 @@ static void usb_msd_fatal_error(MSDState *s) trace_usb_msd_fatal_error(); =20 if (s->packet) { - s->packet->status =3D USB_RET_STALL; - usb_msd_packet_complete(s); + usb_msd_packet_complete(s, USB_RET_STALL); } =20 /* @@ -255,8 +255,8 @@ void usb_msd_transfer_data(SCSIRequest *req, uint32_t l= en) usb_msd_copy_data(s, p); p =3D s->packet; if (p && p->actual_length =3D=3D p->iov.size) { - p->status =3D USB_RET_SUCCESS; /* Clear previous ASYNC status = */ - usb_msd_packet_complete(s); + /* USB_RET_SUCCESS status clears previous ASYNC status */ + usb_msd_packet_complete(s, USB_RET_SUCCESS); } } } @@ -295,8 +295,8 @@ void usb_msd_command_complete(SCSIRequest *req, size_t = resid) s->mode =3D USB_MSDM_CSW; } } - p->status =3D USB_RET_SUCCESS; /* Clear previous ASYNC status */ - usb_msd_packet_complete(s); + /* USB_RET_SUCCESS status clears previous ASYNC status */ + usb_msd_packet_complete(s, USB_RET_SUCCESS); } else if (s->data_len =3D=3D 0) { s->mode =3D USB_MSDM_CSW; } @@ -332,8 +332,7 @@ void usb_msd_handle_reset(USBDevice *dev) assert(s->req =3D=3D NULL); =20 if (s->packet) { - s->packet->status =3D USB_RET_STALL; - usb_msd_packet_complete(s); + usb_msd_packet_complete(s, USB_RET_STALL); } =20 memset(&s->csw, 0, sizeof(s->csw)); --=20 2.45.2