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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EFB2C433F5 for ; Tue, 15 Mar 2022 17:26:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350546AbiCOR1T (ORCPT ); Tue, 15 Mar 2022 13:27:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350543AbiCOR1Q (ORCPT ); Tue, 15 Mar 2022 13:27:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187A248E79 for ; Tue, 15 Mar 2022 10:26:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AAADA615A2 for ; Tue, 15 Mar 2022 17:26:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C896C340EE; Tue, 15 Mar 2022 17:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647365162; bh=Ij4oiFcgoMgMx5C5TPSOMZBFORHOmbZ8CQV6BwrUosE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V7JsfvLYHr9M1VDy4puiSX//sOIjTRX5Xh3KFWxNzDgBO7fk5oytj5RZD49FNgAra IdJyri8WTDOEgIrz8XzVooPh+y1I6YbXk00NPhXaLD+rUud8U1GUH6MWJzHkVdUKHI KcUYAhGa3fLGQJXo2jkchP0lvVTnwY7tqJ/avvPc= Date: Tue, 15 Mar 2022 18:25:58 +0100 From: Greg Kroah-Hartman To: Vincent Mailhol Cc: linux-usb@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , Ville Syrjala , Dmitry Torokhov , Henk Vergonet , Sean Young , Mauro Carvalho Chehab , Benjamin Valentin , Oliver Neukum , "David S. Miller" , Jakub Kicinski , Woojung Huh , Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Kalle Valo , Matthias Brugger , Stanislaw Gruszka , Helmut Schaa , Duncan Sands , Alan Stern , Olav Kongas , Rui Miguel Silva , Jaroslav Kysela , Takashi Iwai , Clemens Ladisch Subject: Re: [PATCH v2 03/10] usb: rework usb_maxpacket() and deprecate its third argument Message-ID: References: <20220304105420.1059585-1-mailhol.vincent@wanadoo.fr> <20220306075524.706660-1-mailhol.vincent@wanadoo.fr> <20220306075524.706660-4-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220306075524.706660-4-mailhol.vincent@wanadoo.fr> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Sun, Mar 06, 2022 at 04:55:17PM +0900, Vincent Mailhol wrote: > This is a transitional patch with the goal of changing the prototype > of usb_maxpacket() from: > | static inline __u16 > | usb_maxpacket(struct usb_device *udev, int pipe, int is_out) > > into: > | static inline u16 usb_maxpacket(struct usb_device *dev, int pipe) > > The third argument of usb_maxpacket(): is_out gets removed because it > can be derived from its second argument: pipe using > usb_pipeout(pipe). Furthermore, in the current version, > ubs_pipeout(pipe) is called regardless in order to sanitize the is_out > parameter. > > In order to make a smooth change, we first deprecate the is_out > parameter by simply ignoring it (using a variadic function) and will > remove it latter, once all the callers get updated. > > Finally, the body of the function is reworked in order not to reinvent > the wheel and just relies on the usb_pipe_endpoint() helper function > instead. > > Signed-off-by: Vincent Mailhol > --- > include/linux/usb.h | 24 +++--------------------- > 1 file changed, 3 insertions(+), 21 deletions(-) > > diff --git a/include/linux/usb.h b/include/linux/usb.h > index 200b7b79acb5..588aa7dc3d10 100644 > --- a/include/linux/usb.h > +++ b/include/linux/usb.h > @@ -1969,30 +1969,12 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) > return eps[usb_pipeendpoint(pipe)]; > } > > -/*-------------------------------------------------------------------------*/ > - > -static inline __u16 > -usb_maxpacket(struct usb_device *udev, int pipe, int is_out) > +static inline u16 usb_maxpacket(struct usb_device *dev, int pipe, > + /* int is_out deprecated */ ...) No need to change from udev->dev, right? > { > - struct usb_host_endpoint *ep; > - unsigned epnum = usb_pipeendpoint(pipe); > - > - if (is_out) { > - WARN_ON(usb_pipein(pipe)); > - ep = udev->ep_out[epnum]; > - } else { > - WARN_ON(usb_pipeout(pipe)); > - ep = udev->ep_in[epnum]; > - } > - if (!ep) > - return 0; > - > - /* NOTE: only 0x07ff bits are for packet size... */ > - return usb_endpoint_maxp(&ep->desc); > + return usb_endpoint_maxp(&usb_pipe_endpoint(dev, pipe)->desc); The change to use usb_pipe_endpoint() can be done separately. Let's make these in tiny steps so that we can easily roll things back if things are not working. thanks, greg k-h