Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp76042lqc; Thu, 7 Mar 2024 10:43:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW+030tFKjUblcStSu2Wg6lv2Jt3ilLjcbEIWtO0v2tdq9wrutKYde10tmrkz8j8lNl8ZL1rPtwvE5jyKudMmFIX6DOZlvtH0zMv3NH3A== X-Google-Smtp-Source: AGHT+IEEi08X2P7+etaN6lgmZhn6lp+3R1ak6eoGwInkz6g/hrA+MiK4SFpyGD96ogCAFJEF4ODB X-Received: by 2002:a05:6102:3546:b0:471:fb61:136e with SMTP id e6-20020a056102354600b00471fb61136emr8384516vss.24.1709836986251; Thu, 07 Mar 2024 10:43:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709836986; cv=pass; d=google.com; s=arc-20160816; b=iliVwKuDwDjnTHmQh3OfVdAyTOtrSn7UR9qJcbbX/DxjHPwr2Hqj88J0tzP7RTOw5c qGF+Rw0Syh5YtMWwF+D+OkNNpbeIX90ajQbwxbwBC4EnFGXko9gst6SglVtbdWPz85p2 W9kMkOy8b2YyZSzOqhHzbkPRVp+s/GPIudRADzjIOYMj24KNlJjvBxCkDBCdeKMIkNsa wrjISQS4JRrFjOgyqD+WKn7so1I2HQQTaAwQnp2RMCgAXxmtLLCBjnLej8F+7hUTX9UJ DaiQW1JrlCzWmHuctkS7Umxgfh9x012BOZYy9cdHb35h5C3lxIkoUIoScWOL8sjeJ4lV AYUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=AzvrZF0W1O24HM1GsbbaKyqRasvA+AWdRTkQVOrooq8=; fh=jHjm+N1BWNvL+6KsR35rvL0Yb6eDguVNVF83e0FeJSM=; b=Nxb1XCgoaLGqHrmgtKpkxbsBiqpubgvmN8ixgxoNhZnwKovmPkdEWoeaWPN6/ouCuY 4KQ3l6VC21wLn8/u/Uyq3EsJ6tuiuelN4y8vplWDilVQfopL8aCZIehAi8FZj8+FhOo8 S55o2U6/rzEKhF81EOKcNYFlKvWYDP9uaLUYPH5SK+JiyLUmXZGq/Bw46nFa4Rvvmn/N tVLngL3l60tcPEJAy90AjBi3WBWeOyNmVJVUA0a7MEVqrNMWXgqVTmE4BX/ktwd7vT1w JFVOD8bBGRgx0T/ltwmbTyT7m5HA+rXHQCNVVD/6SOozZhEbTx5TFRkVSR+fQAIB/CsI ZcOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-96025-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96025-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ks27-20020a056214311b00b006900582d48bsi17390385qvb.160.2024.03.07.10.43.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 10:43:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96025-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-96025-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96025-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F2E561C20EB9 for ; Thu, 7 Mar 2024 18:43:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 887951353EC; Thu, 7 Mar 2024 18:42:58 +0000 (UTC) Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id 20BD553804 for ; Thu, 7 Mar 2024 18:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.131.102.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709836978; cv=none; b=QqPpVzutSdCko6kj/rZ0UTeYzJS/P94pJXVa5T6lBTdEw9F911i7RvLx6qxeGAI9W5Fk0Na/7N6i4oqiYMtPbX6zh2y+3IhBxB5JKHISIy/B9a3NY5TYqcsp+boNEr4Tg/sEVs4CL80WFbLH2OtuVbxuwjUkX/91kALNYPO4xnk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709836978; c=relaxed/simple; bh=MTvwfxmTyM79R2y6PoopPD/AeBFc8u0r4vdurAjyuhY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OfUGdJQTQgm10W3LRK18XFYsjuitIN41G8naqfiWf6B02ngwunxuNVescX/Szv1EZpXxQZT8aaXCjGq8QBp1cq+aZBXXEWOt5NItv4WmTHNirunMO6O/uMHdoCAPPp6AndsZ/Uv3F2DswtPwYw7NCvW3t849jnwuwo4ets1LPk0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu; spf=pass smtp.mailfrom=netrider.rowland.org; arc=none smtp.client-ip=192.131.102.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netrider.rowland.org Received: (qmail 228290 invoked by uid 1000); 7 Mar 2024 13:42:55 -0500 Date: Thu, 7 Mar 2024 13:42:55 -0500 From: Alan Stern To: Dingyan Li <18500469033@163.com> Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] USB: Use EHCI control transfer pid macros instead of constant values. Message-ID: <1e7f57d6-a4c1-4a3d-8cff-f966c89a8140@rowland.harvard.edu> References: <20240307173159.318384-1-18500469033@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240307173159.318384-1-18500469033@163.com> On Fri, Mar 08, 2024 at 01:31:59AM +0800, Dingyan Li wrote: > Macros with good names offer better readability. Besides, also move > the definition to ehci.h. > > Signed-off-by: Dingyan Li <18500469033@163.com> > --- Good idea, but you missed a few spots. > drivers/usb/host/ehci-q.c | 10 +++------- > drivers/usb/host/ehci.h | 8 +++++++- > 2 files changed, 10 insertions(+), 8 deletions(-) > > diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c > index 666f5c4db25a..51b46001e344 100644 > --- a/drivers/usb/host/ehci-q.c > +++ b/drivers/usb/host/ehci-q.c > @@ -27,10 +27,6 @@ > > /*-------------------------------------------------------------------------*/ > > -/* PID Codes that are used here, from EHCI specification, Table 3-16. */ > -#define PID_CODE_IN 1 > -#define PID_CODE_SETUP 2 > - > /* fill a qtd, returning how much of the buffer we were able to queue up */ > > static unsigned int > @@ -230,7 +226,7 @@ static int qtd_copy_status ( > /* fs/ls interrupt xfer missed the complete-split */ > status = -EPROTO; > } else if (token & QTD_STS_DBE) { > - status = (QTD_PID (token) == 1) /* IN ? */ > + status = (QTD_PID(token) == PID_CODE_IN) /* IN ? */ > ? -ENOSR /* hc couldn't read data */ > : -ECOMM; /* hc couldn't write data */ > } else if (token & QTD_STS_XACT) { > @@ -606,7 +602,7 @@ qh_urb_transaction ( > /* SETUP pid */ > qtd_fill(ehci, qtd, urb->setup_dma, > sizeof (struct usb_ctrlrequest), > - token | (2 /* "setup" */ << 8), 8); > + token | (PID_CODE_SETUP << 8), 8); > > /* ... and always at least one more pid */ > token ^= QTD_TOGGLE; There is an occurrence on line 623. > @@ -642,7 +638,7 @@ qh_urb_transaction ( > } > > if (is_input) > - token |= (1 /* "in" */ << 8); > + token |= (PID_CODE_IN << 8); > /* else it's already initted to "out" pid (0 << 8) */ > > maxpacket = usb_endpoint_maxp(&urb->ep->desc); You could use PID_CODE_IN on lines 712 and 1232. There are occurrences on lines 1206, 1219. Also, there's a bunch of "switch" cases near line 433 in ehci-dbg.c. Alan Stern